change approach again
This commit is contained in:
2
node_modules/find-replace/.npmignore
generated
vendored
Normal file
2
node_modules/find-replace/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
tmp
|
||||
out
|
6
node_modules/find-replace/.travis.yml
generated
vendored
Normal file
6
node_modules/find-replace/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 7
|
||||
- 6
|
||||
- 5
|
||||
- 4
|
21
node_modules/find-replace/LICENSE
generated
vendored
Normal file
21
node_modules/find-replace/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-17 Lloyd Brookes <75pound@gmail.com>
|
||||
|
||||
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.
|
42
node_modules/find-replace/README.md
generated
vendored
Normal file
42
node_modules/find-replace/README.md
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
[](https://www.npmjs.org/package/find-replace)
|
||||
[](https://www.npmjs.org/package/find-replace)
|
||||
[](https://travis-ci.org/75lb/find-replace)
|
||||
[](https://david-dm.org/75lb/find-replace)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
<a name="module_find-replace"></a>
|
||||
|
||||
## find-replace
|
||||
Find and either replace or remove items from an array.
|
||||
|
||||
**Example**
|
||||
```js
|
||||
> findReplace = require('find-replace')
|
||||
|
||||
> findReplace([ 1, 2, 3], 2, 'two')
|
||||
[ 1, 'two', 3 ]
|
||||
|
||||
> findReplace([ 1, 2, 3], 2, [ 'two', 'zwei' ])
|
||||
[ 1, [ 'two', 'zwei' ], 3 ]
|
||||
|
||||
> findReplace([ 1, 2, 3], 2, 'two', 'zwei')
|
||||
[ 1, 'two', 'zwei', 3 ]
|
||||
|
||||
> findReplace([ 1, 2, 3], 2) // no replacement, so remove
|
||||
[ 1, 3 ]
|
||||
```
|
||||
<a name="exp_module_find-replace--findReplace"></a>
|
||||
|
||||
### findReplace(array, valueTest, [...replaceWith]) ⇒ <code>array</code> ⏏
|
||||
**Kind**: Exported function
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| array | <code>array</code> | the input array |
|
||||
| valueTest | <code>valueTest</code> | a [test-value](https://github.com/75lb/test-value) query to match the value you're looking for |
|
||||
| [...replaceWith] | <code>any</code> | If specified, found values will be replaced with these values, else removed. |
|
||||
|
||||
|
||||
* * *
|
||||
|
||||
© 2015-17 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
|
11
node_modules/find-replace/jsdoc2md/README.hbs
generated
vendored
Normal file
11
node_modules/find-replace/jsdoc2md/README.hbs
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
[](https://www.npmjs.org/package/find-replace)
|
||||
[](https://www.npmjs.org/package/find-replace)
|
||||
[](https://travis-ci.org/75lb/find-replace)
|
||||
[](https://david-dm.org/75lb/find-replace)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
{{>main}}
|
||||
|
||||
* * *
|
||||
|
||||
© 2015-17 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
|
62
node_modules/find-replace/lib/find-replace.js
generated
vendored
Normal file
62
node_modules/find-replace/lib/find-replace.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict'
|
||||
var arrayify = require('array-back')
|
||||
var testValue = require('test-value')
|
||||
|
||||
/**
|
||||
* Find and either replace or remove items from an array.
|
||||
*
|
||||
* @module find-replace
|
||||
* @example
|
||||
* > findReplace = require('find-replace')
|
||||
*
|
||||
* > findReplace([ 1, 2, 3], 2, 'two')
|
||||
* [ 1, 'two', 3 ]
|
||||
*
|
||||
* > findReplace([ 1, 2, 3], 2, [ 'two', 'zwei' ])
|
||||
* [ 1, [ 'two', 'zwei' ], 3 ]
|
||||
*
|
||||
* > findReplace([ 1, 2, 3], 2, 'two', 'zwei')
|
||||
* [ 1, 'two', 'zwei', 3 ]
|
||||
*
|
||||
* > findReplace([ 1, 2, 3], 2) // no replacement, so remove
|
||||
* [ 1, 3 ]
|
||||
*/
|
||||
module.exports = findReplace
|
||||
|
||||
/**
|
||||
* @param {array} - the input array
|
||||
* @param {valueTest} - a [test-value](https://github.com/75lb/test-value) query to match the value you're looking for
|
||||
* @param [replaceWith] {...any} - If specified, found values will be replaced with these values, else removed.
|
||||
* @returns {array}
|
||||
* @alias module:find-replace
|
||||
*/
|
||||
function findReplace (array, valueTest) {
|
||||
var found = []
|
||||
var replaceWiths = arrayify(arguments)
|
||||
replaceWiths.splice(0, 2)
|
||||
|
||||
arrayify(array).forEach(function (value, index) {
|
||||
var expanded = []
|
||||
replaceWiths.forEach(function (replaceWith) {
|
||||
if (typeof replaceWith === 'function') {
|
||||
expanded = expanded.concat(replaceWith(value))
|
||||
} else {
|
||||
expanded.push(replaceWith)
|
||||
}
|
||||
})
|
||||
|
||||
if (testValue(value, valueTest)) {
|
||||
found.push({
|
||||
index: index,
|
||||
replaceWithValue: expanded
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
found.reverse().forEach(function (item) {
|
||||
var spliceArgs = [ item.index, 1 ].concat(item.replaceWithValue)
|
||||
array.splice.apply(array, spliceArgs)
|
||||
})
|
||||
|
||||
return array
|
||||
}
|
2
node_modules/find-replace/node_modules/array-back/.npmignore
generated
vendored
Normal file
2
node_modules/find-replace/node_modules/array-back/.npmignore
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
tmp
|
||||
out
|
8
node_modules/find-replace/node_modules/array-back/.travis.yml
generated
vendored
Normal file
8
node_modules/find-replace/node_modules/array-back/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 7
|
||||
- 6
|
||||
- 5
|
||||
- 4
|
||||
- iojs
|
||||
- 0.12
|
21
node_modules/find-replace/node_modules/array-back/LICENSE
generated
vendored
Normal file
21
node_modules/find-replace/node_modules/array-back/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-16 Lloyd Brookes <75pound@gmail.com>
|
||||
|
||||
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.
|
51
node_modules/find-replace/node_modules/array-back/README.md
generated
vendored
Normal file
51
node_modules/find-replace/node_modules/array-back/README.md
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
[](https://www.npmjs.org/package/array-back)
|
||||
[](https://www.npmjs.org/package/array-back)
|
||||
[](https://travis-ci.org/75lb/array-back)
|
||||
[](https://david-dm.org/75lb/array-back)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
<a name="module_array-back"></a>
|
||||
|
||||
## array-back
|
||||
**Example**
|
||||
```js
|
||||
var arrayify = require("array-back")
|
||||
```
|
||||
<a name="exp_module_array-back--arrayify"></a>
|
||||
|
||||
### arrayify(input) ⇒ <code>Array</code> ⏏
|
||||
Takes any input and guarantees an array back.
|
||||
|
||||
- converts array-like objects (e.g. `arguments`) to a real array
|
||||
- converts `undefined` to an empty array
|
||||
- converts any another other, singular value (including `null`) into an array containing that value
|
||||
- ignores input which is already an array
|
||||
|
||||
**Kind**: Exported function
|
||||
|
||||
| Param | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| input | <code>\*</code> | the input value to convert to an array |
|
||||
|
||||
**Example**
|
||||
```js
|
||||
> a.arrayify(undefined)
|
||||
[]
|
||||
|
||||
> a.arrayify(null)
|
||||
[ null ]
|
||||
|
||||
> a.arrayify(0)
|
||||
[ 0 ]
|
||||
|
||||
> a.arrayify([ 1, 2 ])
|
||||
[ 1, 2 ]
|
||||
|
||||
> function f(){ return a.arrayify(arguments); }
|
||||
> f(1,2,3)
|
||||
[ 1, 2, 3 ]
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
© 2015-16 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
|
11
node_modules/find-replace/node_modules/array-back/jsdoc2md/README.hbs
generated
vendored
Normal file
11
node_modules/find-replace/node_modules/array-back/jsdoc2md/README.hbs
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
[](https://www.npmjs.org/package/array-back)
|
||||
[](https://www.npmjs.org/package/array-back)
|
||||
[](https://travis-ci.org/75lb/array-back)
|
||||
[](https://david-dm.org/75lb/array-back)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
{{>main}}
|
||||
|
||||
* * *
|
||||
|
||||
© 2015-16 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).
|
47
node_modules/find-replace/node_modules/array-back/lib/array-back.js
generated
vendored
Normal file
47
node_modules/find-replace/node_modules/array-back/lib/array-back.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
'use strict'
|
||||
var t = require('typical')
|
||||
|
||||
/**
|
||||
* @module array-back
|
||||
* @example
|
||||
* var arrayify = require("array-back")
|
||||
*/
|
||||
module.exports = arrayify
|
||||
|
||||
/**
|
||||
* Takes any input and guarantees an array back.
|
||||
*
|
||||
* - converts array-like objects (e.g. `arguments`) to a real array
|
||||
* - converts `undefined` to an empty array
|
||||
* - converts any another other, singular value (including `null`) into an array containing that value
|
||||
* - ignores input which is already an array
|
||||
*
|
||||
* @param {*} - the input value to convert to an array
|
||||
* @returns {Array}
|
||||
* @alias module:array-back
|
||||
* @example
|
||||
* > a.arrayify(undefined)
|
||||
* []
|
||||
*
|
||||
* > a.arrayify(null)
|
||||
* [ null ]
|
||||
*
|
||||
* > a.arrayify(0)
|
||||
* [ 0 ]
|
||||
*
|
||||
* > a.arrayify([ 1, 2 ])
|
||||
* [ 1, 2 ]
|
||||
*
|
||||
* > function f(){ return a.arrayify(arguments); }
|
||||
* > f(1,2,3)
|
||||
* [ 1, 2, 3 ]
|
||||
*/
|
||||
function arrayify (input) {
|
||||
if (input === undefined) {
|
||||
return []
|
||||
} else if (t.isArrayLike(input)) {
|
||||
return Array.prototype.slice.call(input)
|
||||
} else {
|
||||
return Array.isArray(input) ? input : [ input ]
|
||||
}
|
||||
}
|
66
node_modules/find-replace/node_modules/array-back/package.json
generated
vendored
Normal file
66
node_modules/find-replace/node_modules/array-back/package.json
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "array-back@^1.0.4",
|
||||
"_id": "array-back@1.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=",
|
||||
"_location": "/find-replace/array-back",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "array-back@^1.0.4",
|
||||
"name": "array-back",
|
||||
"escapedName": "array-back",
|
||||
"rawSpec": "^1.0.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/find-replace"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz",
|
||||
"_shasum": "644ba7f095f7ffcf7c43b5f0dc39d3c1f03c063b",
|
||||
"_spec": "array-back@^1.0.4",
|
||||
"_where": "/home/wn/workspace-node/homepage/node_modules/find-replace",
|
||||
"author": {
|
||||
"name": "Lloyd Brookes",
|
||||
"email": "75pound@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/75lb/array-back/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"typical": "^2.6.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Guarantees an array back",
|
||||
"devDependencies": {
|
||||
"core-assert": "^0.2.1",
|
||||
"jsdoc-to-markdown": "^2.0.1",
|
||||
"test-runner": "^0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12.0"
|
||||
},
|
||||
"homepage": "https://github.com/75lb/array-back#readme",
|
||||
"keywords": [
|
||||
"to",
|
||||
"convert",
|
||||
"return",
|
||||
"array",
|
||||
"arrayify"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/array-back.js",
|
||||
"name": "array-back",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/75lb/array-back.git"
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo",
|
||||
"test": "test-runner test/*.js"
|
||||
},
|
||||
"version": "1.0.4"
|
||||
}
|
18
node_modules/find-replace/node_modules/array-back/test/test.js
generated
vendored
Normal file
18
node_modules/find-replace/node_modules/array-back/test/test.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
var TestRunner = require('test-runner')
|
||||
var arrayify = require('../')
|
||||
var a = require('core-assert')
|
||||
|
||||
var runner = new TestRunner()
|
||||
|
||||
runner.test('arrayify()', function () {
|
||||
a.deepStrictEqual(arrayify(undefined), [])
|
||||
a.deepStrictEqual(arrayify(null), [ null ])
|
||||
a.deepStrictEqual(arrayify(0), [ 0 ])
|
||||
a.deepStrictEqual(arrayify([ 1, 2 ]), [ 1, 2 ])
|
||||
|
||||
function func () {
|
||||
a.deepStrictEqual(arrayify(arguments), [ 1, 2, 3 ])
|
||||
}
|
||||
func(1, 2, 3)
|
||||
})
|
68
node_modules/find-replace/package.json
generated
vendored
Normal file
68
node_modules/find-replace/package.json
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"_from": "find-replace@^1.0.3",
|
||||
"_id": "find-replace@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-uI5zZNLZyVlVnziMZmcNYTBEH6A=",
|
||||
"_location": "/find-replace",
|
||||
"_phantomChildren": {
|
||||
"typical": "2.6.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "find-replace@^1.0.3",
|
||||
"name": "find-replace",
|
||||
"escapedName": "find-replace",
|
||||
"rawSpec": "^1.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/command-line-args"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/find-replace/-/find-replace-1.0.3.tgz",
|
||||
"_shasum": "b88e7364d2d9c959559f388c66670d6130441fa0",
|
||||
"_spec": "find-replace@^1.0.3",
|
||||
"_where": "/home/wn/workspace-node/homepage/node_modules/command-line-args",
|
||||
"author": {
|
||||
"name": "Lloyd Brookes",
|
||||
"email": "75pound@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/75lb/find-replace/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"array-back": "^1.0.4",
|
||||
"test-value": "^2.1.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Find and either replace or remove items from an array",
|
||||
"devDependencies": {
|
||||
"jsdoc-to-markdown": "^2.0.1",
|
||||
"test-runner": "^0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/75lb/find-replace#readme",
|
||||
"keywords": [
|
||||
"find",
|
||||
"replace",
|
||||
"array",
|
||||
"remove",
|
||||
"splice"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/find-replace.js",
|
||||
"name": "find-replace",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/75lb/find-replace.git"
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo",
|
||||
"test": "test-runner test/*.js"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
50
node_modules/find-replace/test/test.js
generated
vendored
Normal file
50
node_modules/find-replace/test/test.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
const TestRunner = require('test-runner')
|
||||
const findReplace = require('../')
|
||||
const a = require('assert')
|
||||
|
||||
const runner = new TestRunner()
|
||||
|
||||
function fixture () {
|
||||
return [ 1, 2, 3, 4, 2 ]
|
||||
}
|
||||
function argv () {
|
||||
return [ '--one', '1', '-abc', 'three' ]
|
||||
}
|
||||
|
||||
runner.test('find primitive, replace with primitive', function (t) {
|
||||
a.deepStrictEqual(
|
||||
findReplace(fixture(), 2, 'two'),
|
||||
[ 1, 'two', 3, 4, 'two' ]
|
||||
)
|
||||
})
|
||||
|
||||
runner.test('find primitive, replace with array', function (t) {
|
||||
a.deepStrictEqual(
|
||||
findReplace(fixture(), 2, [ 'two', 'zwei' ]),
|
||||
[ 1, [ 'two', 'zwei' ], 3, 4, [ 'two', 'zwei' ] ]
|
||||
)
|
||||
})
|
||||
|
||||
runner.test('find primitive, replace with several primitives', function (t) {
|
||||
a.deepStrictEqual(
|
||||
findReplace(fixture(), 2, 'two', 'zwei'),
|
||||
[ 1, 'two', 'zwei', 3, 4, 'two', 'zwei' ]
|
||||
)
|
||||
})
|
||||
|
||||
runner.test('getopt example', function (t) {
|
||||
a.deepStrictEqual(
|
||||
findReplace(argv(), /^-(\w{2,})$/, function (match) {
|
||||
return [ '-a', '-b', '-c' ]
|
||||
}),
|
||||
[ '--one', '1', '-a', '-b', '-c', 'three' ]
|
||||
)
|
||||
})
|
||||
|
||||
runner.test('getopt example 2', function (t) {
|
||||
a.deepStrictEqual(
|
||||
findReplace(argv(), /^-(\w{2,})$/, 'bread', 'milk'),
|
||||
[ '--one', '1', 'bread', 'milk', 'three' ]
|
||||
)
|
||||
})
|
Reference in New Issue
Block a user