Skip to main content

hasOneOrMore

Verifies that one or more items of an array, collection or enumerable object pass the truth function.

Signature

hasOneOrMore<T>(
list: TList<T> | undefined,
fn: (item: T) => boolean
): boolean

Parameters

NameTypeOptionalDescription
listT[] | undefinedNoSpecifies the array, collection or enumerable object to iterate through.
fn(item: T) => booleanNoSpecifies the truth function. Each item is supplied to the function, passing the item as argument. The function should return a boolean value with the individual verification result.

Return value

Returns true when one or more items pass the verification test.

Example

import { hasOneOrMore } from "@tripetto/runner";

hasOneOrMore<number>([1, 2, 3], (nItem: number) => nItem > 2); // Returns `true`
hasOneOrMore<number>([1, 2, 3], (nItem: number) => nItem > 3); // Returns `false`