diff options
| author | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
|---|---|---|
| committer | Shipwreckt <me@shipwreckt.co.uk> | 2025-10-31 20:02:14 +0000 |
| commit | 7a52ddeba2a68388b544f529d2d92104420f77b0 (patch) | |
| tree | 15ddd47457a2cb4a96060747437d36474e4f6b4e /node_modules/list-to-array | |
| parent | 53d6ae2b5568437afa5e4995580a3fb679b7b91b (diff) | |
Changed from static to 11ty!
Diffstat (limited to 'node_modules/list-to-array')
| -rw-r--r-- | node_modules/list-to-array/.npmignore | 27 | ||||
| -rw-r--r-- | node_modules/list-to-array/LICENSE | 22 | ||||
| -rw-r--r-- | node_modules/list-to-array/README.md | 52 | ||||
| -rw-r--r-- | node_modules/list-to-array/index.js | 18 | ||||
| -rw-r--r-- | node_modules/list-to-array/package.json | 32 | ||||
| -rw-r--r-- | node_modules/list-to-array/tests.js | 29 |
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([]); + }); +}); |
