predictype

predictype v0.8.1


predictype / predicates/sets/setRelation / setRelation

Function: setRelation()

setRelation<T>(source, oper, target): boolean

Defined in: predicates/sets/setRelation.ts:32

Checks the relation between two sets (disjoint, intersects, subset, superset) using the specified operation.

Type Parameters

T

T

Parameters

source

Set<T>

The first set.

oper

SetRelationOper

The relation operation to perform (e.g. ‘disjoint’, ‘subset_of’).

target

Set<T>

The second set.

Returns

boolean

True if the relation check is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

const a = new Set([1, 2]);
const b = new Set([2, 3]);
const c = new Set([4, 5]);

setRelation(a, 'intersects', b); // true
setRelation(a, 'disjoint', c); // true
setRelation(a, 'subset_of', b); // true
setRelation(a, 'superset_of', b); // false

Remarks

Supported Operators: