1 | ;
|
2 | import { identityAsync } from '../internal/identity';
|
3 | export async function min(source, selector = identityAsync) {
|
4 | let atleastOnce = false;
|
5 | let value = Infinity;
|
6 | for await (let item of source) {
|
7 | if (!atleastOnce) {
|
8 | atleastOnce = true;
|
9 | }
|
10 | let x = await selector(item);
|
11 | if (x < value) {
|
12 | value = x;
|
13 | }
|
14 | }
|
15 | if (!atleastOnce) {
|
16 | throw new Error('Sequence contains no elements');
|
17 | }
|
18 | return value;
|
19 | }
|
20 |
|
21 | //# sourceMappingURL=min.mjs.map
|