Security News
RubyGems.org Adds New Maintainer Role
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.
fastseries
Advanced tools
fastseries is a lightweight and fast utility for running a series of asynchronous functions in Node.js. It is designed to handle a series of tasks in a sequential manner, ensuring that each task completes before the next one starts.
Running a series of asynchronous functions
This feature allows you to run a series of asynchronous functions in sequence. Each function is executed one after the other, and the final callback is called once all functions have completed.
const series = require('fastseries')();
function task1(cb) {
setTimeout(() => {
console.log('Task 1 complete');
cb(null, 'result1');
}, 1000);
}
function task2(cb) {
setTimeout(() => {
console.log('Task 2 complete');
cb(null, 'result2');
}, 500);
}
function task3(cb) {
setTimeout(() => {
console.log('Task 3 complete');
cb(null, 'result3');
}, 200);
}
series(null, [task1, task2, task3], (err, results) => {
if (err) throw err;
console.log('All tasks complete', results);
});
The async package provides a comprehensive set of utilities for working with asynchronous JavaScript. It includes methods for running tasks in series, parallel, and other control flow patterns. Compared to fastseries, async is more feature-rich and versatile but may be heavier in terms of performance and size.
neo-async is a drop-in replacement for async with a focus on performance. It offers similar functionalities to async but is optimized for speed. Like fastseries, it is designed to handle asynchronous control flow, but it provides a broader range of utilities and optimizations.
run-series is a minimalistic utility for running an array of asynchronous functions in series. It is similar to fastseries in terms of simplicity and performance but offers fewer features and customization options.
Zero-overhead series function call for node.js.
Also supports each
and map
!
If you need zero-overhead parallel function call, check out fastparallel.
var series = require('fastseries')({
// if you want the results, then here you are
results: true
})
series(
{}, // what will be this in the functions
[something, something, something], // functions to call
42, // the first argument of the functions
done // the function to be called when the series ends
)
function late (arg, cb) {
console.log('finishing', arg)
cb(null, 'myresult-' + arg)
}
function something (arg, cb) {
setTimeout(late, 1000, arg, cb)
}
function done (err, results) {
console.log('series completed, results:', results)
}
var series = require('fastseries')({
// if you want the results, then here you are
// passing false disables map
results: true
})
series(
{}, // what will be this in the functions
something, // functions to call
[1, 2, 3], // the first argument of the functions
done // the function to be called when the series ends
)
function late (arg, cb) {
console.log('finishing', arg)
cb(null, 'myresult-' + arg)
}
function something (arg, cb) {
setTimeout(late, 1000, arg, cb)
}
function done (err, results) {
console.log('series completed, results:', results)
}
The done
function will be called only once, even if more than one error happen.
This library works by caching the latest used function, so that running a new series does not cause any memory allocations.
Benchmark for doing 3 calls setImmediate
1 million times:
benchSetImmediate*1000000: 2460.623ms
benchAsyncSeries*1000000: 3064.569ms
benchAsyncEachSeries*1000000: 2913.525ms
benchAsyncMapSeries*1000000: 3020.794ms
benchNeoSeries*1000000: 2617.064ms
benchNeoEachSeries*1000000: 2621.672ms
benchNeoMapSeries*1000000: 2611.294ms
benchTinyEachAsync*1000000: 2706.457ms
benchFastSeries*1000000: 2540.653ms
benchFastSeriesNoResults*1000000: 2538.674ms
benchFastSeriesEach*1000000: 2534.856ms
benchFastSeriesEachResults*1000000: 2545.394ms
Benchmarks taken on Node 12.16.1 on a dedicated server.
See bench.js for mode details.
ISC
FAQs
Zero-overhead asynchronous series/each/map function calls
We found that fastseries 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
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.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.