import type { ImmutableArray } from "./array.js"; /** Any readonly object. */ export type ImmutableObject = { readonly [KK in K]: T; }; /** Any writable object. */ export type MutableObject = { [KK in K]: T; }; /** Prop for an object. */ export type Prop = readonly [keyof T, T[keyof T]]; /** Key for an object prop. */ export type Key = keyof T; /** Value for an object prop. */ export type Value = T[keyof T]; /** Something that can be converted to an object. */ export type PossibleObject = T | Iterable>; /** Is an unknown value an unknown object? */ export declare function isObject(value: unknown): value is ImmutableObject; /** Assert that a value is an object */ export declare function assertObject(value: unknown): asserts value is ImmutableObject; /** Is an unknown value a plain object? */ export declare function isPlainObject(value: unknown): value is ImmutableObject; /** Assert that an unknown value is a plain object */ export declare function assertPlainObject(value: unknown): asserts value is ImmutableObject; /** Is an unknown value the key for an own prop of an object. */ export declare const isProp: (obj: T, key: PropertyKey) => key is keyof T; /** Assert that an unknown value is the key for an own prop of an object. */ export declare function assertProp(obj: T, key: PropertyKey): asserts key is keyof T; /** Turn a possible object into an object. */ export declare function getObject(obj: PossibleObject): T; /** * Mutable type is the opposite of `Readonly` helper type. * - See https://github.com/microsoft/TypeScript/issues/24509 * - Consistency with `Readonly` */ export type Mutable = { -readonly [K in keyof T]: T[K]; }; /** * Deep partial object: deeply convert an object to its partial version. * - Any value that extends `UnknownObject` has its props made partial. * - Works deeply on nested objects too. */ export type DeepPartial = { [K in keyof T]?: DeepPartial; }; /** * Deep mutable object: deeply convert an object to its mutable version. * - Any value that extends `UnknownObject` has its props made mutable. * - Works deeply on nested objects too. */ export type DeepMutable = { -readonly [K in keyof T]: DeepMutable; }; /** * Deep readonly object: deeply convert an object to its readonly version. * - Any value that extends `UnknownObject` has its props made readonly. * - Works deeply on nested objects too. */ export type DeepReadonly = { +readonly [K in keyof T]: DeepReadonly; }; /** Pick only the properties of an object that match a type. */ export type PickProps = Pick; /** Omit the properties of an object that match a type. */ export type OmitProps = Omit; /** Get the props of an object as a set of entries. */ export declare function getProps(obj: T): ImmutableArray>; export declare function getProps(obj: T | Partial): ImmutableArray>; export declare function getProps(obj: T | Partial | Iterable>): Iterable>; /** Get the keys of an object as an array. */ export declare function getKeys(obj: T): ImmutableArray>; export declare function getKeys(obj: T | Partial): ImmutableArray>; export declare function getKeys(obj: T | Partial | Iterable>): Iterable>; /** Extract the value of a named prop from an object. */ export declare function getProp>(obj: T, key: K): T[K]; /** Create an object from a single prop. */ export declare function fromProp(key: K, value: V): { readonly [KK in K]: V; }; /** Set a prop on an object (immutably) and return a new object including that prop. */ export declare function withProp>(input: T, key: K, value: T[K]): T; /** Set several props on an object (immutably) and return a new object including those props. */ export declare function withProps(input: T, props: Partial): T; export declare function withProps(input: T, props: T | Partial | Iterable>): T; /** Remove several props from an object (immutably) and return a new object without those props. */ export declare function omitProps>(input: T, ...keys: K[]): Omit; /** Remove a prop from an object (immutably) and return a new object without that prop. */ export declare const omitProp: >(input: T, key: K) => Omit; /** Pick several props from an object and return a new object with only thos props. */ export declare function pickProps>(obj: T, ...keys: K[]): Pick; /** Set a single named prop on an object (by reference) and return its value. */ export declare function setProp>(obj: T, key: K, value: T[K]): T[K]; /** Set several named props on an object (by reference). */ export declare function setProps(obj: T, entries: T | Partial | Iterable>): void; /** Remove several key/value entries from an object (by reference). */ export declare function deleteProps(obj: T, ...keys: Key[]): void; /** Remove a key/value entry from an object (by reference). */ export declare const deleteProp: (input: T, key: Key) => void; /** * Get the prototype of an object instance. * - Recommend to use this because Typescript's default lib specifies `Object.getPrototypeOf()` returning `any`. */ export declare function getPrototype(obj: T): Partial | null; /** Shallow clone an object with the same prototype. */ export declare function cloneObject(input: T): T; /** Shallow clone an object with a single changed value. */ export declare function cloneObjectWith>(input: T, key: K, value: T[K]): T; export declare function cloneObjectWith(input: T, key: K, value: V): T & { [KK in K]: V; };