2.0.0 • Published 9 years ago

@micro-js/reduce-map v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

reduce-map

Build status Git tag NPM version Code style

Generates a reducing function that maps a reducer over the entities in a container (usually an object or array). That is complicated to state, but simple if you see the implementation:

function reduceMap (fn) {
  return function (state, value) {
    return map(iter, state)

    function iter (item, key) {
      return fn(item, value, key)
    }
  }
}

Installation

$ npm install @micro-js/reduce-map

Usage

var reduceMap = require('@micro-js/reduce-map')

combineActions({
  todos: handleActions({
    [SET_ALL_COMPLETED]: reduceMap((todo, {completed}) => ({...todo, completed}))
  })
})

API

reduceMap(fn)

  • fn - A function that accepts (item, value, key) and produces a new item based on value.

Returns: A reducing function that maps your reducer fn, over state to produce a new container of type state from each of its elements, and the value passed to reduce.

License

MIT

2.0.0

9 years ago

1.0.0

9 years ago