signal-desktop/ts/util/objectMap.ts

11 lines
342 B
TypeScript
Raw Normal View History

2022-06-16 20:48:57 -04:00
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function objectMap<T>(
obj: Record<string, T>,
2024-07-23 17:31:40 -07:00
f: (key: keyof typeof obj, value: (typeof obj)[keyof typeof obj]) => unknown
2022-06-16 20:48:57 -04:00
): Array<unknown> {
const keys: Array<keyof typeof obj> = Object.keys(obj);
return keys.map(key => f(key, obj[key]));
}