Last active
November 15, 2017 19:01
-
-
Save RobinMalfait/f2140abbc64d3755db341ed921c31f98 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
const output = { | |
_: ["a", "b"], | |
foo: "bar", | |
baz: true | |
}; | |
const sgray = ({ _, ...input }) => | |
[ | |
..._, | |
...Object.keys(input).reduce((acc, key) => { | |
const value = input[key]; | |
return [...acc, value === true ? `--${key}` : `--${key}=${value}`]; | |
}, []) | |
].join(" "); | |
console.log(sgray(output)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment