@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
23 lines • 761 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
function transformMapMulti(mapper, opt = {}) {
let index = 0;
return new stream_1.Transform({
objectMode: true,
async transform(chunk, _encoding, cb) {
try {
await mapper(chunk, index++, out => {
// tslint:disable-next-line:no-invalid-this
this.push(out);
});
cb(); // signal that we've finished processing, but emit no output here
}
catch (err) {
cb(err);
}
},
});
}
exports.transformMapMulti = transformMapMulti;
//# sourceMappingURL=transformMapMulti.js.map