Skip to content

Commit

Permalink
Merge pull request #41 from jesims/JESI-2789
Browse files Browse the repository at this point in the history
  • Loading branch information
axrs committed May 24, 2019
2 parents 27cda43 + 5bd9a3e commit 8e6976d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.32
0.0.33
1 change: 1 addition & 0 deletions src/io/jesi/backpack.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
select-non-nil-keys
trans-reduce
trans-reduce-kv
transform-keys
translate-keys
update!]

Expand Down
8 changes: 1 addition & 7 deletions src/io/jesi/backpack/clojurescript.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
[clojure.string :as string]
[clojure.walk :refer [postwalk]]
[goog.object :as gobj]
[io.jesi.backpack.collection :refer [trans-reduce]]
[io.jesi.backpack.collection :refer [trans-reduce transform-keys]]
[io.jesi.backpack.string :refer [->kebab-case-key ->camelCase]]))

; Came from camel-snake-kebab
(defn transform-keys [t coll]
"Recursively transforms all map keys in coll with t."
(letfn [(transform [[k v]] [(t k) v])]
(postwalk (fn [x] (if (map? x) (into {} (map transform x)) x)) coll)))

(extend-type UUID
IEncodeJS
(-clj->js [x]
Expand Down
7 changes: 7 additions & 0 deletions src/io/jesi/backpack/collection.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
[map]
(into {} (filter (comp some? val) map)))

;TODO isn't this the same at set/rename-keys ?
(defn translate-keys
"Updates map with the keys from kmap"
[kmap map]
Expand Down Expand Up @@ -175,3 +176,9 @@
(if more
(recur ntcoll (first more) (next more))
ntcoll))))

; Came from camel-snake-kebab
(defn transform-keys [f coll]
"Recursively transforms all map keys in coll with f"
(letfn [(transform [[k v]] [(f k) v])]
(postwalk (fn [x] (if (map? x) (into {} (map transform x)) x)) coll)))

0 comments on commit 8e6976d

Please sign in to comment.