DRAFT: implement sequence
This commit is contained in:
8
src/sequence/first.ts
Normal file
8
src/sequence/first.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user