Skip to content

Commit 6c4075a

Browse files
committed
Update .extend api
1 parent fb428bb commit 6c4075a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/mori.cljs

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
sum inc dec even? odd? subseq
1919
apply])
2020
(:use-macros [mori.macros :only [make-inspectable]])
21-
(:require [clojure.set :as set]
21+
(:require [goog.object]
22+
[clojure.set :as set]
2223
[clojure.data :as data]
2324
[clojure.core.reducers :as reducers]
2425
[cljs.reader :as reader]))
@@ -348,7 +349,7 @@
348349
ISeqable
349350
(-seq [this] (.call (aget methods "seq") this))))
350351

351-
(defn ^:export extend [protocol-name obj methods]
352+
(defn extend! [protocol-name obj methods]
352353
(case protocol-name
353354
"IAssociative" (extend-to-iassociative obj methods)
354355
"ICloneable" (extend-to-icloneable obj methods)
@@ -365,6 +366,12 @@
365366
"ISeqable" (extend-to-iseqable obj methods)
366367
(throw (js/Error. (str "Cannot extend to " protocol-name)))))
367368

369+
(defn ^:export extend [obj protocols]
370+
(goog.object/forEach protocols
371+
(fn [val key o]
372+
(extend! key obj val)))
373+
obj)
374+
368375
;; =============================================================================
369376
;; Closure hacks so we get exported ES6 Map/Set interface on collections
370377
;; Following functions are NOT a part of the API

0 commit comments

Comments
 (0)