UNPKG

@winglet/json

Version:

TypeScript library for safe and efficient JSON data manipulation with RFC 6901 (JSON Pointer) and RFC 6902 (JSON Patch) compliance, featuring prototype pollution protection and immutable operations

27 lines (26 loc) 1.4 kB
import type { JsonRoot } from '../../../../type'; import { type Patch } from '../type'; /** * Recursively compares two objects/arrays and populates the fetches array with difference operations. * * This is the internal implementation that performs the actual deep comparison logic. * It handles: * - Early return for identical references * - Automatic serialization of objects with toJson() method * - Recursive comparison of nested objects/arrays * - Generation of appropriate operations based on property changes * - Proper JSON Pointer path construction for nested properties * * @template Source - The type of the source object/array * @template Target - The type of the target object/array * * @param source - The source object or array being compared * @param target - The target object or array being compared * @param fetches - The array to populate with difference operations (modified in-place) * @param path - The current JSON Pointer path (default: '') used for nested property paths * @param strict - Whether to use strict comparison * @param immutable - Whether to use immutable comparison * * @internal This function is for internal use by the compare function */ export declare const compareRecursive: <Source extends JsonRoot, Target extends JsonRoot>(source: Source, target: Target, patches: Patch[], path: string, strict: boolean, immutable: boolean) => void;