async-each
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Async-each is an ultra-simple, no-nonsense JavaScript library that implements an asynchronous parallel forEach function. It is super lightweight, with a codebase of only around 40 lines. This makes it an excellent alternative to bulkier async libraries that can sometimes be overkill for simpler tasks. Its primary use cases would be in situations where you need to perform the same operation on multiple items in parallel and asynchronously, such as reading multiple files at once or making multiple API requests. The package is compatible for use with both browsers and Node.js environments.
To get started using async-each in your projects, first install the package via NPM using the command npm install async-each
. Once installed, you can import it into your JavaScript file using the require
function.
Here's a simple usage example:
var each = require('async-each');
each(['a.js', 'b.js', 'c.js'], fs.readFile, function(error, contents) {
if (error) console.error(error);
console.log('Contents for a, b and c:', contents);
});
In the above code, async-each is being used to read the contents of three files ('a.js'
, 'b.js'
, and 'c.js'
) in parallel. The fs.readFile
function is passed as the iterator, and an error-first callback function is supplied to handle the result.
For browser usage, simply include async-each before your scripts and use the global variable asyncEach
:
asyncEach(list, fn, callback);
Details and documentation about async-each can be found in the readme file on its GitHub repository page here. The readme includes the programming API, an explanation of its functions, and simple usage examples. Additionally, any new updates or changes are typically documented in the GitHub repository.