Last active
February 29, 2024 15:51
-
-
Save sheldonh/6089299 to your computer and use it in GitHub Desktop.
CoffeeScript Object.merge
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
merge = (xs...) -> | |
if xs?.length > 0 | |
tap {}, (m) -> m[k] = v for k, v of x for x in xs | |
tap = (o, fn) -> fn(o); o | |
console.log merge {foo: '1', bar: 'baz'}, {bar: 'bis'} , {wombat: 'fishpaste'} | |
### | |
{ foo: '1', bar: 'bis', wombat: 'fishpaste' } | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The version by @bogdan (23 Nov 2015) unfortunately doesn't compile for me. The original version works fine, though.