Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
run-series
Advanced tools
The run-series npm package is a utility that allows you to run an array of functions in series, each one running once the previous function has completed. If any functions in the series pass an error to its callback, no more functions are run, and the main callback is immediately called with the error. This package is particularly useful for managing sequences of asynchronous tasks in a clean and straightforward manner.
Running tasks in series
This feature allows you to run multiple tasks one after another. Each task is a function that takes a callback as its only argument. Once a task completes, it calls the callback, optionally passing an error and results. If a task passes an error, the series is stopped, and the final callback is called with the error. Otherwise, after all tasks have completed, the final callback is called with an array of results.
const series = require('run-series');
series([
function(callback) {
// Task 1
callback(null, 'result of task 1');
},
function(callback) {
// Task 2
callback(null, 'result of task 2');
}
], function(err, results) {
if (err) throw err;
console.log(results); // ['result of task 1', 'result of task 2']
});
The 'async' package provides a wide range of functions for working with asynchronous JavaScript, including a 'series' method that behaves similarly to run-series. However, 'async' offers much more functionality beyond just running tasks in series, such as parallel execution, waterfall flows, and more, making it a more versatile choice for complex asynchronous control flow.
Neo-async is a drop-in replacement for the 'async' library, designed to be faster and more lightweight. It offers a 'series' function similar to that of run-series and async, but with performance improvements and additional features for handling asynchronous operations, making it a good choice for performance-critical applications that require complex flow control.
npm install run-series
Run the functions in the tasks
array in series, each one running once the previous
function has completed. If any functions in the series pass an error to its callback, no
more functions are run, and callback
is immediately called with the value of the error.
Otherwise, callback
receives an array of results when tasks
have completed.
tasks
- An array containing functions to run, each function is passed a
callback(err, result)
which it must call on completion with an error err
(which can
be null
) and an optional result value.callback(err, results)
- An optional callback to run once all the functions have
completed. This function gets a results array containing all the result arguments passed
to the task callbacks.var series = require('run-series')
series([
function (callback) {
// do some stuff ...
callback(null, 'one')
},
function (callback) {
// do some stuff ...
callback(null, 'two')
}
],
// optional callback
function (err, results) {
// the results array will equal ['one','two']
})
This module is basically equavalent to
async.series
, but it's
handy to just have the functions you need instead of the kitchen sink. Modularity!
Especially handy if you're serving to the browser and need to reduce your javascript
bundle size.
Works great in the browser with browserify!
MIT. Copyright (c) Feross Aboukhadijeh.
FAQs
Run an array of functions in series
The npm package run-series receives a total of 233,166 weekly downloads. As such, run-series popularity was classified as popular.
We found that run-series demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
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.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.