a49b223c9631755551c879fc47cb3dd2c3a21f7661443ed7d3302fea7fd558be72fe35e666311cfb68a7217809d9a7b7d6123b57e6f7711a374c7e0ed39068 613 B

123456789101112131415
  1. import { scan } from './scan';
  2. import { takeLast } from './takeLast';
  3. import { defaultIfEmpty } from './defaultIfEmpty';
  4. import { pipe } from '../util/pipe';
  5. export function reduce(accumulator, seed) {
  6. if (arguments.length >= 2) {
  7. return function reduceOperatorFunctionWithSeed(source) {
  8. return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
  9. };
  10. }
  11. return function reduceOperatorFunction(source) {
  12. return pipe(scan((acc, value, index) => accumulator(acc, value, index + 1)), takeLast(1))(source);
  13. };
  14. }
  15. //# sourceMappingURL=reduce.js.map