From 68d75aacc981c67f3a8cc171f72d1fc3e79c4447 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 28 May 2016 13:45:50 +0300 Subject: [PATCH] Add dissoc-in helper into uxbox.util.data --- src/uxbox/util/data.cljs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/uxbox/util/data.cljs b/src/uxbox/util/data.cljs index 904bfe384..bfff82086 100644 --- a/src/uxbox/util/data.cljs +++ b/src/uxbox/util/data.cljs @@ -37,6 +37,17 @@ (persistent! (reduce #(dissoc! %1 %2) (transient data) keys))) +(defn dissoc-in + [m [k & ks :as keys]] + (if ks + (if-let [nextmap (get m k)] + (let [newmap (dissoc-in nextmap ks)] + (if (seq newmap) + (assoc m k newmap) + (dissoc m k))) + m) + (dissoc m k))) + (defn index-of "Return the first index when appears the `v` value in the `coll` collection."