Comparing version 1.0.0 to 1.0.1
25
index.js
@@ -1,26 +0,25 @@ | ||
var ChainGang = function (gang) { | ||
var next = function () { | ||
const chainz = (...gangs) => { | ||
let gang = []; | ||
const next = function (...args) { | ||
if(gang.length > 0) { | ||
gang.shift()(); | ||
gang.shift()(...args); | ||
} | ||
}; | ||
function Chain (func) { | ||
const Chain = func => { | ||
if(typeof func !== 'function') { | ||
console.warn('every element in array, must be a function'); | ||
console.warn('every argument must be a function'); | ||
func = next; | ||
} | ||
return function () { | ||
var args = Array.prototype.slice.call(arguments); | ||
return function (...args) { | ||
args.push(next); | ||
func.apply(null, args); | ||
// run next event loop | ||
setTimeout(func.bind(Object.create(null), ...args), 0); | ||
}; | ||
} | ||
}; | ||
var gang = gang.map(Chain); | ||
gang = gangs.map(Chain); | ||
next(); | ||
}; | ||
module.exports = ChainGang; | ||
module.exports = chainz; |
{ | ||
"name": "chainz", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Helps call an array of async functions in order, by injecting a next callback ", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/turbobeast/chainz.git" | ||
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "babel-node test/index.js | faucet" | ||
}, | ||
@@ -14,3 +18,8 @@ "keywords": [ | ||
"author": "George Michael Faust <georgemichaelfaust@gmail.com> (http://georgemichaelfaust.com/)", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-preset-es2015": "^6.3.13", | ||
"faucet": "0.0.1", | ||
"tape": "^4.4.0" | ||
} | ||
} |
## Chainz | ||
[![Build Status](https://travis-ci.org/turbobeast/chainz.svg)](https://travis-ci.org/turbobeast/chainz) | ||
Helps call an array of async functions in order, by injecting a next callback. | ||
```javascript | ||
var chain = require('chainz'); | ||
var ayncFunctionOne (next) { | ||
//do something asnyc | ||
next(); // calls asyncFunctionTwo | ||
const asyncFunctionOne = next => { | ||
// do something asnyc | ||
next('cheese'); // calls asyncFunctionTwo | ||
}; | ||
var asyncFunctionTwo (next) { | ||
//do something asnyc | ||
next(); //calls asyncFunctionThree | ||
const asyncFunctionTwo = (message, next) => { | ||
// do something asnyc | ||
console.log(message); // cheese | ||
next('peanut butter'); // calls asyncFunctionThree | ||
}; | ||
var asyncFunctionThree () { | ||
//done | ||
const asyncFunctionThree = message => { | ||
// done | ||
console.log(message); // peanut butter | ||
}; | ||
chain([asyncFunctionOne, asyncFunctionTwo, asyncFunctionThree]); | ||
chain(asyncFunctionOne, asyncFunctionTwo, asyncFunctionThree); | ||
``` |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
3591
8
43
1
29
0
3