
Security News
OpenGrep Restores Fingerprinting in JSON and SARIF Outputs
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
flow control library with a chaining interface, inspired by node-seq by substack
Simple flow control library inspired by seq by substack and async by caolan.
The interface is quite similar but with a reduced function range.
Instead of using the this
property to assign a done-callback the traditional node way is used (a callback function as the last parameter).
npm install chainr
Functions registered via .seq
are executed in sequential order.
Each cb
gets a callback assigned which is used to signal the end of the callback execution.
If name is specified, the second argument sent to cb
goes to chain.var
.
var chainr = require('../');
var chain = chainr();
chain
.seq('foo', function (cb) {
console.log('1');
setTimeout(cb.bind(null, null, 'bar'), 100);
})
.seq(function (cb) {
console.log('2');
setTimeout(cb, 100);
})
.seq(function (cb) {
console.log('3');
console.log(chain.vars);
});
Output:
1
2
3
{ foo: 'bar' }
Functions registered via .par
are executed in parallel.
Each cb
gets a callback assigned which is used to signal the end of the callback execution.
If name is specified, the second argument sent to cb
goes to chain.var
.
var chainr = require('../');
var chain = chainr();
chain
.par(function(cb) {
setTimeout(function() {
console.log('1.1');
cb();
}, 1000);
})
.par('foo', function(cb) {
setTimeout(function() {
console.log('1.2');
cb(null, 'bar');
}, 400);
})
.par(function(cb) {
setTimeout(function() {
console.log('1.3');
cb();
}, 100);
})
.seq(function (cb) {
console.log(chain.vars);
});
Output:
1.3
1.2
1.1
{ foo: 'bar' }
Functions registered via .one
are executed in parallel.
one
acts equally as par
with the distinction that it does not wait for all callbacks to execute, one call is sufficient.
Each cb
gets a callback assigned which is used to signal the end of the callback execution.
If name is specified, the second argument sent to cb
goes to chain.var
. (Notice that not every value might be in there!)
var chainr = require('../');
var order = [];
var chain = chainr();
chain
.one(function(cb) {
setTimeout(function() {
console.log('1.1');
order.push('1.1');
cb();
}, 1000);
})
.one(function(cb) {
setTimeout(function() {
console.log('1.2');
order.push('1.2');
cb();
}, 400);
})
.one(function(cb) {
setTimeout(function() {
console.log('1.3');
order.push('1.3');
cb();
}, 100);
})
.seq(function (cb) {
console.log(order);
});
Output:
1.3
1.2
1.1
['1.1']
When in a sequential or parallel context a callback gets an error object assigned, the execution steps over all pending steps and skips to the next catch
block.
The catch block than receives the error and an callback that can be used to continue with the execution or to rethrow the error.
var chainr = require('../');
chainr()
.seq(function (cb) {
cb(new Error('foo'));
})
.seq(function (cb) {
console.log('2');
cb();
})
.catch(function (error, cb) {
console.log(error);
cb(error);
})
.catch(function(error, cb) {
console.log(error);
cb();
})
.seq(function() {
console.log('final');
});
Output:
[Error: foo]
[Error: foo]
final
FAQs
flow control library with a chaining interface, inspired by node-seq by substack
The npm package chainr receives a total of 16 weekly downloads. As such, chainr popularity was classified as not popular.
We found that chainr 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
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.