UNPKG

object-deep-compare

Version:

A type-safe collection of comparison methods for objects and arrays in TypeScript/JavaScript

38 lines (37 loc) 2.21 kB
import { ComparisonOptions, TypeSafeComparisonOptions, TypedComparisonResult, TypedDetailedDifference } from '../types'; /** * Type-safe comparison of arrays that includes type information * * @param firstArray - First array to compare * @param secondArray - Second array to compare * @param options - Optional comparison options (strict, circularReferences) * @returns Object with isEqual flag and type information */ export declare const TypeSafeCompareArrays: <T extends unknown[], U extends unknown[]>(firstArray: T, secondArray: U, options?: ComparisonOptions) => TypedComparisonResult<T, U>; /** * Maps properties between objects with different structures * * @param sourceObject - Source object * @param propertyMapping - Mapping from source properties to target properties * @returns A new object with mapped properties */ export declare const MapObjectProperties: <T extends Record<string, unknown>, U extends Record<string, unknown>>(sourceObject: T, propertyMapping: Partial<Record<keyof T, keyof U>>) => Partial<U>; /** * Type-safe version of object comparison that supports objects with different structures * * @param firstObject - First object to compare * @param secondObject - Second object to compare * @param options - Type-safe comparison options * @returns Object with isEqual flag and type information */ export declare const TypeSafeCompareObjects: <T extends Record<string, unknown>, U extends Record<string, unknown>>(firstObject: T | null | undefined, secondObject: U | null | undefined, options?: TypeSafeComparisonOptions<T, U>) => TypedComparisonResult<T, U>; /** * Type-safe version of detailed comparison that supports objects with different structures * and provides type information * * @param firstObject - First object to compare * @param secondObject - Second object to compare * @param options - Type-safe comparison options * @returns Array of typed detailed differences with type information */ export declare const TypeSafeCompareValuesWithDetailedDifferences: <T extends Record<string, unknown>, U extends Record<string, unknown>>(firstObject: T, secondObject: U, options?: TypeSafeComparisonOptions<T, U>) => TypedDetailedDifference[];