UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

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