async-for-each
Version:
Asynchronous array iteration
28 lines (22 loc) • 695 B
Markdown
async-for-each` exposes a function to iterate over an array asynchronously. This is useful
for iteration that must occur in an asynchronous context, or for iterating over long arrays
without blocking the event loop.
npm install --save async-for-each
```javascript
const asyncForEach = require("async-for-each");
const arr = [1, 2, 3, 4, 5];
asyncForEach(arr, function(value, index, next) {
console.log("The value at %s is %s", index, value);
doSomethingAsyncWithValue(value, function() {
next();
});
}, function() {
console.log("Iteration complete!");
});
```
`