@justinc/map-all

2.0.0 • Public • Published

map-all NPM version License Js Standard Style

Run multiple map functions against an Iterable in one go.

Install

npm i @justinc/map-all

Example of usage

const mapAll = require('@justinc/map-all')
// `mapAll` is curried in v2 onwards (see curry tutorial)
mapAll([(x) => x + 1, (x) => x + 2])([1, 2, 3])
// [ [2, 3, 4], [3, 4, 5] ]

Tutorials

TODO: A JSDoc 3 tutorial (re currying) needs to be injected in this README.md. For now there's only a link:

Modules

@justinc/map-all
@justinc/jsdocs

This module houses JSDoc 3 type definitions which can be re-used in different packages.

@justinc/map-all

@justinc/map-all~mapAll(mappers, iterable) ⇒ Array.<Array.<*>>

This function is curried. Calls each mapper obtained from mappers on each element obtained from iterable. In the given result, there is an array for each found mapper. The result of mappers[0] is at results[0] etc…

Kind: inner method of @justinc/map-all
See: Mapper

Param Type
mappers Iterable.<Mapper>
iterable Iterable.<*>

@justinc/jsdocs

This module houses JSDoc 3 type definitions which can be re-used in different packages.

@justinc/jsdocs.Mapper ⇒ Array.<Y>

A function of type Mapper is a similar function to what you'd pass to Array.map

Kind: static typedef of @justinc/jsdocs
Template: X,Y

Param Type Description
currentValue X The current element being processed in the array.
index number The index of the current element being processed in the array.
array Array.<X> The array map was called upon.

Example

const appendIndex = (x, i) => x + `${i}`
;[1, 2, 3].map(appendIndex)
// gives: ['10', '21', '32']

Readme

Keywords

Package Sidebar

Install

npm i @justinc/map-all

Weekly Downloads

3

Version

2.0.0

License

MIT

Last publish

Collaborators

  • justinc