UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

21 lines (19 loc) 522 B
import { identityAsync } from '../util/identity'; export async function min(source, selector = identityAsync) { let atleastOnce = false; let value = Infinity; for await (const item of source) { if (!atleastOnce) { atleastOnce = true; } const x = await selector(item); if (x < value) { value = x; } } if (!atleastOnce) { throw new Error('Sequence contains no elements'); } return value; } //# sourceMappingURL=min.mjs.map