mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
18 lines
368 B
JavaScript
18 lines
368 B
JavaScript
import {StreamBase} from './base';
|
|
|
|
export class ScanStream extends StreamBase {
|
|
|
|
constructor(stream, seed, scanFunc) {
|
|
super();
|
|
this.stream = stream;
|
|
this.value = seed;
|
|
this.scanFunc = scanFunc;
|
|
}
|
|
|
|
attach(observer) {
|
|
return this.stream.attach(v => {
|
|
this.value = this.scanFunc(this.value, v);
|
|
observer(this.value);
|
|
});
|
|
}
|
|
}
|