some
Import from @varavel/vdl-plugin-sdk/utils/sets.
function some<T>(set, doesMatch): boolean;
Tests whether at least one element in a Set satisfies the provided predicate function.
This function iterates through the elements of the Set and checks if the predicate function returns true for at least one element. It returns true if any element satisfies the predicate, and false otherwise.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of elements in the Set. |
Parameters
| Parameter | Type | Description |
|---|---|---|
set | Set<T> | The Set to test. |
doesMatch | (value, value2, set) => boolean | A predicate function that tests each element. |
Returns
boolean
true if at least one element satisfies the predicate, false otherwise.
Example
const set = new Set([1, 2, 3]);
const result = some(set, (value) => value > 2);
// result will be: true
const result2 = some(set, (value) => value > 5);
// result2 will be: false