This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

37
node_modules/traverse-chain/README.md generated vendored Normal file
View File

@ -0,0 +1,37 @@
# traverse-chain
A simple asynchronous tool
## Installation
```bash
$ npm install traverse-chain
```
## Example
```javascript
var Chain = require('traverse-chain');
var chain = new Chain();
chain.add(
function() {
setTimeout(function() {
chain.next();
}, 2000);
},
functin() {
setTimeout(function() {
chain.next();
}, 1000);
}
)
chain.traverse(function() {
// done
});
```
## License
MIT

102
node_modules/traverse-chain/index.js generated vendored Normal file
View File

@ -0,0 +1,102 @@
/**
* Simple asynchronous tool for saving my life.
*/
/**
* A wrapper function create a `Chain` instance at the same
* time initializes the `queue` with a serial of arguments.
*/
module.exports = function() {
var s = new Chain();
return s.__init.apply(s, arguments);
}
/**
* Chain constructor.
* @api pivate
*/
function Chain() {
this.queue = [];
this.onend = function(err) {};
this.pass = true;
}
/**
* Trying to Initialize the `queue` with a serial of arguments.
*
* @api private
*/
Chain.prototype.__init = function() {
this.queue = [].slice.call(arguments);
return this;
}
/**
* Add a `job` or an array of `jobs` into the Chain.
* A `job` is defined by a function.
*
* @param {Function|Array} a function or an array of functions
* @return {Chain}
* @api public
*/
Chain.prototype.add = function() {
var jobs = [].slice.call(arguments);
jobs.forEach(
(function(job) {
this.queue.push.apply(
this.queue, Array.isArray(job) ? job : [job]
);
}).bind(this)
);
return this;
}
/**
* The iterator of the Chain. When it reaches end then call
* call the callback function.
*
* @return {Chain}
* @api public
*/
Chain.prototype.next = function() {
if (!this.pass) return this;
if (this.queue.length) {
this.queue.shift().call();
} else {
this.onend();
}
return this;
}
/**
* Terminate the chain.
*
* @return {Chain}
* @api public
*/
Chain.prototype.stop = function() {
this.pass = false;
this.onend.apply(this, arguments);
return this;
}
/**
* Start iterating through the Chain and ends with the
* given callback.
*
* @param {Function} end callback
* @return {Chain}
* @api public
*/
Chain.prototype.traverse = function(fn) {
fn && fn.call && fn.apply && (this.onend = fn);
this.next();
return this;
}

54
node_modules/traverse-chain/package.json generated vendored Normal file
View File

@ -0,0 +1,54 @@
{
"_args": [
[
"traverse-chain@0.1.0",
"/Users/tatiana/selfdefined"
]
],
"_from": "traverse-chain@0.1.0",
"_id": "traverse-chain@0.1.0",
"_inBundle": false,
"_integrity": "sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE=",
"_location": "/traverse-chain",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "traverse-chain@0.1.0",
"name": "traverse-chain",
"escapedName": "traverse-chain",
"rawSpec": "0.1.0",
"saveSpec": null,
"fetchSpec": "0.1.0"
},
"_requiredBy": [
"/find"
],
"_resolved": "https://registry.npmjs.org/traverse-chain/-/traverse-chain-0.1.0.tgz",
"_spec": "0.1.0",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "yuanchuan"
},
"bugs": {
"url": "https://github.com/yuanchuan/traverse-chain/issues"
},
"description": "A simple asynchronous tool",
"homepage": "https://github.com/yuanchuan/traverse-chain#readme",
"keywords": [
"async",
"chain",
"queue"
],
"license": "MIT",
"main": "index.js",
"name": "traverse-chain",
"repository": {
"type": "git",
"url": "git+https://github.com/yuanchuan/traverse-chain.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "0.1.0"
}