Created
February 16, 2010 01:01
-
-
Save perplexes/305169 to your computer and use it in GitHub Desktop.
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
Object.prototype.tap: (func) -> | |
func.apply(this, [this]) | |
Object.prototype.clone: -> | |
((this instanceof Array) ? [] : {}).tap (newObj) => | |
for key, val of this | |
if key == 'clone' | |
# no op | |
else if val && typeof val == 'object' | |
newObj[key] = val.clone() | |
else | |
newObj[key] = val | |
Object.prototype.merge: (obj) -> | |
@clone().tap (newObj) -> | |
for key, val of obj | |
newObj[key] = val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment