map-all
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:
- tutorial: curry.md
- issue: jsdoc2md/jsdoc-to-markdown#115
Modules
- @justinc/map-all
- @justinc/jsdocs
-
This module houses JSDoc 3 type definitions which can be re-used in different packages.
@justinc/map-all
Array.<Array.<*>>
@justinc/map-all~mapAll(mappers, iterable) ⇒ 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.
Array.<Y>
@justinc/jsdocs.Mapper ⇒ 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']