9 lines
226 B
TypeScript
9 lines
226 B
TypeScript
import {error} from "../util/error.js";
|
|
|
|
export function first<T>(value: Iterable<T>, predicate?: (it: T) => boolean): T {
|
|
for (const it of value) {
|
|
if (!predicate || predicate(it)) return it;
|
|
}
|
|
error();
|
|
}
|