Given an object, map its entries (key, value) to a new key/value pair, and return a new object.
If the mapping function generates duplicate keys, the latest entry wins.
the object to map
a function that takes an entry and returns a new entry
a new object with the mapped entries
import { mapObject } from "@trashpanda001/helpers/object"objectMap({ a: "alpha", b: "beta" }, ([k, v]) => [k, v.toUpperCase()])// { a: "ALPHA", b: "BETA" }objectMap({ a: "alpha", b: "beta" }, ([k, v]) => [v, k.toUpperCase()])// { alpha: "A", beta: "B" } Copy
import { mapObject } from "@trashpanda001/helpers/object"objectMap({ a: "alpha", b: "beta" }, ([k, v]) => [k, v.toUpperCase()])// { a: "ALPHA", b: "BETA" }objectMap({ a: "alpha", b: "beta" }, ([k, v]) => [v, k.toUpperCase()])// { alpha: "A", beta: "B" }
Given an object, map its entries (key, value) to a new key/value pair, and return a new object.
If the mapping function generates duplicate keys, the latest entry wins.