PersistentArrayMap.fromArray

functionsince v0.0-1798Edit
(PersistentArrayMap.fromArray arr no-clone no-check)

Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(set! (.-fromArray PersistentArrayMap)
  (fn [arr ^boolean no-clone ^boolean no-check]
    (as-> (if no-clone arr (aclone arr)) arr
      (if no-check
        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)]
                (when (== idx -1)
                  (.push ret k)
                  (.push ret v)))
              (recur (+ i 2))))
          ret))
      (let [cnt (/ (alength arr) 2)]
        (PersistentArrayMap. nil cnt arr nil)))))