@tsdotnet/linq
Version:
A familiar set of functions that operate on JavaScript iterables (ES2015+) in a similar way to .NET's LINQ does with enumerables.
20 lines (17 loc) • 578 B
JavaScript
import { ArgumentNullException, InvalidOperationException } from '@tsdotnet/exceptions';
function max(sequence) {
if (!sequence)
throw new ArgumentNullException('sequence');
const i = sequence[Symbol.iterator]();
let n = i.next();
if (n.done)
throw new InvalidOperationException('Sequence is empty. Use defaultIfEmpty to ensure a default value.');
let max = n.value;
while (!(n = i.next()).done) {
if (n.value > max)
max = n.value;
}
return max;
}
export { max as default };
//# sourceMappingURL=max.js.map