Created
July 27, 2012 01:48
-
-
Save terraflubb/3185739 to your computer and use it in GitHub Desktop.
Abasso#cast in coffeescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cast = (obj, key = false) -> | |
o = [] | |
unless isNan obj.length | |
if !client.ie or client.version > 8 | |
o = Array::slice.call obj | |
else | |
utility.iterate obj, (i, idx) -> | |
o.push i unless idx is "length" | |
else | |
if key | |
o = array.keys obj | |
else | |
utility.iterate obj, (i) -> o.push i | |
o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's close to what I had cooked up yesterday, but as soon as I try to put that inside an object like below, I get a syntax error