Const
Returns the unique element that satisfies the optional predicate, or undefined when no match is found.
undefined
Curried version of _singleOrDefault.
Element type produced by the source iterable.
Predicate receiving each element and its index; the matching element must be unique when provided.
The sole element accepted by pred, or undefined when no element matches.
pred
Error Thrown when more than one element satisfies pred.
Error Rethrows any error thrown by pred.
const value = _singleOrDefault([1, 2, 3], (item) => item > 3);console.log(value); // undefined Copy
const value = _singleOrDefault([1, 2, 3], (item) => item > 3);console.log(value); // undefined
or using the curried version:
const value = pipeInto( [1, 2, 3], singleOrDefault((item) => item > 3));console.log(value); // undefined Copy
const value = pipeInto( [1, 2, 3], singleOrDefault((item) => item > 3));console.log(value); // undefined
Returns the unique element that satisfies the optional predicate, or
undefinedwhen no match is found.Curried version of _singleOrDefault.