summaryrefslogtreecommitdiff
path: root/node_modules/list-to-array
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/list-to-array')
-rw-r--r--node_modules/list-to-array/.npmignore27
-rw-r--r--node_modules/list-to-array/LICENSE22
-rw-r--r--node_modules/list-to-array/README.md52
-rw-r--r--node_modules/list-to-array/index.js18
-rw-r--r--node_modules/list-to-array/package.json32
-rw-r--r--node_modules/list-to-array/tests.js29
6 files changed, 180 insertions, 0 deletions
diff --git a/node_modules/list-to-array/.npmignore b/node_modules/list-to-array/.npmignore
new file mode 100644
index 0000000..123ae94
--- /dev/null
+++ b/node_modules/list-to-array/.npmignore
@@ -0,0 +1,27 @@
+# Logs
+logs
+*.log
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
+node_modules
diff --git a/node_modules/list-to-array/LICENSE b/node_modules/list-to-array/LICENSE
new file mode 100644
index 0000000..b9d8498
--- /dev/null
+++ b/node_modules/list-to-array/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Jed Watson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/node_modules/list-to-array/README.md b/node_modules/list-to-array/README.md
new file mode 100644
index 0000000..2fec249
--- /dev/null
+++ b/node_modules/list-to-array/README.md
@@ -0,0 +1,52 @@
+# list-to-array
+
+Simple javascript lib for converting a [comma || space] delimited string to an array.
+
+Trims values so you can use human-friendly lists like `'one, two, three' => ['one','two','three']`
+
+If in array is provided, it is simply returned. If a falsy or non-string value is provided, an empty array is returned.
+
+Won't work with values that contain spaces.
+
+## Installation
+
+```
+npm install list-to-array
+```
+
+Works in node.js, iojs or bundle for the browser with browserify or webpack.
+
+## Usage
+
+```
+var listToArray = require('list-to-array');
+
+console.log(listToArray('one, two, three'));
+
+// logs ['one','two','three']
+```
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2015 Jed Watson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/list-to-array/index.js b/node_modules/list-to-array/index.js
new file mode 100644
index 0000000..78efcf9
--- /dev/null
+++ b/node_modules/list-to-array/index.js
@@ -0,0 +1,18 @@
+function truthy(val) { return val; }
+function trim(str) { return str.trim(); }
+
+function listToArray (str, delimiter) {
+ if (Array.isArray(str)) {
+ return str;
+ }
+ if (!str || typeof str !== 'string') {
+ return [];
+ }
+ if (!delimiter) {
+ delimiter = ' ';
+ str = str.replace(/\,/g, ' ');
+ }
+ return str.split(delimiter).map(trim).filter(truthy);
+}
+
+module.exports = listToArray;
diff --git a/node_modules/list-to-array/package.json b/node_modules/list-to-array/package.json
new file mode 100644
index 0000000..a6b8ed0
--- /dev/null
+++ b/node_modules/list-to-array/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "list-to-array",
+ "version": "1.1.0",
+ "description": "Simple javascript lib for converting a [comma || space] delimited string to an array",
+ "main": "index.js",
+ "author": "Jed Watson",
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/JedWatson/list-to-array.git"
+ },
+ "bugs": {
+ "url": "https://github.com/JedWatson/list-to-array/issues"
+ },
+ "homepage": "https://github.com/JedWatson/list-to-array",
+ "scripts": {
+ "test": "mocha tests.js"
+ },
+ "keywords": [
+ "array",
+ "list",
+ "string",
+ "manipulation",
+ "conversion",
+ "function",
+ "library"
+ ],
+ "devDependencies": {
+ "mocha": "^2.2.5",
+ "must": "^0.12.0"
+ }
+}
diff --git a/node_modules/list-to-array/tests.js b/node_modules/list-to-array/tests.js
new file mode 100644
index 0000000..456d275
--- /dev/null
+++ b/node_modules/list-to-array/tests.js
@@ -0,0 +1,29 @@
+var demand = require('must');
+var listToArray = require('./index');
+
+describe('listToArray', function() {
+ it('splits a comma-delimited list into an array', function() {
+ listToArray('one,two,three').must.eql(['one', 'two', 'three']);
+ });
+ it('splits a space-delimited list into an array', function() {
+ listToArray('one two three').must.eql(['one', 'two', 'three']);
+ });
+ it('trims whitespace from values', function() {
+ listToArray('one, two, three').must.eql(['one', 'two', 'three']);
+ });
+ it('splits a list into an array', function() {
+ listToArray('one,two,three').must.eql(['one', 'two', 'three']);
+ });
+ it('returns a empty array w/ no arguments', function() {
+ listToArray().must.eql([]);
+ });
+ it('returns a empty array for a blank string', function() {
+ listToArray('').must.eql([]);
+ });
+ it('returns a empty array when only given whitespace', function() {
+ listToArray(' ').must.eql([]);
+ });
+ it('returns a empty array when only given whitespace and commas', function() {
+ listToArray(' , ').must.eql([]);
+ });
+});