Skip to content

Instantly share code, notes, and snippets.

@fxg42
Last active February 13, 2017 03:03
Show Gist options
  • Save fxg42/eb2f9ab4e18a09242095f2c1c5b43784 to your computer and use it in GitHub Desktop.
Save fxg42/eb2f9ab4e18a09242095f2c1c5b43784 to your computer and use it in GitHub Desktop.
Useless tag function...
//
// Splits a string containing words separated by spaces into a list of those
// words. The function should be used as a tag i.e.
//
// w`foo bar ${'b' + 'az'}` => [ 'foo', 'bar', 'baz' ]
//
export const w = (templateObj, ...substitutions) => String.raw({ raw: templateObj }, ...substitutions).trim().split(/\W+/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment