Guest User

Untitled

a guest
Apr 25th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. function mapWithState(state, values, f) {
  2. return values.reduce(({ results, nextState: state }, v, i) => {
  3. const {
  4. result,
  5. nextState
  6. } = f(v, state, i);
  7.  
  8. return {
  9. results: [...results, result],
  10. nextState,
  11. };
  12. }, {
  13. results: [],
  14. nextState: state
  15. });
  16. }
Add Comment
Please, Sign In to add comment