Created
February 27, 2010 20:28
-
-
Save StanAngeloff/316935 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$unlink: (object) -> | |
if isArray(object) | |
$unlink(child) for child in object | |
else if typeof object is 'object' | |
{ key: $unlink(value) } for key, value of object | |
else | |
object |
This file contains hidden or 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
var $unlink; | |
var __hasProp = Object.prototype.hasOwnProperty; | |
$unlink = function $unlink(object) { | |
var _a, _b, _c, _d, _e, _f, child, key, unlinked, value; | |
if (isArray(object)) { | |
_a = []; _b = object; | |
for (_c = 0, _d = _b.length; _c < _d; _c++) { | |
child = _b[_c]; | |
_a.push($unlink(child)); | |
} | |
return _a; | |
} else if (typeof object === 'object') { | |
_e = object; | |
_f = {}; | |
for (key in _e) { if (__hasProp.call(_e, key)) { | |
value = _e[key]; | |
_f[key] = $unlink(value); | |
}} | |
return _f; | |
} else { | |
return object; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment