@boost/core
Version:
Robust pipeline for creating dev tools that separate logic into routines and tasks.
23 lines (22 loc) • 824 B
JavaScript
;
/* eslint-disable no-restricted-syntax, no-await-in-loop */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Executor_1 = __importDefault(require("../Executor"));
class SerialExecutor extends Executor_1.default {
/**
* Execute tasks in sequential order with the output of each
* task being passed to the next promise in the chain.
*/
async run(handler, tasks, value) {
this.debug('Serializing %d tasks', tasks.length);
let nextValue = value;
for (const task of tasks) {
nextValue = await handler(task, nextValue);
}
return nextValue;
}
}
exports.default = SerialExecutor;