MCPcopy
hub / github.com/louischatriot/nedb / _parallel

Function _parallel

browser-version/out/nedb.js:3742–3772  ·  view source on GitHub ↗
(eachfn, tasks, callback)

Source from the content-addressed store, hash-verified

3740 };
3741
3742 var _parallel = function(eachfn, tasks, callback) {
3743 callback = callback || function () {};
3744 if (tasks.constructor === Array) {
3745 eachfn.map(tasks, function (fn, callback) {
3746 if (fn) {
3747 fn(function (err) {
3748 var args = Array.prototype.slice.call(arguments, 1);
3749 if (args.length <= 1) {
3750 args = args[0];
3751 }
3752 callback.call(null, err, args);
3753 });
3754 }
3755 }, callback);
3756 }
3757 else {
3758 var results = {};
3759 eachfn.each(_keys(tasks), function (k, callback) {
3760 tasks[k](function (err) {
3761 var args = Array.prototype.slice.call(arguments, 1);
3762 if (args.length <= 1) {
3763 args = args[0];
3764 }
3765 results[k] = args;
3766 callback(err);
3767 });
3768 }, function (err) {
3769 callback(err, results);
3770 });
3771 }
3772 };
3773
3774 async.parallel = function (tasks, callback) {
3775 _parallel({ map: async.map, each: async.each }, tasks, callback);

Callers 1

nedb.jsFile · 0.85

Calls 2

fnFunction · 0.85
_keysFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…