Skip to content

Instantly share code, notes, and snippets.

@StanAngeloff
Created February 27, 2010 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StanAngeloff/316933 to your computer and use it in GitHub Desktop.
Save StanAngeloff/316933 to your computer and use it in GitHub Desktop.
$unlink: (object) ->
if isArray(object)
$unlink(child) for child in object
else if typeof object is 'object'
unlinked: {}
(unlinked[key]: $unlink(value)) for key, value of object
return unlinked
else
object
var $unlink;
var __hasProp = Object.prototype.hasOwnProperty;
$unlink = function $unlink(object) {
var _a, _b, _c, _d, _e, 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') {
unlinked = {};
_e = object;
for (key in _e) { if (__hasProp.call(_e, key)) {
value = _e[key];
((unlinked[key] = $unlink(value)));
}}
return unlinked;
} else {
return object;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment