typedash
Version:
modern, type-safe collection of utility functions
17 lines (15 loc) • 598 B
JavaScript
import { t as filter } from "./filterIterable-CyAWwYFe.js";
//#region src/functions/single/single.ts
/**
* Implementation for all overloads.
* @param source The iterable to search.
* @param predicate The predicate function used to determine if an element is a match.
* @returns The single matching element, or undefined if there are zero or multiple matches.
*/
function single(source, predicate) {
const relevantItems = filter(source, predicate);
return relevantItems?.length === 1 ? relevantItems[0] : void 0;
}
//#endregion
export { single as t };
//# sourceMappingURL=single-BNWR-MVp.js.map