predictype

predictype v0.8.1


predictype / predicates/sets / setSize

Function: setSize()

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

Defined in: predicates/sets/setSize.ts:27

Checks the size of a set using the specified operation.

Type Parameters

T

T

Parameters

source

Set<T>

The set to check.

oper

SetSizeOper

The size operation to perform (e.g. ‘size_equals’, ‘size_greater_than’).

target

number

The size to compare against.

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const a = new Set([1, 2, 3]);

setSize(a, 'size_equals', 3); // true
setSize(a, 'size_greater_than', 2); // true

Remarks

Supported Operators: