> native-satisifes? must come last due to `default` case.
Okay, gotcha! I wasn't aware of this, thanks for the explanation.
So the concern with extending `get` to objects actually _is_ a global
regression: there's no way of avoiding a hit to anything relying on
`native-satisfies?`, is that correct?
Fully in agreement then of not modifying `get`, my mistake. Again, appreciate
the help understanding.
How would you feel about a PR to add something along these lines?:
(defn js-get "Like `get` for JS objects."
([obj k] (js-get obj k nil))
([obj k not-found]
(when (and obj (instance? js/Object obj))
(gobj/get obj k not-found))))
(def js-get-in "Like `get-in` for JS objects."
(let [sentinel (js-obj)]
(fn
([obj ks] (js-get-in obj ks nil))
([obj ks not-found]
(loop [obj obj
ks (seq ks)]
(if-not ks
obj
(if-not (and obj (instance? js/Object obj))
not-found
(let [obj (js-get obj (first ks) sentinel)]
(if (identical? obj sentinel)
not-found
(recur obj (next ks)))))))))))
Borrowed the naming convention from `js-obj`, `js-keys,` `js-delete`, etc.
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.