Skip to content

Commit

Permalink
[#289] [fix] >1 arity parse-map broken since v3.3.0
Browse files Browse the repository at this point in the history
Thanks to @zerg000000 for the report!
  • Loading branch information
ptaoussanis committed Oct 24, 2023
1 parent af4bea1 commit ab00f2a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/taoensso/carmine.clj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,17 @@
(defn as-int [x] (when x (enc/as-int x)))
(defn as-float [x] (when x (enc/as-float x)))
(defn as-bool [x] (when x (enc/as-bool x)))
(defn as-map [x] (when x (persistent! (enc/reduce-kvs assoc! (transient {}) x))))
(defn as-map
([x ] (if (empty? x) {} (persistent! (enc/reduce-kvs assoc! (transient {}) x))))
([x & [kf vf]]
(if (empty? x)
{}
(let [kf (case kf nil (fn [_ v] v) kf)
vf (case vf nil (fn [k _] k) :keywordize (fn [k _] (keyword k)) vf)]
(persistent!
(enc/reduce-kvs
(fn [m k v] (assoc! m (kf k v) (vf k v)))
(transient {}) x))))))

(enc/defalias parse protocol/parse)
(enc/defalias parser-comp protocol/parser-comp)
Expand Down

0 comments on commit ab00f2a

Please sign in to comment.