$ npm install --save lomap
const _map = require('lomap')
const obj = {foo: 123, bar: 456}
// simple case: pick some fields
_map(obj, ['foo'])
// {foo: 123}
// level up: pick with different name
_map(obj, {foo2: 'foo'})
// {foo2: 123}
// final move: pick and process with a handler function
_map(obj, ['foo'], val => val + 1)
// {foo: 123}
Type: object
Required: true
Source object.
Type: array
object
An array of keys to select or key-value pair to set different to target object.
Type: function
Default: val => val
Process each value with a handler function.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D