Skip to content

Instantly share code, notes, and snippets.

@aboekhoff
Created January 10, 2010 21:45
Show Gist options
  • Save aboekhoff/273795 to your computer and use it in GitHub Desktop.
Save aboekhoff/273795 to your computer and use it in GitHub Desktop.
;;;; *very* quick and dirty support for javascript destructuring on
;;;; native javascript arrays and objects
(add-inline-form
get [[_ a b c]]
(str "((" a "[" b "]" ")||" c ")"))
(add-inline-form
nth [[_ a b]]
(str a "[" b "]"))
(add-inline-form
nthnext [[_ a b]]
(str a ".slice(" b ")"))
;;;; pointless destructuring fn
(defscrypt trial
{:ns jury.destro}
(defn foo [{:keys [this-thingy that-thingy]
:or {this-thingy "foo"
that-thingy "bar"}}
[x y & ys]]
(alert this-thingy)
(alert that-thingy)
(alert x)
(alert y)
(alert ys)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment