NeXTSTEP Programming Mastermind
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@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

Keywords

none

Install

npm i @vutran/object-map

DownloadsWeekly Downloads

1

Version

0.4.1

License

MIT

Last publish

Collaborators

  • avatar