map

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.object

This is the same function as the “Array.map” but for objects. It will iterate over all the properties of the passed object and pass the value to your process function. It will then save the property with your processed value

Params

  1. object*-Object

    The object to process

  2. processor*-Function

    The processor function that will take as parameters the current property value and the property name

Return

  1. -Object

    The processed object

Example

import { map } from '@blackbyte/sugar/object';
const myObject = {
   hello: 'world',
   cat: 'Nelson'
};
map(myObject, ({value, prop}) => {
   return prop === 'hello' ? 'universe' : value;
});
{
   hello: 'universe',
   cat: 'Nelson'
}

Todo

  • testsnormal