Use REST inside your Clojure programs. Represent an edit to a data structure as a data structure (patch) and apply it to any nested combination of maps, lists, vectors and sets.
[patcher "0.0.0"]
A patch is a map with 3 keys: :type
, :path
and :value
. :type
can be :put
, :post
and :delete
.
:put
will replace whatever value you would get with (get-in coll path)
with value
:post
is similar, but it will conj
or merge
(in case of maps) value
to existing data instead of replacing it
:delete
will purge it from the data structure so that (get-in coll path)
returns nil
(apply-patch {:type :post :path [:interests] :value :music} {:age 35 :sex :male :interests [:cooking]})
=> {:age 35 :sex :male :interests [:cooking :music]}
Copyright © 2018 FIXME
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close