Skip to main content
Module

x/lazy/lib/lazy.ts>Lazy#singleOrDefault

A linq-like lazy-evaluation enumerable/iteration library that aims to support deno, node & browser
Latest
method Lazy.prototype.singleOrDefault
import { Lazy } from "https://deno.land/x/lazy@v1.7.3/lib/lazy.ts";

Returns a single element from the iterable that matches the given condition, or a default value if no element was found.

Parameters

predicate: BoolPredicate<TElement>

The predicate function to test each element with.

defaultValue: TElement

The default value to use if no element could be found.

Returns

TElement

The element that satisfies the condition, or the default value if no element was found.

Returns a single element from the iterable that matches the given condition, or a default value if no element was found.

Parameters

predicate: BoolPredicate<TElement>

The predicate function to test each element with.

defaultValue: TDefault

The default value to use if no element could be found.

Returns

TElement | TDefault

The element that satisfies the condition, or the default value if no element was found.