Distopico Vegan 9e639edc8d | 6 years ago | |
---|---|---|
.. | ||
LICENSE | 6 years ago | |
README.md | 6 years ago | |
package.json | 6 years ago | |
qw.js | 6 years ago |
Quoted word literals!
const qw = require('qw')
const myword = qw` this is
a long list
of words`
// equiv of:
const myword = [ 'this', 'is', 'a', 'long', 'list', 'of', 'words' ]
You can embed vars in the usual way:
const mywords = qw`product ${23 * 5} also ${'escaping a string'}`
// equiv of:
const mywords = [ 'product', 23 * 5, 'also', 'escaping a string' ]
You can also embed vars inside strings:
const mywords = qw`product=${23 * 5} also "${'escaping a string'}"`
// equiv of:
const mywords = [ 'product=' + (23 * 5), 'also', '"escaping a string"' ]
This uses template strings to bring over this little common convenience from Perl-land.