UNPKG

@tsdi/pack

Version:

@tsdi/pack is simple build tasks, base on AOP, Ioc container, via @tsdi. dev build pack activities.

62 lines (60 loc) 2.09 kB
import { __awaiter, __decorate, __metadata } from "tslib"; import { isArray } from '@tsdi/ioc'; import { Input } from '@tsdi/components'; import { Task } from '@tsdi/activities'; import { TransformActivity } from './TransformActivity'; let StreamActivity = class StreamActivity extends TransformActivity { execute(ctx) { return __awaiter(this, void 0, void 0, function* () { let pipes = yield ctx.resolveExpression(this.pipes); if (isArray(pipes)) { pipes = pipes.filter(p => p); } if (pipes && pipes.length) { return yield this.pipeStreams(ctx, ctx.getData(), ...pipes); } }); } /** * stream pipe transform. * * @protected * @param {NodeActivityContext} ctx * @param {ITransform} stream * @param {...Expression<ITransform>[]} pipes * @returns {Promise<ITransform>} * @memberof StreamActivity */ pipeStreams(ctx, stream, ...pipes) { return __awaiter(this, void 0, void 0, function* () { if (pipes.length < 1) { return stream; } if (pipes.length === 1) { return yield this.pipeStream(ctx, stream, pipes[0]); } let pstream = Promise.resolve(stream); pipes.forEach(transform => { if (transform) { pstream = pstream .then(stm => { return this.pipeStream(ctx, stm, transform); }); } }); return yield pstream; }); } static ρAnn() { return { "name": "StreamActivity", "params": { "execute": ["ctx"], "pipeStreams": ["ctx", "stream", "pipes"] } }; } }; __decorate([ Input('pipes'), __metadata("design:type", Array) ], StreamActivity.prototype, "pipes", void 0); StreamActivity = __decorate([ Task('pipes, [pipes]') ], StreamActivity); export { StreamActivity }; //# sourceMappingURL=../sourcemaps/transforms/StreamActivity.js.map