
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
flow-builder
Advanced tools
define and execute tasks in a simple way.
flow-builder lets you define a work flow that works well with tasks with a defined API.
it gives you a simple building block to handle tasks that depend on other tasks.
tasks will most likely be asynchronous, but it can be used for synchronous tasks as well.
whenever your tasks don't have a unified API (function name and function signature).
npm install flow-builder
var Flow = require('flow-builder');
var flow = new Flow();
// define flow
flow
.parallel('header', task('ADD A HEADER'))
.parallel('footer', task('ADD A FOOTER'))
.series('content', task('ENTER CONTENT'));
// handle flow events
var results = {};
flow
.task(function(name, item, callback) {
item.doSmartThing(results, function(err, result) {
results[result] = result + ' DONE';
callback(err);
});
})
.group(function(err, group, callback) {
console.log('group finished', group);
callback(err);
})
.done(function(err) {
if (err) return console.log('failed');
console.log('all done', results);
});
// start flow
flow.exec();
// example task
var projectHistory = [];
function task(todo) {
return {
doSmartThing: function(list, callback) {
projectHistory.push(todo);
callback(null, todo);
}
}
}
the flow is basically executed in the order the definition methods are called.
automatic group creation
eventually tasks will be in the same group: started immediately, and evaluated at the final callback (done).series tasks added in a row will create a new series group.parallel tasks that are added in a row will create a new `parallel group.parallel after series or vice versa, a new group is being created automatically.arguments
the flow definition methods take any and as many arguments as you like.
the provided arguments will be emitted in the task event, to let you handle the task execution.
the only thing to consider is, that the arguments should be consistent in every definition method for the same flow.
the methods return this and are chainable.
aliases: eachSeries, eachSync, sync
these tasks will execute in the defined order. the next task that was defined with series will be executed only after the previous one has finished.
aliases: each
these tasks will start their execution together.
if series tasks have been defined before, they will finish first.
after the defined parallel tasks in the same group
aliases: long
these tasks will be started immediately and evaluated only at the final callback (done), when the whole task flow has finished.
aliases: execute
start the flow execution
iterates over the defined tasks.
callback(args, stepIndex, groupName, groupIndex)
called on every defined flow execution step (task)
call the callback function when the task is done callback() or when an error occured callback(err).
arguments: [args...,] callback
args arguments as they were defined with series, parallel or eventually.callback(err)called every time a defined group has finished
call the callback function when the task is done callback() or when an error occured callback(err).
when the callback(err) is called with a truthy err, the flow is stopped and done err is emited.
arguments: err, group, callback
err errorgroup definition as array [name, [steps...]] where steps are the defined argumentscallback(err)called at the very end of the flow execution (final callback)
arguments: err
err truthy when an error occurednpm test
MIT
FAQs
define and execute tasks in a simple way
We found that flow-builder 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.