
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
The extremly well-known parallel execution of tasks, but with a cargo, a shared object where tasks can store data. It's like a cargo ship, cranes (tasks) storing cargo (data). Each task writing to the shared object.
It's very useful when you need to call a bunch of functions in parallel and store the results in a common place.
var cranes = [
function (cargo, done) {
cargo.a = 1;
done();
},
function (cargo, done) {
cargo.b = 2;
done();
},
function (cargo, done) {
cargo.c = 3;
done();
}
];
ship.load(cranes, function (err, cargo) {
// cargo { a: 1, b: 2, c: 3 }
});
It's basically the same behaviour as the async.parallel() but with a sightly! and slightly different interface.
module.load(cranes[, cargo], callback) : undefined
Executes all tasks in parallel.
cranes is an array of functions to run in parallel. Each function has the signature function(cargo, done), where cargo is the shared object and done the function to call when the task finishes. As usual, pass an error to done() to abort the execution of the tasks. This is the error returned by the load() function. Because aborting asynchronous parallel tasks is not possible once they begin, the callback is guaranteed to be called only once with the first error occurred.
A cargo can be passed from outside. Use the second parameter to initialize the cargo with data.
var cranes = [
function (cargo, done) {
cargo.b = 2;
done();
},
function (cargo, done) {
cargo.c = 3;
done();
}
];
ship.load(cranes, { a: 1 }, function (err, cargo) {
// cargo { a: 1, b: 2, c: 3 }
});
FAQs
Parallel execution of tasks with a shared namespace
We found that cargo-ship 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.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.