Skip to main content
Module

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

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

Returns the first element in the iterable, or the given default value if the iterable was empty.

Parameters

defaultValue: TElement

The value to use of the iterable was empty.

Returns

TElement

The first element in the iterable, or the default value if empty.

Returns the first element in the iterable, or the given default value if the iterable was empty.

Parameters

defaultValue: TDefault

The value to use of the iterable was empty.

Returns

TElement | TDefault

The first element in the iterable, or the default value if empty.

Returns the first element in the iterable that satisfies the condition, or the given default value.

Parameters

defaultValue: TElement

The value to use if no element satisfied the condition.

predicate: BoolPredicate<TElement>

The predicate to test each element with.

Returns

TElement

The first element in the iterable that satisfies the condition, or the default value if none satisfied it.

Returns the first element in the iterable that satisfies the condition, or the given default value.

Parameters

defaultValue: TDefault

The value to use if no element satisfied the condition.

predicate: BoolPredicate<TElement>

The predicate to test each element with.

Returns

TElement | TDefault

The first element in the iterable that satisfies the condition, or the default value if none satisfied it.