mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
14 lines
296 B
JavaScript
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));
|
|
}
|
|
}
|