
Security News
Security Community Slams MIT-linked Report Claiming AI Powers 80% of Ransomware
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.
callback-sequence
Advanced tools
Make a new callback to run callbacks in sequence.
Callbacks can be made async like gulp tasks.
var sequence = require('callback-sequence');
var Readable = require('stream').Readable;
var gulp = require('gulp');
gulp.task('publish', sequence(
  read, lint, warn, bump
));
function lint() {
}
function warn(cb) {
  process.nextTick(cb);
}
function bump() {
  return Promise.resolve();
}
function read() {
  var s = Readable();
  s.push(null);
  return s;
}
sequence will create a callback to run all those specified tasks in appearance order.
Type: mixed
Optional
If specified, it can be passed to the first task through sequence.last.
See task.
Type: Function
Signature: done(err, results)
done is called after all tasks finish.
results is an array containing all results of the tasks.
Type: Function, Array
If Array, the first element is treated as the callback,
and elements following the callback are passed to it as arguments.
var sequence = require('callback-sequence');
function sum(a, b, next) {
  process.nextTick(function () {
    next(null, a + b);
  });
}
sequence(
  [sum, sequence.last, 1],
  [sum, sequence.last, 1],
  [sum, sequence.last, 1]
)(1, function (err, res) {
  console.log('Expected:', [2, 3, 4]);
  console.log('Actual:', res);
});
Type: Array
Elements are tasks.
var sequence = require('callback-sequence');
function sum(a, b, next) {
  process.nextTick(function () {
    next(null, a + b);
  });
}
sequence.run([
  [sum, sequence.last, 1],
  [sum, sequence.last, 1],
  [sum, sequence.last, 1],
], 1, function (err, res) {
  console.log('Expected:', [2, 3, 4]);
  console.log('Actual:', res);
});
Actually, you can dynamically add callbacks:
var sequence = require('callback-sequence');
var tasks = [task];
var count = 0;
function task(next) {
  process.nextTick(function () {
    count++;
    if (count < 5) {
      tasks.push(task);
    }
    next(null, count);
  });
}
sequence.run(tasks, function (err, res) {
  console.log(res);
  // [ 1, 2, 3, 4, 5 ]
});
Type: Array
Store all the results of the tasks.
It is passed to done as the second argument.
Sync callbacks deliver results with return,
async callbacks with the last argument passed to it (next(err, res)),
promisified callbacks with resolve(res),
and streamified callbacks always deliver undefined.
FAQs
Make a new callback to run input callbacks in sequence
The npm package callback-sequence receives a total of 134 weekly downloads. As such, callback-sequence popularity was classified as not popular.
We found that callback-sequence 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
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.

Research
/Security News
Socket researchers found 10 typosquatted npm packages that auto-run on install, show fake CAPTCHAs, fingerprint by IP, and deploy a credential stealer.