Object
/ API Reference
Object
/ API Reference

map

Maps the object based on the provided mapper function.
Similar to Array.prototype.map, but for objects.

The Gist

import { map } from '@weser/object'

const mappedObject = map({ a: 1, b: 2, c: 3 }, (value) => value * 2)

// => { a: 2, b: 4, c: 6 }
console.log(mappedObject)

Parameters

ParameterTypeDescription
objRecord<PropertyKey, any>The object to map.
mapper(value: any, key: PropertyKey, obj: Record<PropertyKey, any>) => RThe mapper function.

Returns

(Record<PropertyKey, R>) The mapped object.

On this page