This commit is contained in:
nathanmarz 2017-01-08 19:15:14 -05:00
parent 1346cbc222
commit 9505ac6dd1
3 changed files with 5 additions and 3 deletions

View file

@ -1,6 +1,6 @@
## 0.13.3-SNAPSHOT
* Transform to `com.rpl.specter/NONE` to remove elements from data structures. Works with `keypath` (on maps only), `must` (on maps only), `ALL`, and `MAP-VALS`
* Transform to `com.rpl.specter/NONE` to remove elements from data structures. Works with `keypath` (for both sequences and maps), `must`, `ALL`, and `MAP-VALS`
* Dynamic navs automatically compile sequence returns if completely static
## 0.13.2

View file

@ -466,10 +466,11 @@
(defn- do-keypath-transform [vals structure key next-fn]
;;TODO: not right, this doesn't handle sequences
(let [newv (next-fn vals (get structure key))]
(if (identical? newv i/NONE)
(dissoc structure key)
(if (sequential? structure)
(i/srange-transform* structure key (inc key) (fn [_] []))
(dissoc structure key))
(assoc structure key newv))))
(defrichnav

View file

@ -1327,6 +1327,7 @@
(is (predand= list? '(1 2 3) (setval [s/ALL nil?] s/NONE '(1 2 nil 3 nil))))
(is (= {:b 2} (setval :a s/NONE {:a 1 :b 2})))
(is (= {:b 2} (setval (s/must :a) s/NONE {:a 1 :b 2})))
(is (predand= vector? [1 3] (setval (s/keypath 1) s/NONE [1 2 3])))
;; test with PersistentArrayMap
(is (= {:a 1 :c 3} (setval [s/MAP-VALS even?] s/NONE {:a 1 :b 2 :c 3 :d 4})))
(is (= {:a 1 :c 3} (setval [s/ALL (s/selected? s/LAST even?)] s/NONE {:a 1 :b 2 :c 3 :d 4})))