@johngw/stream
Version:
Reactive programming tools using the WHATWG Streams API.
30 lines • 624 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.map = void 0;
/**
* Transforms chunks from one value to another.
*
* @group Transformers
* @example
* ```
* --1----2----3----4----|
*
* map((x) => x + 1)
*
* --2----3----4----5----|
* ```
*/
function map(fn) {
return new TransformStream({
async transform(chunk, controller) {
try {
controller.enqueue(await fn(chunk));
}
catch (error) {
controller.error(error);
}
},
});
}
exports.map = map;
//# sourceMappingURL=map.js.map