Comparing version 0.1.1 to 0.1.2
/*! | ||
each-async | ||
Async parallel iterator | ||
Async concurrent iterator (async forEach) | ||
https://github.com/sindresorhus/each-async | ||
@@ -30,4 +30,2 @@ by Sindre Sorhus | ||
var count = 0; | ||
var i = 0; | ||
var l = arr.length; | ||
@@ -44,3 +42,5 @@ cb = cb || function () {}; | ||
if (!arr.length) { | ||
var len = arr.length; | ||
if (!len) { | ||
return cb(); | ||
@@ -59,3 +59,3 @@ } | ||
if (++count === l) { | ||
if (++count === len) { | ||
return cb(); | ||
@@ -65,3 +65,3 @@ } | ||
for (; i < l; i++) { | ||
for (var i = 0; i < len; i++) { | ||
next(arr[i], i, once(callback)); | ||
@@ -68,0 +68,0 @@ } |
{ | ||
"name": "each-async", | ||
"version": "0.1.1", | ||
"description": "Async parallel iterator", | ||
"version": "0.1.2", | ||
"description": "Async concurrent iterator", | ||
"license": "MIT", | ||
@@ -14,3 +14,3 @@ "main": "each-async.js", | ||
"engines": { | ||
"node": ">=0.8.0" | ||
"node": ">=0.10.0" | ||
}, | ||
@@ -38,4 +38,4 @@ "scripts": { | ||
"devDependencies": { | ||
"mocha": "~1.14.0" | ||
"mocha": "*" | ||
} | ||
} |
# each-async [![Build Status](https://secure.travis-ci.org/sindresorhus/each-async.png?branch=master)](http://travis-ci.org/sindresorhus/each-async) | ||
> Async parallel iterator | ||
> Async concurrent iterator (async forEach) | ||
Like [async.each](https://github.com/caolan/async#eacharr-iterator-callback), but smaller. | ||
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 | ||
@@ -36,4 +40,2 @@ | ||
```js | ||
var eachAsync = require('each-async'); | ||
eachAsync(['foo','bar','baz'], function (item, index, done) { | ||
@@ -51,22 +53,3 @@ console.log(item, index); | ||
### Bower | ||
```html | ||
<script src="bower_components/each-async/each-async.js"></script> | ||
``` | ||
```js | ||
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 | ||
@@ -88,3 +71,3 @@ | ||
Note that order is not guaranteed since each item is handled in parallel. | ||
Note that order is not guaranteed since each item is handled concurrently. | ||
@@ -91,0 +74,0 @@ #### finishedCallback(error) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3733
58
79