2.1.1 • Published 8 years ago

@f/reduce-map v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 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 @f/reduce-map

Usage

var reduceMap = require('@f/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.1.1

8 years ago

2.1.0

8 years ago