Skip to content

iarna/node-qw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qw

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"' ]

DESCRIPTION

This uses template strings to bring over this little common convenience from Perl-land.

About

Quoted word literals! For Node.js!

Resources

License

Stars

Watchers

Forks

Packages

No packages published