mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
07ad400ee0
Closes #968
22 lines
556 B
JavaScript
22 lines
556 B
JavaScript
var Promise = require('bluebird');
|
|
|
|
function pipeline(tasks /* initial arguments */) {
|
|
var args = Array.prototype.slice.call(arguments, 1),
|
|
|
|
runTask = function (task, args) {
|
|
runTask = function (task, arg) {
|
|
return task(arg);
|
|
};
|
|
|
|
return task.apply(null, args);
|
|
};
|
|
|
|
return Promise.all(tasks).reduce(function (arg, task) {
|
|
return Promise.resolve(runTask(task, arg)).then(function (result) {
|
|
return result;
|
|
});
|
|
}, args);
|
|
}
|
|
|
|
module.exports = pipeline;
|