-
-
Save dbani-dev/ef0872f5f58e4f046b5b516445e8632c to your computer and use it in GitHub Desktop.
Friendlier object definition
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
const define = (object, ...pairs) => | |
(Array.isArray(pairs[0]) ? pairs : [pairs]).reduce((accumulator, pair) => { | |
const [ key, value ] = pair; | |
return Object.defineProperty(accumulator, key, { value, enumerable: true }); | |
}, object); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment