ObjectUtils: {
    cloneObject<T>(obj): T;
    deepEqual(obj1, obj2): boolean;
    filterUniqueByProp<T>(objects, prop): T[];
    filterByKeys(obj, keys): Record<string, unknown>;
    findFirstNonZeroIndex(data): number;
    flatten(obj, prefix?): Record<string, unknown>;
    fromMap<T>(map): Record<string, T>;
    getNestedProp<T>(obj, ...path): null | T;
    groupByProp<T>(objects, ...propPath): Record<string, T[]>;
    hasNestedProp(obj, ...path): boolean;
    isEmpty(obj): boolean;
    isFunction(value): value is Function;
    isEqual(obj1, obj2): boolean;
    isEqualOnKeys(obj1, obj2, keys): boolean;
    isObject(value): value is Record<string, unknown>;
    mapByProp<T>(objects, ...propPath): Record<string, T>;
    matchesRules<T>(obj, ruleSet): boolean;
    merge<T>(...objects): T;
    omit<T>(obj, keys): Partial<T>;
    pick<T>(obj, keys): Partial<T>;
    removeNullishValues<T>(obj, noEmptyStrings?): Partial<T>;
    replaceEmptyStringsWithNull(obj, deep?): Record<string, unknown>;
    replaceKey<T>(obj, oldKey, newKey): Record<string, unknown>;
    replaceNullWithEmptyString(obj, fields?): Record<string, unknown>;
    setNestedProp<T>(obj, ...path): null | T;
    sortByProp<T>(__namedParameters): T[];
    toMap<T>(obj): Map<string, T>;
    transform<T>(obj, keyTransform?, valueTransform?): Record<string, unknown>;
} = ...

Type declaration

  • cloneObject:function
    • Creates a deep clone of an object, including nested objects and arrays.

      Type Parameters

      • T

        The type of the object to clone

      Parameters

      • obj: T

        The object to clone

      Returns T

      A deeply cloned copy of the object

      Example

      const original = { user: { name: 'John', hobbies: ['reading'] } };
      const cloned = ObjectUtils.cloneObject(original);
      cloned.user.name = 'Jane'; // Original remains unchanged
  • deepEqual:function
    • Performs a deep equality check between two values, comparing all nested properties.

      Parameters

      • obj1: unknown

        The first value to compare

      • obj2: unknown

        The second value to compare

      Returns boolean

      True if the values are deeply equal, false otherwise

      Example

      ObjectUtils.deepEqual({ a: { b: 1 } }, { a: { b: 1 } }); // Returns true
      ObjectUtils.deepEqual({ a: 1 }, { a: 2 }); // Returns false
      ObjectUtils.deepEqual([1, 2, 3], [1, 2, 3]); // Returns true
  • filterUniqueByProp:function
    • Filters an array of objects to unique values based on a specified property.

      Type Parameters

      • T extends Record<string, unknown>

        The type of objects in the array

      Parameters

      • objects: T[]

        The array of objects to filter

      • prop: keyof T

        The property to use for uniqueness comparison

      Returns T[]

      An array containing only unique objects based on the specified property

      Example

      const users = [
      { id: 1, name: 'John' },
      { id: 2, name: 'Jane' },
      { id: 1, name: 'John Doe' }
      ];
      ObjectUtils.filterUniqueByProp(users, 'id'); // Returns first two objects
  • filterByKeys:function
    • Filters an object to only include the specified keys.

      Parameters

      • obj: Record<string, unknown>

        The object to filter

      • keys: string[]

        An array of keys to include in the filtered object

      Returns Record<string, unknown>

      A new object containing only the specified keys

      Example

      const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
      ObjectUtils.filterByKeys(user, ['id', 'name']); // Returns { id: 1, name: 'John' }
  • findFirstNonZeroIndex:function
    • Finds the index of the first non-zero value in an object of numbers.

      Parameters

      • data: Record<string, number>

        An object containing numeric values

      Returns number

      The index of the first non-zero value, or -1 if all values are zero

      Example

      ObjectUtils.findFirstNonZeroIndex({ a: 0, b: 0, c: 5, d: 2 }); // Returns 2
      ObjectUtils.findFirstNonZeroIndex({ a: 0, b: 0 }); // Returns -1
  • flatten:function
    • Flattens a nested object into a single-level object with dot-notation keys.

      Parameters

      • obj: Record<string, unknown>

        The object to flatten

      • prefix: string = ""

        The prefix to use for nested keys (default: empty string)

      Returns Record<string, unknown>

      A flattened object with dot-notation keys

      Example

      const nested = { user: { profile: { name: 'John', age: 30 } } };
      ObjectUtils.flatten(nested);
      // Returns { 'user.profile.name': 'John', 'user.profile.age': 30 }
  • fromMap:function
    • Converts a Map to a plain object

      Type Parameters

      • T

      Parameters

      • map: Map<string, T> | Record<string, T>

        Map to convert

      Returns Record<string, T>

      Plain object

  • getNestedProp:function
    • Gets a nested property from an object

      Type Parameters

      • T

      Parameters

      • obj: Record<string, unknown>

        Object to get property from

      • Rest ...path: string[]

        Path to property

      Returns null | T

      Property value or null if not found

  • groupByProp:function
    • Groups objects by a property value

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • objects: T[]

        Array of objects to group

      • Rest ...propPath: string[]

        Path to property to group by

      Returns Record<string, T[]>

      Object with grouped arrays

  • hasNestedProp:function
    • Checks if an object has a nested property

      Parameters

      • obj: Record<string, unknown>

        Object to check

      • Rest ...path: string[]

        Path to property

      Returns boolean

      True if property exists

  • isEmpty:function
    • Checks if an object is empty

      Parameters

      • obj: unknown

        Object to check

      Returns boolean

      True if object is empty

  • isFunction:function
    • Checks if a value is a function

      Parameters

      • value: unknown

        Value to check

      Returns value is Function

      True if value is a function

  • isEqual:function
    • Checks if two objects are equal using JSON stringification

      Parameters

      • obj1: unknown

        First object to compare

      • obj2: unknown

        Second object to compare

      Returns boolean

      True if objects are equal

  • isEqualOnKeys:function
    • Compares objects based on specified keys

      Parameters

      • obj1: Record<string, unknown>

        First object to compare

      • obj2: Record<string, unknown>

        Second object to compare

      • keys: string[]

        Array of keys to compare

      Returns boolean

      True if objects are equal on specified keys

  • isObject:function
    • Checks if a value is an object

      Parameters

      • value: unknown

        Value to check

      Returns value is Record<string, unknown>

      True if value is an object

  • mapByProp:function
    • Maps objects by a property value

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • objects: T[]

        Array of objects to map

      • Rest ...propPath: string[]

        Path to property to map by

      Returns Record<string, T>

      Object with mapped values

  • matchesRules:function
    • Checks if an object conforms to a set of rules

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to check

      • ruleSet: Record<keyof T, ((value) => boolean)>

        Object containing validation functions

      Returns boolean

      True if object conforms to all rules

  • merge:function
    • Deep merges two or more objects

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • Rest ...objects: T[]

        Objects to merge

      Returns T

      Merged object

  • omit:function
    • Creates a new object with specified keys omitted

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to omit keys from

      • keys: string[]

        Keys to omit

      Returns Partial<T>

      New object without specified keys

  • pick:function
    • Creates a new object with only the specified keys

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to pick from

      • keys: string[]

        Keys to pick

      Returns Partial<T>

      New object with only specified keys

  • removeNullishValues:function
    • Removes null, undefined, and optionally empty string values from an object

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to clean

      • noEmptyStrings: boolean = false

        Whether to remove empty strings

      Returns Partial<T>

      Cleaned object

  • replaceEmptyStringsWithNull:function
    • Replaces empty strings with null in an object

      Parameters

      • obj: Record<string, unknown>

        Object to process

      • deep: boolean = false

        Whether to process nested objects

      Returns Record<string, unknown>

      Processed object

  • replaceKey:function
    • Replaces a key in an object

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to modify

      • oldKey: keyof T

        Key to replace

      • newKey: string

        New key name

      Returns Record<string, unknown>

      New object with replaced key

  • replaceNullWithEmptyString:function
    • Replaces null values with empty strings in an object

      Parameters

      • obj: Record<string, unknown>

        Object to process

      • Optional fields: string[]

        Optional array of fields to process

      Returns Record<string, unknown>

      Processed object

  • setNestedProp:function
    • Sets a nested property in an object

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to modify

      • Rest ...path: [...string[], unknown]

        Path to property

      Returns null | T

      New object with set property

  • sortByProp:function
    • Sorts an array of objects by a property

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • __namedParameters: {
            objects: T[];
            prop: keyof T;
            direction?: "asc" | "desc";
        }
        • objects: T[]
        • prop: keyof T
        • Optional direction?: "asc" | "desc"

      Returns T[]

      Sorted array

  • toMap:function
    • Converts an object to a Map

      Type Parameters

      • T

      Parameters

      • obj: Record<string, T>

        Object to convert

      Returns Map<string, T>

      Map

  • transform:function
    • Transforms an object's keys and/or values

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • obj: T

        Object to transform

      • Optional keyTransform: ((key) => string)

        Function to transform keys

          • (key): string
          • Parameters

            • key: string

            Returns string

      • Optional valueTransform: ((value) => unknown)

        Function to transform values

          • (value): unknown
          • Parameters

            • value: unknown

            Returns unknown

      Returns Record<string, unknown>

      Transformed object