Galerie und tage
This commit is contained in:
46
node_modules/each-async/index.js
generated
vendored
Normal file
46
node_modules/each-async/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
var onetime = require('onetime');
|
||||
var setImmediateShim = require('set-immediate-shim');
|
||||
|
||||
module.exports = function (arr, next, cb) {
|
||||
var failed = false;
|
||||
var count = 0;
|
||||
|
||||
cb = cb || function () {};
|
||||
|
||||
if (!Array.isArray(arr)) {
|
||||
throw new TypeError('First argument must be an array');
|
||||
}
|
||||
|
||||
if (typeof next !== 'function') {
|
||||
throw new TypeError('Second argument must be a function');
|
||||
}
|
||||
|
||||
var len = arr.length;
|
||||
|
||||
if (!len) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
function callback(err) {
|
||||
if (failed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (err !== undefined && err !== null) {
|
||||
failed = true;
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (++count === len) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
setImmediateShim(next, arr[i], i, onetime(callback, true));
|
||||
}
|
||||
};
|
||||
21
node_modules/each-async/license
generated
vendored
Normal file
21
node_modules/each-async/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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/each-async/package.json
generated
vendored
Normal file
42
node_modules/each-async/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "each-async",
|
||||
"version": "1.1.1",
|
||||
"description": "Async concurrent iterator (async forEach)",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/each-async",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --timeout 20000"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"each",
|
||||
"async",
|
||||
"asynchronous",
|
||||
"iteration",
|
||||
"iterate",
|
||||
"loop",
|
||||
"foreach",
|
||||
"parallel",
|
||||
"concurrent",
|
||||
"array",
|
||||
"flow",
|
||||
"control flow"
|
||||
],
|
||||
"dependencies": {
|
||||
"onetime": "^1.0.0",
|
||||
"set-immediate-shim": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
}
|
||||
}
|
||||
62
node_modules/each-async/readme.md
generated
vendored
Normal file
62
node_modules/each-async/readme.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# each-async [](https://travis-ci.org/sindresorhus/each-async)
|
||||
|
||||
> Async concurrent iterator (async forEach)
|
||||
|
||||
Like [async.each()](https://github.com/caolan/async#eacharr-iterator-callback), but tiny.
|
||||
|
||||
I often use `async.each()` for doing async operations when iterating, but I almost never use the other gadzillion methods in `async`.
|
||||
|
||||
Async iteration is one of the most used async control flow patterns.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save each-async
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var eachAsync = require('each-async');
|
||||
|
||||
eachAsync(['foo','bar','baz'], function (item, index, done) {
|
||||
console.log(item, index);
|
||||
done();
|
||||
}, function (error) {
|
||||
console.log('finished');
|
||||
});
|
||||
//=> foo 0
|
||||
//=> bar 1
|
||||
//=> baz 2
|
||||
//=> finished
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### eachAsync(array, callback, finishedCallback)
|
||||
|
||||
#### array
|
||||
|
||||
The array you want to iterate.
|
||||
|
||||
#### callback(item, index, done)
|
||||
|
||||
A function which is called for each item in the array with the following arguments:
|
||||
|
||||
- `item`: the current item in the array
|
||||
- `index`: the current index
|
||||
- `done([error])`: call this when you're done with an optional error. Supplying anything other than `undefined`/`null` will stop the iteration.
|
||||
|
||||
Note that order is not guaranteed since each item is handled concurrently.
|
||||
|
||||
#### finishedCallback(error)
|
||||
|
||||
A function which is called when the iteration is finished or on the first error. First argument is the error passed from `done()` in the `callback`.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Reference in New Issue
Block a user