Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
(defn oget
"Like `aget` for JS objects, Ref. Unlike `aget`,
returns nil for missing keys instead of throwing."
([o k] (when o (gobj/get o k nil)))
([o k1 k2] (when-let [o (oget o k1)] (gobj/get o k2 nil))) ; Optimized common case
([o k1 k2 & ks] (when-let [o (oget o k1 k2)] (apply oget o ks)))) ; Can also lean on optimized 2-case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.