predictype / predicates/arrays/arrayRelation / arrayRelation
arrayRelation<
T
>(source
,oper
,target
):boolean
Defined in: predicates/arrays/arrayRelation.ts:34
Checks if the source array is a subset, strict subset, superset, or strict superset of the target array, using the specified operation.
T
Type of the array elements.
T
[]
The source array.
The relation operation to perform (‘subset_of’, ‘superset_of’, ‘strict_subset_of’, ‘strict_superset_of’).
T
[]
The target array to check against the source.
boolean
True if the relation check is valid according to the operator, otherwise false.
If the operation is not recognized.
arrayRelation([1, 2], 'subset_of', [1, 2, 3]); // true
arrayRelation([1, 2], 'subset_of', [1, 2]); // true (equality allowed)
arrayRelation([1, 2, 3], 'superset_of', [2, 3]); // true
arrayRelation([1, 2], 'superset_of', [1, 2]); // true (equality allowed)
arrayRelation([1, 2], 'strict_subset_of', [1, 2, 3]); // true
arrayRelation([1, 2], 'strict_subset_of', [1, 2]); // false (equality not allowed)
arrayRelation([1, 2, 3], 'strict_superset_of', [2, 3]); // true
arrayRelation([1, 2], 'strict_superset_of', [1, 2]); // false (equality not allowed)
Supported Operators: