/** * Helper functions that have to do with objects. * * @module */ import type { ReadonlyRecord } from "../types/ReadonlyRecord.js"; import type { WidenLiteral } from "../types/WidenLiteral.js"; /** * Helper function to get the keys and values of an object with their literal key types preserved. * * This is a typed wrapper around `Object.entries`. The type assertion is necessary because * TypeScript defines the keys from `Object.entries` as being `string[]`. */ export declare function getObjectEntries(object: T): ReadonlyArray<{ [K in keyof T]: [K, T[K]]; }[keyof T]>; /** * Helper function to get keys of an object with their literal key types preserved. * * This is a typed wrapper around `Object.keys`. The type assertion is necessary because TypeScript * defines `Object.keys` as returning `string[]`. */ export declare function getObjectKeys(object: T): ReadonlyArray; /** * Safely gets a value from a widened object. * * This is useful when normal indexing produces a type error from an object that uses an `as const` * assertion. */ export declare function getWidenedObjectValue>(object: T, key: WidenLiteral): T[keyof T] | undefined; /** * Helper function to get the values in an object that match an arbitrary condition. Similar to the * `Array.filter` method, but works for objects. * * This is efficient such that it avoids converting the object values into an array. */ export declare function objectFilter(object: ReadonlyRecord, predicate: (value: V) => boolean): readonly V[]; /** * Helper function to map the values in an object to another object with new values. Similar to the * `Array.map` method, but works for objects. */ export declare function objectMap(object: Record, callback: (key: K, value: V) => U): ReadonlyRecord; /** * Helper function to convert an object to a `Map`. * * This is useful when you need to construct a type safe object with the `satisfies` operator, but * then later on you need to query it in a way where you expect the return value to be T or * undefined. In this situation, by converting the object to a map, you can avoid unsafe type * assertions. * * Note that the converted map will only have string keys, due to the nature of JavaScript objects * only having string keys under the hood. */ export declare function objectToMap(object: Record): ReadonlyMap; /** * Helper function to convert an object to a reverse map. * * Note that the converted map will only have string keys, due to the nature of JavaScript objects * only having string keys under the hood. */ export declare function objectToReverseMap(object: Record): ReadonlyMap; /** * Helper function to reverse the keys and values of an object. * * @throws If the object has duplicate values. */ export declare function reverseObject(obj: Record): ReadonlyRecord; //# sourceMappingURL=object.d.ts.map