Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
async-each
Advanced tools
No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach / map function for JavaScript.
The async-each package is a small, zero-dependency utility module for Node.js that provides a simple way to iterate over an array asynchronously. It allows you to apply a function to each item in an array in parallel, without waiting for the previous function call to complete, making it useful for performing IO-bound tasks or operations that are CPU-intensive but can be run concurrently.
Asynchronous iteration over an array
This feature allows you to asynchronously process each item in an array. The provided code sample demonstrates how async-each can be used to log each item in an array with a delay of 1 second between each log, simulating an asynchronous operation like reading files or making HTTP requests.
const asyncEach = require('async-each');
const myArray = [1, 2, 3, 4];
asyncEach(myArray, (item, callback) => {
setTimeout(() => {
console.log(item);
callback();
}, 1000);
}, (err) => {
if (err) throw err;
console.log('All items have been processed.');
});
The 'async' package is a comprehensive collection of utility functions for working with asynchronous JavaScript. It offers much more than just asynchronous iteration, including control flow, collection manipulation, and utility functions. Compared to async-each, it is more feature-rich but also larger in size, making async-each a lightweight alternative for projects that only require asynchronous iteration.
Bluebird is a powerful promise library that, among many other features, offers utilities for concurrent execution of promises, which can be used for asynchronous iteration similar to async-each. Bluebird is known for its performance and extensive feature set. It is a good choice if you are already working with promises and need a broad set of features beyond asynchronous iteration.
p-each-series is a package that allows for serial iteration over an array of items with promises. Unlike async-each, which performs iterations in parallel, p-each-series ensures that each item is processed one after the other, waiting for the current promise to resolve before moving to the next. This is useful for tasks that must be done in order but still benefit from asynchronous execution.
No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach function for JavaScript.
We don't need junky 30K async libs. Really.
For browsers and node.js.
npm install async-each
if you’re using node.js.component install paulmillr/async-each
if you’re using component(1).bower install async-each
if you’re using Twitter Bower.each(array, iterator, callback);
— Array
, Function
, (optional) Function
iterator(item, next)
receives current item and a callback that will mark the item as done. next
callback receives optional error, transformedItem
arguments.callback(error, transformedArray)
optionally receives first error and transformed result Array
.Node.js:
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);
});
Browser:
// component(1)
var each = require('async-each');
each(list, fn, callback);
// Default:
window.asyncEach(list, fn, callback);
The MIT License (MIT)
Copyright (c) 2013 Paul Miller (http://paulmillr.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.
FAQs
No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach / map function for JavaScript.
The npm package async-each receives a total of 2,933,102 weekly downloads. As such, async-each popularity was classified as popular.
We found that async-each demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.