Function firstNotNullishOf
- first
Not <T, O>(array, selector): NonNullable<O> | undefinedNullish Of Type Parameters
Parameters
Returns NonNullable<O> | undefined
The first non-
nulland non-undefinedvalue produced by the selector function, orundefinedif no such value is produced.Example: Basic usage
import { firstNotNullishOf } from "@std/collections/first-not-nullish-of";
import { assertEquals } from "@std/assert";
const tables = [
{ number: 11, order: null },
{ number: 12, order: "Soup" },
{ number: 13, order: "Salad" },
];
const nextOrder = firstNotNullishOf(tables, (table) => table.order);
assertEquals(nextOrder, "Soup");
Applies the given selector to elements in the given array until a value is produced that is neither
nullnorundefinedand returns that value. Returnsundefinedif no such value is produced.