gen-map-fn
Map function over iterator capturing the iterator return value
Install
npm i -S gen-map-fn
Signatures
genMapFn :: (Function fn, Iterator it) => (fn, it, ...args) -> it
curriedGenMapFn :: (Function fn, Iterator it) => fn -> (it, ...args) -> it
Use case
- You are within a generator function
- You have a source iterator that you are pulling the values from
- You want to transform those values
- You need the return value of the source iterator
- You want to minimize boilerplate and just use:
result = yield* iterator
Usage Example
For curried version use:
const curriedGenMapFn = require('gen-map-fn/curried')
const genMapFn = { 1 2 3 return 'ok'} const mul = v * m { it = console} consoleconsole
Dev
git clone https://github.com/nhz-io/gen-map-fncd gen-map-fnnpm inpm start