# lomap **Repository Path**: mirrors_egoist/lomap ## Basic Information - **Project Name**: lomap - **Description**: Map reducer for JS object. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # _map [![NPM version](https://img.shields.io/npm/v/lomap.svg?style=flat-square)](https://npmjs.com/package/lomap) [![NPM downloads](https://img.shields.io/npm/dm/lomap.svg?style=flat-square)](https://npmjs.com/package/lomap) [![Build Status](https://img.shields.io/circleci/project/egoist/lomap/master.svg?style=flat-square)](https://circleci.com/gh/egoist/lomap) ## Install ```bash $ npm install --save lomap ``` ## Usage ```js 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: 124} ``` ## API ### _map(source, selection, [handler]) #### source Type: `object`
Required: `true` Source object. #### selection Type: `array` `object` An array of keys to select or key-value pair to set different name in target object. #### handler Type: `function`
Default: `val => val` Process each value with a handler function. ## Contributing 1. Fork it! 2. Create your feature branch: `git checkout -b my-new-feature` 3. Commit your changes: `git commit -am 'Add some feature'` 4. Push to the branch: `git push origin my-new-feature` 5. Submit a pull request :D ## License [MIT](https://egoist.mit-license.org/) © [EGOIST](https://github.com/egoist)