Skip to content

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 Parameter Description
K The type of keys in the Map.
V The type of values in the Map.

Parameters

Parameter Type Description
map Map\<K, V> The Map to test.
doesMatch (value, key, map) => boolean A 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