@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 min(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 min = n.value;
while (!(n = i.next()).done) {
if (n.value < min)
min = n.value;
}
return min;
}
export { min as default };
//# sourceMappingURL=min.js.map