Skip to content

Instantly share code, notes, and snippets.

@RobinMalfait

RobinMalfait/Example.js

Last active Nov 15, 2017
Embed
What would you like to do?
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