We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aeefa07 commit a48312eCopy full SHA for a48312e
dashi/src/lib/utils/mapObject.ts
@@ -0,0 +1,14 @@
1
+export function mapObject<
2
+ S extends Record<string, V1>,
3
+ V1 = unknown,
4
+ V2 = unknown,
5
+>(
6
+ obj: S,
7
+ transformValue: (value: V1, key: string | number) => V2,
8
+): Record<string, V2> {
9
+ const obj2: { [k: string]: V2 } = {};
10
+ Object.getOwnPropertyNames(obj).forEach((key) => {
11
+ obj2[key] = transformValue(obj[key], key);
12
+ });
13
+ return obj2;
14
+}
0 commit comments