function | since v1.9.456 | clojure.lang/PersistentArrayMap.createWithCheck | Edit |
(PersistentArrayMap.createWithCheck arr)
(set! (.-createWithCheck PersistentArrayMap)
(fn [arr]
(let [ret (array)]
(loop [i 0]
(when (< i (alength arr))
(let [k (aget arr i)
v (aget arr (inc i))
idx (array-index-of ret k)]
(if (== idx -1)
(doto ret (.push k) (.push v))
(throw (js/Error. (str "Duplicate key: " k)))))
(recur (+ i 2))))
(let [cnt (/ (alength arr) 2)]
(PersistentArrayMap. nil cnt arr nil)))))