Creates an object with the same values and keys generated by running each own enumerable string keyed and symbol keyed property of object through the callback.

Info

The source object should be a Plain Object.

Info

The returned object preserves a null prototype when the source object was created with Object.create(null).

Syntax

TypeScript
import { mapKeys } from "@opentf/std";

mapKeys(obj: object, fn: (value: any, key: string | symbol) => string | symbol)

Examples

TypeScript
const obj = { a: 1, b: 2 };

mapKeys(obj, (v, k) => k + v); 
//=> { a1: 1, b2: 2 }
Last updated on
Edit this page