Skip to content

micro-js/reduce-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Generates a reducing function that maps a reducer over the entities in a container.

Resources

Stars

Watchers

Forks

Packages

No packages published