Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mapWithState(state, values, f) {
- return values.reduce(({ results, nextState: state }, v, i) => {
- const {
- result,
- nextState
- } = f(v, state, i);
- return {
- results: [...results, result],
- nextState,
- };
- }, {
- results: [],
- nextState: state
- });
- }
Add Comment
Please, Sign In to add comment