Object
/ API ReferenceObject
/ API Referencemap
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
| Parameter | Type | Description |
|---|---|---|
| obj | Record<PropertyKey, any> | The object to map. |
| mapper | (value: any, key: PropertyKey, obj: Record<PropertyKey, any>) => R | The mapper function. |
Returns
(Record<PropertyKey, R>) The mapped object.
© 2024-present Robin Weser. All Rights Reserved.