Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

async-for-each

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-for-each

Asynchronous array iteration

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

async-for-each

Asynchronous array iteration

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.

Installation

npm install --save async-for-each

Usage

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!");
});

API

Functions

asyncForEach(array, iterator, callback)

Iterates over an array asynchronously.

Typedefs

iteratorCallback : function

The asyncForEach iterator callback.

finalCallback : function

The asyncForEach final callback.

asyncForEach(array, iterator, callback)

Iterates over an array asynchronously.

Kind: global function

ParamTypeDescription
arrayArrayThe array over which to iterate.
iteratoriteratorCallbackThe iterator function. Called with the signature iterator(value, index, next), where value is the current array value, index is the current index, and next is a function to be called when the next iteration should occur.

IMPORTANT: if next() is never called in the iterator function, the iteration will never complete.
callbackfinalCallbackThe callback function. Called with the signature callback(error) when the iteration is complete.

iteratorCallback : function

The asyncForEach iterator callback.

Kind: global typedef

ParamTypeDescription
value*The value currently being iterated over.
indexnumberThe index currently being iterated over
nextfunctionCalled to indicate that the current iteration is over.

finalCallback : function

The asyncForEach final callback.

Kind: global typedef

ParamTypeDescription
errorErrorError that was raised during iteration, if any.

Keywords

async

FAQs

Package last updated on 30 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts