Gathering detailed insights and metrics for callback-sequence
Gathering detailed insights and metrics for callback-sequence
Gathering detailed insights and metrics for callback-sequence
Gathering detailed insights and metrics for callback-sequence
algoframe
A TypeScript comprehensive and modulated libary for doing algebraic animation with requestAnimatioFrame natively, even with Bezier and Sequences
after-sequence
Run several async functions and run a callback when they are gone.
callback-chain
A tool collecting callbacks and invoking them on demand in a sequence, passing a set of user provided arguments. It implements the linked list without using any data structure, but rather keeps provided callbacks in the correct order using the javascript
iterified
Convert any callback-based sequence of values into a full-fledged async iterable
Make a new callback to run input callbacks in sequence
npm install callback-sequence
Typescript
Module System
Node Version
NPM Version
69.6
Supply Chain
98
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
92,384
Last Day
2
Last Week
10
Last Month
66
Last Year
1,685
1 Stars
37 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Oct 05, 2015
Minified
Minified + Gzipped
Latest Version
3.2.0
Package Id
callback-sequence@3.2.0
Size
3.77 kB
NPM Version
2.14.7
Node Version
4.2.1
Cumulative downloads
Total Downloads
Last Day
-50%
2
Compared to previous day
Last Week
42.9%
10
Compared to previous week
Last Month
-29%
66
Compared to previous month
Last Year
-22.8%
1,685
Compared to previous year
1
Make a new callback to run callbacks in sequence or parallel.
Callbacks can be made async like gulp tasks.
1var thunkify = require('callback-sequence') 2 3var Readable = require('stream').Readable 4var gulp = require('gulp') 5 6gulp.task('sequence', thunkify( 7 sync, async, promise, stream 8)) 9 10gulp.task('parallel', thunkify( 11 [sync, async, promise, stream] 12)) 13 14gulp.task('parallel-nested', thunkify( 15 // `async` and `promise` will be run in parallel 16 sync, [async, promise], stream 17)) 18 19gulp.task('sequence-nested', thunkify( 20 // `async` and `promise` will be run in sequence 21 [sync, [async, promise], stream] 22)) 23 24function sync() { 25} 26 27function async(cb) { 28 process.nextTick(cb) 29} 30 31function promise() { 32 return Promise.resolve() 33} 34 35function stream() { 36 var s = Readable() 37 s.push(null) 38 return s 39} 40
1var Runner = require('./lib/runner') 2var runner = new Runner({ input: false, output: false }) 3 4exports = module.exports = runner.thunkify.bind(runner) 5exports.run = exports.sequence = runner.sequence.bind(runner) 6exports.parallel = runner.parallel.bind(runner) 7exports.series = runner.series.bind(runner) 8exports.Runner = Runner 9
var runner = Runner(opts)
Create a new runner instance.
Specify whether to pass the results of the previous callback to the next as arguments.
Type: Boolean
Default: true
1var Runner = require('callback-sequence').Runner 2 3var runner = Runner({ input: true }) 4 5runner.thunkify( 6 function (a, b) { 7 // 3 8 return a + b 9 }, 10 function (sum, next) { 11 process.nextTick(function () { 12 // 6 13 next(null, sum * 2) 14 }) 15 }, 16 function (product) { 17 return Promise.resolve().then(function () { 18 // 7 19 return product + 1 20 }) 21 } 22)(1, 2) 23.then(function (res) { 24 // [7] 25 console.log(res) 26}) 27 28
Specify whether to deliver results.
Type: Boolean
Default: true
If false
, the final results will always be []
.
Specify a runner function to run each callback.
Type: Function
, Object
Default: null
If Function
, it receives a callback followed by a list of arguments,
and should return a promise to fetch the results (Array
).
If Object
, it is passed to
Runner of run-callback
to create a runner function.
Return a callback to run the specified tasks in the appearance order.
1var runner = Runner() 2 3runner.thunkify( 4 function (res) { 5 return res + 1 6 }, 7 function (res) { 8 return Promise.resolve() 9 .then(function () { 10 return res + 1 11 }) 12 }, 13 function (res, next) { 14 process.nextTick(function () { 15 next(null, res - 1, res + 1) 16 }) 17 } 18)(1) 19.then(function (res) { 20 // [ 2, 4 ] 21 console.log(res) 22}) 23
Run tasks
in sequence.
NOTE: directly nested array of tasks will be run with Runner.prototype.parallel
.
1var runner = Runner() 2 3runner.sequence([ 4 function () { console.log(1) }, 5 [ 6 function (cb) { 7 setTimeout(function() { 8 console.log(3) 9 cb() 10 }, 0) 11 }, 12 function () { 13 return new Promise(function (resolve) { 14 process.nextTick(function () { 15 console.log(2) 16 resolve() 17 }) 18 }) 19 }, 20 ], 21 function () { console.log(4) }, 22]).then(function () { 23 console.log('DONE') 24}) 25 26// 1 27// 2 28// 3 29// 4 30// DONE 31
Callbacks can be added dynamically:
1var runner = Runner() 2 3var count = 5 4var tasks = [] 5 6var res = [] 7function task(next) { 8 process.nextTick(function () { 9 res.push(count) 10 if (--count > 0) { 11 tasks.push(task) 12 } 13 next() 14 }) 15} 16runner.sequence(tasks).then(function () { 17 // [5, 4, 3, 2, 1] 18 console.log(res) 19}) 20 21tasks.push(task) 22
Run the specified tasks in parallel.
NOTE: directly nested array of tasks will be run with Runner.prototype.sequence
.
1var runner = Runner() 2 3var res = [] 4runner.parallel([ 5 function () { res.push(1) }, 6 [ 7 function () { 8 return Promise.resolve().then(function () { 9 res.push(4) 10 }) 11 }, 12 function () { res.push(5) }, 13 ], 14 function (cb) { 15 setTimeout(function() { 16 res.push(3) 17 cb() 18 }, 0) 19 }, 20 function (cb) { 21 res.push(2) 22 cb() 23 }, 24]) 25.then(function () { 26 // [1, 2, 4, 5, 3] 27 console.log(res) 28}) 29
Run tasks
in sequence.
However, while the results of sequence
is that of the last task,
the results of series
is an array containing all results of the tasks.
In addition, the results of the previous task will not be passed to the next as arguments.
NOTE: each element will be passed to Runner.prototype.sequence
.
1var runner = Runner() 2 3runner.series( 4 function () { 5 console.log(1) 6 return 1 7 }, 8 [ 9 function () { 10 return Promise.resolve().then(function () { 11 console.log(4) 12 return 4 13 }) 14 }, 15 function (cb) { 16 setTimeout(function() { 17 console.log(3) 18 cb(null, 3) 19 }, 0) 20 }, 21 function () { 22 console.log(5) 23 return 5 24 }, 25 ], 26 function (cb) { 27 console.log(2) 28 cb(null, 2) 29 } 30) 31.then(function (res) { 32 // 1 33 // 5 34 // 4 35 // 3 36 // 2 37 // [ [ 1 ], [ [ 4 ], [ 3 ], [ 5 ] ], [ 2 ] ] 38 console.log(res) 39}) 40
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More