UNPKG

@dazejs/framework

Version:

Daze.js - A powerful web framework for Node.js

28 lines 830 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Pipeline = void 0; class Pipeline { constructor(...stages) { this.stages = stages; } pipe(...stages) { for (const stage of stages) { this.stages.push(stage); } return this; } send(...payload) { this.payload = payload; return this; } async process(processor) { if (this.stages.length > 0) { const callback = this.stages .reduceRight((next, pipe) => async (...data) => pipe(...data, next.bind(null, ...data)), async (...params) => processor(...params)); return callback(...this.payload); } return processor(...this.payload); } } exports.Pipeline = Pipeline; //# sourceMappingURL=index.js.map