You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # object.map [![NPM version](https://img.shields.io/npm/v/object.map.svg?style=flat)](https://www.npmjs.com/package/object.map) [![NPM monthly downloads](https://img.shields.io/npm/dm/object.map.svg?style=flat)](https://npmjs.org/package/object.map) [![NPM total downloads](https://img.shields.io/npm/dt/object.map.svg?style=flat)](https://npmjs.org/package/object.map) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/object.map.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/object.map) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/object.map.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/object.map)
  2. > Similar to map for arrays, this creates a new object by calling the callback on each property of the original object.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save object.map
  7. ```
  8. ## Usage
  9. ```js
  10. var mapValues = require('object.map');
  11. var result = mapValues({a: 'a', b: 'b'}, function(val, key, obj) {
  12. return val + val;
  13. });
  14. console.log(result);
  15. //=> {a: 'aa', b: 'bb'}
  16. ```
  17. Optionally specify a `thisArg` as the last argument:
  18. ```js
  19. var result = mapValues({a: 'b'}, function(val, key, obj) {
  20. return this.foo;
  21. }, {foo: 'bar'});
  22. console.log(result);
  23. //=> {a: 'bar'}
  24. ```
  25. ## About
  26. ### Related projects
  27. * [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map "Faster, node.js focused alternative to JavaScript's native array map.")
  28. * [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.")
  29. * [collection-map](https://www.npmjs.com/package/collection-map): Returns an array of mapped values from an array or object. | [homepage](https://github.com/jonschlinkert/collection-map "Returns an array of mapped values from an array or object.")
  30. ### Contributing
  31. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  32. ### Contributors
  33. | **Commits** | **Contributor** |
  34. | --- | --- |
  35. | 4 | [jonschlinkert](https://github.com/jonschlinkert) |
  36. | 1 | [phated](https://github.com/phated) |
  37. | 1 | [doowb](https://github.com/doowb) |
  38. ### Building docs
  39. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  40. To generate the readme, run the following command:
  41. ```sh
  42. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  43. ```
  44. ### Running tests
  45. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  46. ```sh
  47. $ npm install && npm test
  48. ```
  49. ### Author
  50. **Jon Schlinkert**
  51. * [github/jonschlinkert](https://github.com/jonschlinkert)
  52. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  53. ### License
  54. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  55. Released under the [MIT License](LICENSE).
  56. ***
  57. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on December 20, 2017._