UNPKG

@gameye/sdk

Version:
23 lines 689 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stream = require("stream"); class ReduceTransform extends stream.Transform { constructor(fn, initialState) { super({ objectMode: true }); this.fn = fn; if (initialState === undefined) { this.state = fn(); } else { this.state = initialState; } } _transform(chunk, encoding, callback) { const { fn } = this; let { state } = this; this.state = state = fn(state, chunk); callback(undefined, state); } } exports.ReduceTransform = ReduceTransform; //# sourceMappingURL=reduce-transform.js.map