This commit is contained in:
17
node_modules/chain-function/.gitattributes
generated
vendored
Normal file
17
node_modules/chain-function/.gitattributes
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
9
node_modules/chain-function/LICENSE.md
generated
vendored
Normal file
9
node_modules/chain-function/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jason Quense
|
||||
|
||||
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.
|
||||
25
node_modules/chain-function/README.md
generated
vendored
Normal file
25
node_modules/chain-function/README.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# chain-function
|
||||
chain a bunch of functions
|
||||
|
||||
```sh
|
||||
npm i chain-function
|
||||
```
|
||||
|
||||
```js
|
||||
function foo() {
|
||||
console.log('foo')
|
||||
}
|
||||
|
||||
function baz() {
|
||||
console.log('bar')
|
||||
}
|
||||
|
||||
var foobar = chain(foo, bar)
|
||||
|
||||
foobar() // "bar" "foo"
|
||||
|
||||
//handles empty values just fine
|
||||
foobar = chain(foo, null, bar, undefined)
|
||||
|
||||
foobar() // "bar" "foo"
|
||||
```
|
||||
20
node_modules/chain-function/index.js
generated
vendored
Normal file
20
node_modules/chain-function/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
module.exports = function chain(){
|
||||
var len = arguments.length
|
||||
var args = [];
|
||||
|
||||
for (var i = 0; i < len; i++)
|
||||
args[i] = arguments[i]
|
||||
|
||||
args = args.filter(function(fn){ return fn != null })
|
||||
|
||||
if (args.length === 0) return undefined
|
||||
if (args.length === 1) return args[0]
|
||||
|
||||
return args.reduce(function(current, next){
|
||||
return function chainedFunction() {
|
||||
current.apply(this, arguments);
|
||||
next.apply(this, arguments);
|
||||
};
|
||||
})
|
||||
}
|
||||
24
node_modules/chain-function/package.json
generated
vendored
Normal file
24
node_modules/chain-function/package.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "chain-function",
|
||||
"version": "1.0.1",
|
||||
"description": "chain a bunch of functions together into a single call",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node ./test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jquense/chain-function.git"
|
||||
},
|
||||
"keywords": [
|
||||
"chain",
|
||||
"compose",
|
||||
"function"
|
||||
],
|
||||
"author": "jquense",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jquense/chain-function/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jquense/chain-function#readme"
|
||||
}
|
||||
29
node_modules/chain-function/test.js
generated
vendored
Normal file
29
node_modules/chain-function/test.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
var assert = require('assert')
|
||||
var chain = require('./index')
|
||||
|
||||
console.log('testing...')
|
||||
|
||||
var count = 0;
|
||||
|
||||
chain(
|
||||
function(step){ count += step },
|
||||
function(step){ count += step },
|
||||
function(step){ count += step }
|
||||
)(1)
|
||||
|
||||
assert.equal(count, 3, 'should chain calls')
|
||||
|
||||
count = 0;
|
||||
|
||||
chain(
|
||||
function(step){ count += step },
|
||||
null, undefined,
|
||||
function(step){ count += step }
|
||||
)(1)
|
||||
|
||||
assert.equal(count, 2, 'should filter out null and undefined arguments')
|
||||
|
||||
var fn = function(){}
|
||||
assert.equal(chain(fn, null), fn, 'should return the only function argument')
|
||||
|
||||
console.log('done. tests pass!')
|
||||
Reference in New Issue
Block a user