jsketcher/modules/lstream/scan.js
2018-07-05 22:42:25 -07:00

14 lines
296 B
JavaScript

import {StreamBase} from './base';
export class ScanStream extends StreamBase {
constructor(stream, initAccumulator) {
super();
this.stream = stream;
this.acc = initAccumulator;
}
attach(observer) {
return this.stream.attach(v => this.acc = observer(this.acc, v));
}
}