You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

15 lines
613 B

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) => accumulator(acc, value, index + 1)), takeLast(1))(source);
};
}
//# sourceMappingURL=reduce.js.map