DieselDepot-APP/node_modules/es-toolkit/dist/set/every.mjs
SJCoetz def597c157 chore: add generated build artifacts and node module type files
add all Next.js build outputs and third-party dependency type declaration files
2026-07-20 01:18:42 +02:00

27 lines
917 B
JavaScript

//#region src/set/every.ts
/**
* 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.
*
* @template T - The type of elements in the Set.
* @param set - The Set to test.
* @param doesMatch - A predicate function that tests each element.
* @returns 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
*/
function every(set, doesMatch) {
for (const value of set) if (!doesMatch(value, value, set)) return false;
return true;
}
//#endregion
export { every };