function | since v1.9.456 | clojure.lang/PersistentHashMap.createWithCheck | Edit |
(PersistentHashMap.createWithCheck arr)
(set! (.-createWithCheck PersistentHashMap)
(fn [arr]
(let [len (alength arr)
ret (transient (.-EMPTY PersistentHashMap))]
(loop [i 0]
(when (< i len)
(-assoc! ret (aget arr i) (aget arr (inc i)))
(if (not= (-count ret) (inc (/ i 2)))
(throw (js/Error. (str "Duplicate key: " (aget arr i))))
(recur (+ i 2)))))
(-persistent! ret))))