UNPKG

@johngw/stream

Version:

Reactive programming tools using the WHATWG Streams API.

27 lines 639 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withCounter = void 0; const map_1 = require("@johngw/stream/transformers/map"); /** * Adds a counter representing the amount of chunks * received thus far. * * @group Transformers * @example * ``` * --a----------------------b-------| * * withCounter() * * --{chunk:'a',counter:0}--{chunk:'b',counter:1}-| * ``` */ function withCounter(start = 0) { let counter = start; return (0, map_1.map)((chunk) => ({ chunk, counter: counter++, })); } exports.withCounter = withCounter; //# sourceMappingURL=withCounter.js.map