This is a simple and naive reducer implementation. Reducers allow to apply chained algorithms in a single loop. It also provides more compliant argument positions, for functional programming.
Using map:
import {map, reduce} from 'reducer';
reduce(map(value => value * 2)(concat), [1, 2, 3, 4]);
// => [2, 4, 6];
Using filter:
import {filter, reduce} from 'reducer';
reduce(filter(value => 0 === value % 2)(concat), [1, 2, 3, 4]);
// => [2, 4]
Using compose:
import {map, filter, compose, reduce} from 'reducer';
reduce(compose(
map(value => value * 2),
filter(value => 0 === value % 2)
)(concat), [1, 1.5, 2, 2.5]);
// => [2, 4]
MIT.