Skip to content

Instantly share code, notes, and snippets.

@RobinMalfait
Last active November 15, 2017 19:01
Show Gist options
  • Save RobinMalfait/f2140abbc64d3755db341ed921c31f98 to your computer and use it in GitHub Desktop.
Save RobinMalfait/f2140abbc64d3755db341ed921c31f98 to your computer and use it in GitHub Desktop.
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