switchScan.js 464 B

123456789101112
  1. import { switchMap } from './switchMap';
  2. import { operate } from '../util/lift';
  3. export function switchScan(accumulator, seed) {
  4. return operate((source, subscriber) => {
  5. let state = seed;
  6. switchMap((value, index) => accumulator(state, value, index), (_, innerValue) => ((state = innerValue), innerValue))(source).subscribe(subscriber);
  7. return () => {
  8. state = null;
  9. };
  10. });
  11. }
  12. //# sourceMappingURL=switchScan.js.map