@vutran/object-map

0.4.1 • Public • Published

object-map

map function for JavaScript objects.

Travis

Install

$ npm install --save @vutran/object-map

Usage

import objectMap from '@vutran/object-map';

const myObject = {
  firstName: 'Vu',
  lastName: 'Tran',
};

const newObject = objectMap(myObject, function(value, prop, arr) {
  return value + '!';
});

console.log(newObject);
// => { firstName: 'Vu!', lastName: 'Tran!' };

API

objectMap(object, callback)

Returns a new object and applies the callback for each property in the given object.

objectMap

Type: object

The reference object

callback

Type: function

Function that produces a value for a given property. Takes 3 arguments: value, prop, object.

value: The value of the current property prop: The name of the property object: The original object

License

MIT © Vu Tran

Readme

Keywords

none

Package Sidebar

Install

npm i @vutran/object-map

Weekly Downloads

1

Version

0.4.1

License

MIT

Last publish

Collaborators

  • vutran