/** * Array assignment function that merges arrays excluding null and undefined values. */ declare const arrAssign: (target: E[], ...sources: E[][]) => E[]; /** * Get the class name of an object from its constructor. */ declare function className(target: object): string; /** * Returns the constructor of the given object. */ declare function constructorOf(o: T): any; /** * Creates a function that merges arrays based on a predicate function. */ declare function createArrayMerger(predicate: (value: T, index: number, arr: T[]) => boolean): (target: E[], ...sources: E[][]) => E[]; /** Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). @category Class */ type Constructor = new(...arguments_: Arguments) => T; type Any = any; type TFunction = (...args: A) => R; type AnyFunction = Constructor | TFunction; type AnyConstructor = (new (...args: any[]) => Any) | AnyFunction; type StringKeyOf = Extract; /** * Gets the union type of all values in the given object type. */ type ValueOf = O[keyof O]; /** * Creates a function that merges objects based on a predicate function. */ declare function createObjectMerger(predicate: (value: Any, key: string, obj: Record) => boolean): (target: Record, ...sources: Record[]) => Record; /** * Check if the given descriptor is an accessor descriptor. */ declare function isAccessorDescriptor(des?: TypedPropertyDescriptor): des is AccessorDescriptor; type DescriptorGetter = { get: () => V; }; type DescriptorSetter = { set: (value: V) => void; }; type DescriptorBothAccessors = DescriptorGetter & DescriptorSetter; type DescriptorAccessors = DescriptorGetter | DescriptorSetter | DescriptorBothAccessors; type AccessorsDescriptorAttributes = { configurable?: boolean; enumerable?: boolean; }; type AccessorDescriptor = AccessorsDescriptorAttributes & DescriptorAccessors; /** * Define accessor properties (getter and setter) on an object with enhanced descriptor handling. */ declare function defineAccessors(obj: T, // key: PropertyKey, des: AccessorDescriptor): T; /** * Define a getter property on an object with enhanced descriptor handling. */ declare function defineGetter(obj: T, key: PropertyKey, get: () => V, des?: Omit, 'get'>): T; /** * Define a lazy property that evaluates its getter on first access and then caches the value. */ declare function defineLazyProperty(obj: T, key: PropertyKey, get: () => V, des?: Omit, 'get'>): T; /** * Check if the given descriptor is a value descriptor. */ declare function isValueDescriptor(des?: TypedPropertyDescriptor): des is ValueDescriptor; type DescriptorValue = { value?: V; }; type ValueDescriptorAttributes = { configurable?: boolean; enumerable?: boolean; writable?: boolean; }; type ValueDescriptor = ValueDescriptorAttributes & DescriptorValue; /** * Define a method property on an object with enhanced descriptor handling. */ declare function defineMethod(obj: T, key: PropertyKey, value: V, des?: ValueDescriptor | AccessorDescriptor): T; /** * Utility function for defining properties on objects with enhanced descriptor handling. */ declare function defineProperty(obj: T, // key: PropertyKey, des: ValueDescriptor | AccessorDescriptor): T; /** * Define a setter property on an object with enhanced descriptor handling. */ declare function defineSetter(obj: T, key: PropertyKey, set: (value: V) => void, des?: Omit, 'set'>): T; /** * Define a value property on an object with enhanced descriptor handling. */ declare function defineValue(obj: T, key: PropertyKey, value: V, des?: ValueDescriptor | AccessorDescriptor): T; /** * Mutably delete enumerable properties with null or undefined values. */ declare function deleteNullishPropsMutable(obj: T): T; /** * Same as Object.entries except the keys are typed as keyof T. */ declare function entriesOf(obj: T): [StringKeyOf, T[StringKeyOf]][]; /** * Filter an object's own enumerable properties by predicate. */ declare function filterObject(obj: T, predicate: (value: ValueOf, key: StringKeyOf, obj: T) => boolean): T; /** * Mutably filter an object's own properties based on a given predicate. */ declare function filterObjectMutable(obj: T, predicate: (value: ValueOf, key: keyof T, obj: T) => boolean): Partial; /** * Get the class constructor chain for any target (constructor, prototype, or instance). * Always returns constructors/classes, never prototype objects. * By default excludes the target's own constructor (returns superclasses only). */ declare function getClassChain(target: object | AnyConstructor, options?: { includeSelf?: boolean; }): AnyConstructor[]; /** * Returns an array of keys representing configurable methods or getters of an object. * * @template T - The type of the object. * @param obj - The object to retrieve the keys from. * @returns An array of keys representing configurable methods or getters. */ declare function getConfigurableMethodOrGetterKeys(obj: T): string[]; /** * Creates a preset function for getting object keys with specific filtering options. */ declare function getKeysPreset(options?: GetKeysOptions): (o: object) => KeysPrimitiveTypeFrom[]; interface IOptsKeys { ignoreEnumerable?: boolean; ignoreNonEnumerable?: boolean; } interface IOptsEnumerableKeys extends IOptsKeys { ignoreEnumerable?: false; ignoreNonEnumerable: true; } interface IOptsNonEnumerableKeys extends IOptsKeys { ignoreEnumerable: true; ignoreNonEnumerable?: false; } interface IOptsEnumerableAndNonEnumerableKeys extends IOptsKeys { ignoreEnumerable?: false; ignoreNonEnumerable?: false; } interface IOptsKeyType { ignore?: (string | symbol)[]; ignoreSymbols?: boolean; ignoreStrings?: boolean; } interface IOptsStringKeys extends IOptsKeyType { ignore?: string[]; ignoreSymbols: true; ignoreStrings?: false; } interface IOptsSymbolKeys extends IOptsKeyType { ignore?: symbol[]; ignoreSymbols?: false; ignoreStrings: true; } interface IOptsStringAndSymbolKeys extends IOptsKeyType { ignore?: (string | symbol)[]; ignoreSymbols?: false; ignoreStrings?: false; } type OptsKeysVariants = IOptsEnumerableKeys | IOptsNonEnumerableKeys | IOptsEnumerableAndNonEnumerableKeys; type OptsKeyTypeVariants = IOptsStringKeys | IOptsSymbolKeys | IOptsStringAndSymbolKeys; type GetKeysOptions = K & KT; type KeysPrimitiveTypeFrom

= P extends IOptsStringKeys ? string : P extends IOptsSymbolKeys ? symbol : string | symbol; /** * Returns an array of the own property keys of an object. * * Every combination of ways to toggle enumerable/non-enumerable/strings/symbols * are available. Ignoring specific keys is also possible. * * @remarks * The options are typed so that non-sensical or impossible combinations are disallowed. * * @remarks * The prototype chain is not traversed, but used in tandom with * @see prototypeChain you can easily specify exactly what keys you need. * @see superClassChain for traversing only class constructors of the prototype chain. */ declare function getKeys(o: object, options?: GetKeysOptions): KeysPrimitiveTypeFrom[]; /** * Returns a given own property value of a given object. */ declare function getOwnProperty(obj: object, key: PropertyKey): undefined; /** * Get the prototype chain of any object. * Returns prototype objects, not constructors. */ declare function getPrototypeChain(target: object, options?: { includeSelf?: boolean; }): object[]; /** * Get the immediate superclass of a target. * Returns Object if no meaningful superclass exists. */ declare function getSuperClass(target: object | AnyConstructor): AnyConstructor; /** * Get all superclasses of a target (excluding the target itself by default). * Simpler version without overloads - just returns the class chain. */ declare function getSuperClasses(target: object | AnyConstructor, options?: { includeSelf?: boolean; }): AnyConstructor[]; /** * Object.prototype.hasOwnProperty.call */ declare function hasOwnProperty(object: T, key: PropertyKey): boolean; /** * Determines if a property is defined on an object, including 'own' and prototype chain. */ declare function hasProperty(object: T, key: PropertyKey): key is keyof T; /** * Determines if a property is defined on an object's prototype prototype chain, not * including the object itself. */ declare function hasPrototypeChainProperty(object: T, key: PropertyKey): boolean; /** * Copies prototype members from a source constructor to a target constructor, excluding specified keys. */ declare function inheritPrototypeMembers>(target: T, source: Constructor, ignoreKeys?: PropertyKey[]): T; /** * Copies static members from a source constructor to a target constructor, excluding specified keys. */ declare function inheritStaticMembers>(target: T, source: Constructor, ignoreKeys?: PropertyKey[]): T; /** * Check if the property is enumerable. */ declare function isEnumerable(target: T, key: PropertyKey): boolean; /** * Checks if a property descriptor represents a method (function value descriptor). */ declare function isMethodValueDescriptor(descriptor: PropertyDescriptor): descriptor is TypedValuePropertyDescriptor; type TypedValuePropertyDescriptor = ValueDescriptorAttributes & DescriptorValue & ThisType; /** * Returns the first element of an iterable object. * @template T - The type of elements in the iterable. * @param iterable The iterable object. * @returns The first element of the iterable object, or `undefined` if the iterable is empty. * @example ```ts * iterableFirstElement([1, 2, 3, 4, 5]); * //=> 1 * ``` */ declare function iterableFirstElement(iterable: Iterable): T | undefined; /** * Interface describing the data yielded by iterateObject for each node in the traversal */ interface IterateObjectYield { /** The parent object containing the current value */ object: object; /** The key or index of the current value in its parent object */ key: string | number; /** The value at the current node */ value: V; /** Array representation of the path to the current node */ propertyPathArray: (string | number)[]; /** Lodash-style property path string (e.g., 'a.b[0].c') */ propertyPath: string | number | symbol | readonly (string | number | symbol)[]; /** Whether this node is a primitive value */ isLeaf: boolean; /** The type of container at this node */ nodeType: 'object' | 'array'; /** Reference to the root object being traversed */ root: T; } /** * Generator that performs a depth-first traversal of an object's structure. * Yields information about each node including its path, value, and container type. * Handles circular references and maintains parent-child relationships. * * Key features: * - Supports both objects and arrays * - Generates Lodash-style property paths * - Detects leaf nodes (primitives) * - Prevents circular reference loops * - Preserves traversal order */ declare function iterateObject(root: T): Generator>; /** * Same as Object.keys except the keys are typed as string keys of T. */ declare function keysOf(obj: T): StringKeyOf[]; /** * Maps over an object's entries, transforming both keys and values using the provided function. */ declare function mapObjectEntries(obj: T, fn: (key: StringKeyOf, value: T[StringKeyOf]) => [K, V]): Record; /** * Maps over an object's keys, transforming each key using the provided function while preserving values. */ declare function mapObjectKeys(obj: T, fn: (key: StringKeyOf, value: T[StringKeyOf]) => K): Record]>; /** * Like Object.assign, but only copies source object property values != null. */ declare const objAssign: (target: Record, ...sources: Record[]) => Record; /** * Deep freezes an object. * * Note: Deep recursion may cause stack overflow for very deeply nested objects. */ declare function objDeepFreeze(o: Record): Record; /** * Defines a lazy property on an object. The property will be lazily evaluated on the first access and then cached for subsequent accesses. * The property is both enumerable and configurable. * * @typeParam T - The type of the object on which the property will be defined. Must be a record with string keys. * @param object - The object on which to define the property. * @param key - The key of the property to define. * @param getValue - A function that returns the value of the property. This function will be called the first time the property is accessed. * @returns The original object with the newly defined property. */ declare function objDefineLazyProperty>(object: T, key: string, getValue: (...args: unknown[]) => unknown): T; /** * Deletes a property from an object and returns the modified object. * @param obj The object from which to delete the property. * @template K - The type of the keys in the object. * @returns The modified object with the key deleted. * @param key The key of the property to delete. * @example ```ts * const obj = { name: 'John', age: 30 }; * objDelete(obj, 'age'); * //=> { name: 'John' } * ``` */ declare function objDelete(obj: Record, key: K): Omit, K>; /** * Retrieves the value associated with the specified key from an object. */ declare function objGet(obj: T, key: K): T[K]; /** * Gets a property value from an object or creates it using a factory function if it doesn't exist. */ declare function objGetOrDefault(object: Record, key: K, factory: (key: K) => V): V; /** * This function attempts to retrieve a value from an object using a provided key. * If the key does not exist in the object, it sets the provided default value in the object and returns it. */ declare function objGetOrDefaultValue(obj: T, key: K, defaultValue: T[K]): T[K]; /** * Checks if an object has a specific key. * @param obj The object to check. * @template K - The type of the keys in the object. * @returns Returns true if the object has the key, false otherwise. * @param key The key to check for. * @example ```ts * const myObj = { name: 'John', age: 30 }; * objHas(myObj, 'name'); * //=> true * objHas(myObj, 'email'); * //=> false * ``` */ declare function objHas(obj: Record, key: PropertyKey): boolean; /** * Deletes the specified keys from an object in a mutable way. * @param obj The object from which to delete the keys. * @returns The modified object with the specified keys deleted. * @typeparam V - The type of the values in the object. * @param keys The keys to delete from the object. * @example ```ts * const obj = { a: 1, b: 2, c: 3 }; * objOmitKeysMutable(obj, 'a', 'c'); * //=> { b: 2 } * ``` */ declare function objOmitKeysMutable>(obj: O, ...keys: PropertyKey[]): O; /** * Converts the specified properties of an object into getter functions. * @template K - The type of the keys of the object. * @template V - The type of the values of the object. * @template T - The type of the object. * @param object The object whose properties are to be converted into getter functions. * @param propertyNames The names of the properties to be converted into getter functions. * @returns The object with the specified properties converted into getter functions. * @throws Throws an error if the property descriptor for a specified property name is not found. * @example ```ts * const obj = { a: 1, b: 2, c: 3 }; * objPropertyValueToGetter(obj, 'a', 'b'); * obj.a; * //=> 1 * obj.b; * //=> 2 * obj.c; * //=> 3 * ``` */ declare function objPropertyValueToGetter>(object: T, ...propertyNames: PropertyKey[]): T; /** * Sets a value for a key in an object and returns the value. */ declare function objSet(obj: T, key: K, value: T[K]): T[K]; /** * Returns the number of enumerable keys in an object. */ declare function objSize(obj: object): number; /** * Sorts the keys of an object in alphabetical order unless a custom compare function is provided. */ declare function objSortKeys(o: T, compare?: (a: [string, ValueOf], b: [string, ValueOf]) => number): T; /** * Converts an object to a Map. */ declare function objToMap(obj: T): Map>; /** * Updates the value of a specific key in an object using a callback function. */ declare function objUpdate>(obj: T, key: keyof T, callback: (value: ValueOf | undefined, key: PropertyKey, obj: T) => V): V; /** * Updates the property descriptors of the specified properties on the given object. * @param object - The object whose property descriptors are to be updated. * @param properties - An array of property names for which the descriptors are to be updated. * @param update - A function that takes a property descriptor and a property name, and returns a new property descriptor. * @throws Will throw an error if any of the specified properties do not exist on the object. * @example ```ts * const obj = { a: 1, b: 2 }; * objUpdatePropertyDescriptors(obj, ['a', 'b'], (descriptor, property) => { * descriptor.writable = true; * return obj; * }); * ``` */ declare function objUpdatePropertyDescriptors(object: Record, properties: PropertyKey[], update: (descriptor: PropertyDescriptor, property: PropertyKey) => PropertyDescriptor): void; /** * Calls Object.prototype.propertyIsEnumerable on the given object. */ declare function propertyIsEnumerable(o: object, key: PropertyKey): boolean; /** * Sets the enumerable property of the specified properties of an object to true. */ declare function setEnumerable(object: T, ...keys: string[]): T; /** * Sets the specified properties of an object as non-configurable. */ declare function setNonConfigurable(object: T, ...properties: string[]): T; /** * Sets the specified properties of an object as non-enumerable. */ declare function setNonEnumerable(object: T, ...properties: string[]): T; /** * Sets the specified properties of an object to be non-writable. */ declare function setNonWritable(object: T, ...properties: string[]): T; /** * Sets the specified properties of an object to be non-writable. */ declare function setWritable(object: T, ...properties: string[]): T; /** * Sort an object's keys. */ declare function sortKeys(obj: T, compareFn?: (a: string, b: string) => number): T; /** * Sorts the keys of an object in the given order. */ declare function sortKeysLike(o: T, orderedKeys: (keyof T)[]): T; /** * Returns the static string-property keys of a class but without the natively built-in keys 'length', 'name', and 'prototype'. */ declare function staticClassKeysOf unknown>(cls: T): StaticClassKeyof[]; /** * Returns the static string-property keys of a class but without the natively built-in keys 'length', 'name', and 'prototype'. */ type StaticClassKeyof unknown> = Exclude; /** * Keys always present in any class object. */ declare const ignoreKeys: readonly ["length", "name", "prototype"]; type IgnoreKey = (typeof ignoreKeys)[number]; /** * Get the values of an object with type-safe return value. */ declare function valuesOf(obj: T): T[StringKeyOf][]; export { type AccessorDescriptor, type AccessorsDescriptorAttributes, type DescriptorAccessors, type DescriptorBothAccessors, type DescriptorGetter, type DescriptorSetter, type DescriptorValue, type GetKeysOptions, type IterateObjectYield, type KeysPrimitiveTypeFrom, type OptsKeyTypeVariants, type OptsKeysVariants, type StaticClassKeyof, type TypedValuePropertyDescriptor, type ValueDescriptor, type ValueDescriptorAttributes, arrAssign, className, constructorOf, createArrayMerger, createObjectMerger, defineAccessors, defineGetter, defineLazyProperty, defineMethod, defineProperty, defineSetter, defineValue, deleteNullishPropsMutable, entriesOf, filterObject, filterObjectMutable, getClassChain, getConfigurableMethodOrGetterKeys, getKeys, getKeysPreset, getOwnProperty, getPrototypeChain, getSuperClass, getSuperClasses, hasOwnProperty, hasProperty, hasPrototypeChainProperty, inheritPrototypeMembers, inheritStaticMembers, isAccessorDescriptor, isEnumerable, isMethodValueDescriptor, isValueDescriptor, iterableFirstElement, iterateObject, keysOf, mapObjectEntries, mapObjectKeys, objAssign, objDeepFreeze, objDefineLazyProperty, objDelete, objGet, objGetOrDefault, objGetOrDefaultValue, objHas, objOmitKeysMutable, objPropertyValueToGetter, objSet, objSize, objSortKeys, objToMap, objUpdate, objUpdatePropertyDescriptors, propertyIsEnumerable, setEnumerable, setNonConfigurable, setNonEnumerable, setNonWritable, setWritable, sortKeys, sortKeysLike, staticClassKeysOf, valuesOf };