Last active
June 30, 2017 11:13
-
-
Save Prajjwal/67834eb66d8b3971bfaccdaa73da3ed1 to your computer and use it in GitHub Desktop.
Helper to mimic the ES7 spread operation on Objects
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
// Or any object that yields a set of { key: value } pairs. | |
const x = { | |
* [Symbol.iterator] () { | |
yield { done: false, value: { dog: 'cat' } } | |
yield { done: false, value: { dawg: 'cayt' } } | |
} | |
} | |
function ES7ObjectAssign (target, source) { | |
for (const sourceObject of source) { | |
Object.assign (target, sourceObject.value) | |
} | |
return target | |
} | |
console.log (ES7ObjectAssign ({ }, x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment