type ReduceObjectArray = T extends object ? T extends [infer F, ...infer R] ? F & ReduceObjectArray : T : never type DeepReadonly = T extends object ? { readonly [K in keyof T]: DeepReadonly } : T type DeepPartial = T extends object ? { [K in keyof T]?: DeepPartial } : T type Diff = T extends object ? U extends object ? { [K in keyof T]?: K extends keyof U ? Deep extends true ? Diff : T[K] : T[K] } & { [K in Exclude]?: Object["diffDeletedSymbol"] } : {} : T | undefined type Object = { /** * Creates a new object with the given object as metatable's index, to mimic JavaScript's `Object.create`. * @param obj - The object to create a new object from. * @returns A new object with the given object as metatable's index. */ create: (obj?: T | undefined) => T extends undefined ? {} : T & {}, /** * Returns an array of the keys of the given object. Supports Proxies, Arrays, Sets, Maps, and Objects. * @param obj - The object to get the keys of. * @returns An array of the keys of the given object. */ keys: { (obj: ReadonlyArray): Array, (obj: ReadonlySet): Array, (obj: ReadonlyMap): Array, (obj: T): Array, }, /** * Returns an array of the entries of the given object. Supports Proxies, Arrays, Sets, Maps, and Objects. * @param obj - The object to get the entries of. * @returns An array of the entries of the given object. */ entries: { (obj: ReadonlyArray): Array<[number, NonNullable]>, (obj: ReadonlySet): Array<[T, true]>, (obj: ReadonlyMap): Array<[K, NonNullable]>, (obj: T): Array<[keyof T, NonNullable]>, }, /** * Returns an array of the values of the given object. Supports Proxies, Arrays, Sets, Maps, and Objects. * @param obj - The object to get the values of. * @returns An array of the values of the given object. */ values: { (obj: ReadonlyArray): Array>, (obj: ReadonlySet): Array, (obj: ReadonlyMap): Array>, (obj: T): Array>, }, /** * Assigns the given sources to the target object. Overriding existing properties. * @param target - The target object to assign the sources to. * @param sources - The sources to assign to the target object. * @returns The target object. */ assign: (target: T, ...sources: U[]) => T & ReduceObjectArray, /** * Creates an object from an array of key-value pairs. * @param i - The array of key-value pairs. * @returns The created object. */ fromEntries:

( this: void, i: ReadonlyArray

, ) => Reconstruct< UnionToIntersection< P extends unknown ? { [k in P[0]]: P[1]; } : never > >, /** * Checks if the given object has the given key. * @param obj - The object to check the key of. * @param key - The key to check if the object has. * @returns Whether the object has the given key. */ hasOwn: { (obj: ReadonlyArray, key: number): boolean, (obj: ReadonlySet, key: T): boolean, (obj: ReadonlyMap, key: K): boolean, (obj: T, key: keyof T): obj is T & Record>, }, /** * Checks if the given object is empty. * @param obj - The object to check if it is empty. * @returns Whether the object is empty. */ isEmpty: (obj: T) => boolean, /** * Duplicates the given object. Supports Proxies, Arrays, Sets, Maps, and Objects. * Can recursively duplicate the object if the `deep` parameter is set to `true`, unless will copy only the first level. * @param obj - The object to duplicate. * @param deep - Whether to duplicate the object deeply. * @returns The duplicated object. */ dup: (obj: T, deep?: boolean) => T, /** * Checks if the given object is equal to the other object. (Mimics JavaScript's `Object.is`) * @param obj - The object to check if it is equal to the other object. * @param other - The other object to check if the object is equal to. * @returns Whether the object is equal to the other object. */ is: (obj: T, other: U) => obj is T & U, /** * Checks if the given object is equal to the other object, by comparing the values of the properties. * Can check the object deeply by setting the `deep` parameter to `true`, unless will check only the first level with shallow comparison. * @param obj - The object to check if it is equal to the other object. * @param other - The other object to check if the object is equal to. * @param deep - Whether to check the object deeply. * @returns Whether the object is equal to the other object. */ equals: (obj: T, other: U, deep?: boolean) => obj is T & U, /** * Returns the string representation of the given object, as json string * @param obj - The object to get the string representation of. * @returns The string representation of the given object. */ toString: (obj: T) => string, /** * Checks if the given object is callable. * @param obj - The object to check if it is callable. * @returns Whether the object is callable. */ isCallable: { (obj: unknown): obj is Callback, (obj: T): obj is T & Callback }, /** * Freezes the given object. * @param obj - The object to freeze. * @returns The frozen object. */ freeze: (obj: T, deep?: Deep) => Deep extends true ? DeepReadonly : Readonly, /** * Checks if the given object is frozen. * @param obj - The object to check if it is frozen. * @returns Whether the object is frozen. */ isFrozen: (obj: T) => obj is Readonly, /** * Seals the given object. A sealed object is an object that cannot be modified., but can still be mutated. * @param obj - The object to seal. * @returns The sealed object. */ seal: (obj: T) => Readonly, /** * Excludes the given types from the given object. * @warn This function does changes the original object, use `Object.dup` to duplicate the object first if you want to keep the original object. * @warn deep does not include a depth limit or a cache, so it can be slow on large objects, or stack overflow on circular objects. * @param obj - The object to exclude the types from. * @param types - The types to exclude from the object. * @param deep - Whether to exclude the types deeply. * @returns The object with the excluded types. */ excludeTypes: (obj: T, types: (keyof CheckableTypes)[] | Set, deep?: Deep) => Deep extends true ? DeepPartial : Partial, /** * A symbol that is used to indicate that a property has been deleted. in a diff object. */ diffDeletedSymbol: symbol, /** * Returns a diff object between the current and other object. * The diff object is a object that contains the changes that have been made to the other object to become the current object. * @warn deep does not include a depth limit or a cache, so it can be slow on large objects, or stack overflow on circular objects. * @param current - The current object. * @param other - The other object. * @param deep - Whether to diff the object deeply. * @returns The diff object. */ diff: (current: T, other: U, deep?: Deep) => Diff, /** * Applies a diff object to the current object. * @warn This function does changes the original object, use `Object.dup` to duplicate the object first if you want to keep the original object. * @warn deep does not include a depth limit or a cache, so it can be slow on large objects, or stack overflow on circular objects. * @param current - The current object. * @param diff - The diff object. * @param deep - Whether to apply the diff deeply. * @returns The object with the applied diff. */ patch: (current: T, diff: U, deep?: Deep) => T, } export declare const Object: Object