
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Chaining of functions call to resolve the problem of javascript async callback handling.
npm install chainjs
use in node:
var Chain = require('chainjs'),
param = {message: 'Hello world';}
function beginStep (chain, param) {
console.log(param.message); //Hello world
chain.next('none');
}
function step1 (chain, data) {
chain.next('say hello');
}
Chain(beginStep, param)
.then(step1)
.final(function (chain, data) {
console.log(data); //say hello
});
Chain(func, param)
Chain(func).then(func1).then(func2)
Chain(func).then(func1).then(func2).start();
Saving data in current chain
Chain(function (chain, param) {
chain.data('param', param);
chain.next();
}, {data: ''})
.then(function (chain) {
var param = chain.data('param');
console.log(param); // {data:''}
})
.start();
TBD
Will be invoked before each step
Chain(function (chain, param) {
chain.data('param', param);
chain.next();
}, {data: ''})
.then(function (chain) { // Step 1
var param = chain.data('param');
console.log(param); // {data:''}
})
.before(function (chain) { // Step before
console.log('It will be invoked before each chain step')
})
.start();
TBD
npm test
var Chain = require('chainjs');
Chain(function (chain, msg) {
// save param
chain.data('chain:param', msg);
console.log(msg); //Hello world
chain.next({message: 'Next step'});
}, 'Hello world')
.then(function (chain, param) {
console.log(param.message); // Next step
chain.end({name: 'switer'})
})
.then(function (chain) {
//will be skiped
})
.final(function (chain, author) {
var param = chain.data('chain:param');
console.log(param); // Hello world
console.log(author.name); // switer
})
.start(); // starting chain execute
MIT
FAQs
Flow controller for the complex function logic.
We found that chainjs 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.