summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/qw
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/qw')
-rw-r--r--deps/npm/node_modules/qw/LICENSE13
-rw-r--r--deps/npm/node_modules/qw/README.md34
-rw-r--r--deps/npm/node_modules/qw/package.json60
-rw-r--r--deps/npm/node_modules/qw/qw.js43
4 files changed, 150 insertions, 0 deletions
diff --git a/deps/npm/node_modules/qw/LICENSE b/deps/npm/node_modules/qw/LICENSE
new file mode 100644
index 0000000000..74bf5afb71
--- /dev/null
+++ b/deps/npm/node_modules/qw/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2016, Rebecca Turner <me@re-becca.org>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/deps/npm/node_modules/qw/README.md b/deps/npm/node_modules/qw/README.md
new file mode 100644
index 0000000000..55ba17a91f
--- /dev/null
+++ b/deps/npm/node_modules/qw/README.md
@@ -0,0 +1,34 @@
+# qw
+
+Quoted word literals!
+
+```js
+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:
+
+```js
+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:
+
+```js
+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.
diff --git a/deps/npm/node_modules/qw/package.json b/deps/npm/node_modules/qw/package.json
new file mode 100644
index 0000000000..fb4c272f35
--- /dev/null
+++ b/deps/npm/node_modules/qw/package.json
@@ -0,0 +1,60 @@
+{
+ "_from": "qw",
+ "_id": "qw@1.0.1",
+ "_inBundle": false,
+ "_integrity": "sha1-77/cdA+a0FQwRCassYNBLMi5ltQ=",
+ "_location": "/qw",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "tag",
+ "registry": true,
+ "raw": "qw",
+ "name": "qw",
+ "escapedName": "qw",
+ "rawSpec": "",
+ "saveSpec": null,
+ "fetchSpec": "latest"
+ },
+ "_requiredBy": [
+ "#USER",
+ "/"
+ ],
+ "_resolved": "https://registry.npmjs.org/qw/-/qw-1.0.1.tgz",
+ "_shasum": "efbfdc740f9ad054304426acb183412cc8b996d4",
+ "_spec": "qw",
+ "_where": "/Users/rebecca/code/npm",
+ "author": {
+ "name": "Rebecca Turner",
+ "email": "me@re-becca.org",
+ "url": "http://re-becca.org/"
+ },
+ "bugs": {
+ "url": "https://github.com/iarna/node-qw/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {},
+ "deprecated": false,
+ "description": "Quoted word literals!",
+ "devDependencies": {
+ "tap": "^8.0.0"
+ },
+ "directories": {
+ "test": "test"
+ },
+ "files": [
+ "qw.js"
+ ],
+ "homepage": "https://github.com/iarna/node-qw#readme",
+ "keywords": [],
+ "license": "ISC",
+ "main": "qw.js",
+ "name": "qw",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/iarna/node-qw.git"
+ },
+ "scripts": {
+ "test": "tap test"
+ },
+ "version": "1.0.1"
+}
diff --git a/deps/npm/node_modules/qw/qw.js b/deps/npm/node_modules/qw/qw.js
new file mode 100644
index 0000000000..239e5a565e
--- /dev/null
+++ b/deps/npm/node_modules/qw/qw.js
@@ -0,0 +1,43 @@
+'use strict'
+module.exports = qw
+
+function appendLast (arr, str) {
+ var last = arr.length - 1
+ if (last < 0) {
+ arr.push(str)
+ } else {
+ var lastValue = String(arr[last])
+ return arr[last] = lastValue + String(str)
+ }
+}
+
+function qw () {
+ const args = Object.assign([], arguments[0])
+ const values = [].slice.call(arguments, 1)
+ const words = []
+ let lastWordWasValue = false
+ while (args.length) {
+ const arg = args.shift()
+ const concatValue = arg.length === 0 || arg.slice(-1) !== ' '
+ if (arg.trim() !== '') {
+ const theseWords = arg.replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ').split(/ /)
+ if (lastWordWasValue && arg[0] !== ' ') {
+ appendLast(words, theseWords.shift())
+ }
+ words.push.apply(words, theseWords)
+ }
+
+ if (values.length) {
+ const val = values.shift()
+ if (concatValue) {
+ appendLast(words, val)
+ } else {
+ words.push(val)
+ }
+ lastWordWasValue = true
+ } else {
+ lastWordWasValue = false
+ }
+ }
+ return words
+}