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