VDL Plugin SDK

every

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

function every<K, V>(map, doesMatch): boolean;

Tests whether all entries in a Map satisfy the provided predicate function.

This function iterates through all entries of the Map and checks if the predicate function returns true for every entry. It returns true if the predicate is satisfied for all entries, and false otherwise.

Type Parameters

Type ParameterDescription
KThe type of keys in the Map.
VThe type of values in the Map.

Parameters

ParameterTypeDescription
mapMap<K, V>The Map to test.
doesMatch(value, key, map) => booleanA predicate function that tests each entry.

Returns

boolean

true if all entries satisfy the predicate, false otherwise.

Example

const map = new Map([
  ['a', 10],
  ['b', 20],
  ['c', 30]
]);
const result = every(map, (value) => value > 5);
// result will be: true

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