VDL Plugin SDK

every

Import from @varavel/vdl-plugin-sdk/utils/sets.

function every<T>(set, doesMatch): boolean;

Tests whether all elements in a Set satisfy the provided predicate function.

This function iterates through all elements of the Set and checks if the predicate function returns true for every element. It returns true if the predicate is satisfied for all elements, and false otherwise.

Type Parameters

Type ParameterDescription
TThe type of elements in the Set.

Parameters

ParameterTypeDescription
setSet<T>The Set to test.
doesMatch(value, value2, set) => booleanA predicate function that tests each element.

Returns

boolean

true if all elements satisfy the predicate, false otherwise.

Example

const set = new Set([10, 20, 30]);
const result = every(set, (value) => value > 5);
// result will be: true

const result2 = every(set, (value) => value > 15);
// result2 will be: false