arraymap
v0.1.2
Published
Curried function deriving new array values by applying provided function to each item/index of provided array. Fast and compatible with modern or old browsers.
Maintainers
Readme
arraymap
Curried function deriving new array values by applying provided function to each item/index of provided array. Fast and compatible with modern or old browsers.
npm install arraymap --saveYou can also use Duo, Bower or download the files manually.
npm stats
Overview
Optionally, a dot-notation formatted string may be provided for item property access.
API Example
Pointful
var map = require('arraymap')
var characters = ['a', 'b', 'c']
var codepoints = (letter) => punycode.ucs2.decode(letter)[0]
map(codepoints, characters)
//=> [ 97, 98, 99 ]Pointful (dot-notation object access)
var map = require('arraymap')
var collection = [ { letter: 'a' }, { letter: 'b' }, { letter: 'c' } ]
map('letter', collection)
//=> ['a', 'b', 'c']Pointfree Style
var map = require('arraymap')
var collection = [ { letter: 'a' }, { letter: 'b' }, { letter: 'c' } ]
var promise = Promise.resolve(collection)
promise.then(map('letter'))
//=> ['a', 'b', 'c']API
map(fn, list)
arguments
fn (Function|String).list (array).
returns
(array)Array resulting from applying provided functionfnto each item oflist.
Alternatives
- Array.prototype.map(): difficult to compose, not curried.
- array-map: not curried.
- curried-map: does not support dot-notation string accessor.
Contributing
SEE: contributing.md
