Skip to main content

core.diffany

Home > @medplum/core > diffAny

diffAny() function

diffAny() returns an empty array if input and output are materially equal (i.e., would produce equivalent JSON); otherwise it produces an array of patches that would transform input into output.

Here, "equal" means that the value at the target location and the value conveyed by "value" are of the same JSON type, and that they are considered equal by the following rules for that type: o strings: are considered equal if they contain the same number of Unicode characters and their code points are byte-by-byte equal. o numbers: are considered equal if their values are numerically equal. o arrays: are considered equal if they contain the same number of values, and if each value can be considered equal to the value at the corresponding position in the other array, using this list of type-specific rules. o objects: are considered equal if they contain the same number of members, and if each member can be considered equal to a member in the other object, by comparing their keys (as strings) and their values (using this list of type-specific rules). o literals (false, true, and null): are considered equal if they are the same.

Signature:

export declare function diffAny(input: any, output: any, ptr: Pointer, diff?: Diff): Operation[];

Parameters

Parameter

Type

Description

input

any

The original value.

output

any

The target value.

ptr

Pointer

JSON Pointer.

diff

Diff

(Optional) Diff function.

Returns:

Operation

The list of operations to get form the original to target value.