@f/map

Map a function over a container of some kind

  • @f/map

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/map
001.5.36 years ago7 years agoMinified + gzip package size for @f/map in KB

Readme

map
!Build statustravis-imagetravis-url !Git taggit-imagegit-url !NPM versionnpm-imagenpm-url !Code stylestandard-imagestandard-url
Map a function over a container of some kind

Installation

$ npm install @f/map

Usage

var map = require('@f/map')

map(add1, [1, 2, 3])          // => [2, 3, 4]
map(add1, {a: 1, b: 2, c: 3}) // => {a: 2, b: 3, c: 4}
map(add1, function * () {yield 1; yield 2; yield 3}) // => function * () {yield 2; yield 3; yield 4}

function add1 (n) {
  return n + 1
}

API

map(fn, container)

  • fn - The function to map over val. Accepts (val, key) and returns a new val to be set at key.
  • container - A container of some kind (objects, arrays, generators or functors).

Returns: A new entity of the same type as container with all of its values being replaced by the result of fn(val, key).

License

MIT