@gameye/sdk
Version:
Node.js SDK for Gameye
20 lines • 576 B
JavaScript
import * as stream from "stream";
export 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);
}
}
//# sourceMappingURL=reduce-transform.js.map