UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

21 lines (19 loc) 523 B
import { identityAsync } from '../util/identity'; export async function max(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=max.mjs.map