@terascope/utils / equality
equality
Functions
isDeepEqual()
isDeepEqual(target, input)
isDeepEqual<
T
>(target
,input
):input is T
Compares two values and returns a boolean if they are the same. Arrays are compared using original sorting, while object key ordering doesn't matter.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
input | unknown |
Returns
input is T
Example
isDeepEqual({ key1: 1, key2: 2 }, { key2: 2, key1: 1 }) === true;
isDeepEqual(null, null) === true;
isDeepEqual(undefined, undefined) === true;
isDeepEqual(NaN, NaN) === true;
isDeepEqual(3, 3) === true
isDeepEqual('hello', 'hello') === true
isDeepEqual([1, 2, 3], [1, 2, 3]) === true
isDeepEqual([{ some: 'obj' }], [{ some: 'obj' }]) === true
isDeepEqual(undefined, null) === false;
isDeepEqual([1, 2, 3], [1, 3, 2]) === false
isDeepEqual([1, 2, 3], [1, 2, undefined, 3]) === false
isDeepEqual(true, 'true') === false;
Source
packages/utils/src/equality.ts:45
isDeepEqual(target, input)
isDeepEqual<
T
>(target
,input
):boolean
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
input | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:46
isDeepEqualFP()
isDeepEqualFP(target)
isDeepEqualFP<
T
>(target
): (input
) =>input is T
A functional version of isDeepEqual
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
input is T
Source
packages/utils/src/equality.ts:69
isDeepEqualFP(target)
isDeepEqualFP<
T
>(target
): (input
) =>boolean
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:70
isEqual()
isEqual(target, input)
isEqual<
T
>(target
,input
):input is T
Verify that two values are the same (uses a reference check). Similar to === except two NaNs is considered the same For deep equality use isDeepEqual
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
input | unknown |
Returns
input is T
Source
packages/utils/src/equality.ts:10
isEqual(target, input)
isEqual<
T
>(target
,input
):boolean
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
input | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:11
isEqualFP()
isEqualFP(target)
isEqualFP<
T
>(target
): (input
) =>input is T
A functional version of isEqual
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
input is T
Source
packages/utils/src/equality.ts:19
isEqualFP(target)
isEqualFP<
T
>(target
): (input
) =>boolean
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
Returns
Function
Parameters
Parameter | Type |
---|---|
input | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:20
isGreaterThan()
isGreaterThan(
value
,other
):boolean
Check if a value is greater than another
Parameters
Parameter | Type |
---|---|
value | unknown |
other | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:122
isGreaterThanFP()
isGreaterThanFP(
other
): (value
) =>boolean
Check if a value is greater than or equal to another
Parameters
Parameter | Type |
---|---|
other | unknown |
Returns
Function
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:131
isGreaterThanOrEqualTo()
isGreaterThanOrEqualTo(
value
,other
):boolean
Check if a value is greater than or equal to another
Parameters
Parameter | Type |
---|---|
value | unknown |
other | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:102
isGreaterThanOrEqualToFP()
isGreaterThanOrEqualToFP(
other
): (value
) =>boolean
Check if a value is greater than or equal to another
Parameters
Parameter | Type |
---|---|
other | unknown |
Returns
Function
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:111
isLessThan()
isLessThan(
value
,other
):boolean
Check if a value is less than another
Parameters
Parameter | Type |
---|---|
value | unknown |
other | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:162
isLessThanFP()
isLessThanFP(
other
): (value
) =>boolean
Check if a value is greater than or equal to another
Parameters
Parameter | Type |
---|---|
other | unknown |
Returns
Function
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:171
isLessThanOrEqualTo()
isLessThanOrEqualTo(
value
,other
):boolean
Check if a value is less than or equal to another
Parameters
Parameter | Type |
---|---|
value | unknown |
other | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:142
isLessThanOrEqualToFP()
isLessThanOrEqualToFP(
other
): (value
) =>boolean
Check if a value is less than or equal to another
Parameters
Parameter | Type |
---|---|
other | unknown |
Returns
Function
Parameters
Parameter | Type |
---|---|
value | unknown |
Returns
boolean
Source
packages/utils/src/equality.ts:151
isSame()
isSame(target, input)
isSame<
T
>(target
,input
):input is T
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
input | unknown |
Returns
input is T
Deprecated
use isDeepEqual instead
Source
packages/utils/src/equality.ts:78
isSame(target, input)
isSame<
T
>(target
,input
):boolean
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
target | T |
input | unknown |
Returns
boolean
Deprecated
use isDeepEqual instead