@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.
21 lines (18 loc) • 477 B
JavaScript
import { ArgumentNullException } from '@tsdotnet/exceptions';
function sumAndCount(sequence) {
if (!sequence)
throw new ArgumentNullException('sequence');
let sum = 0, count = 0;
for (const s of sequence) {
if (isNaN(s))
return { value: NaN, count: NaN };
sum += s;
count++;
}
return {
value: sum,
count: count
};
}
export { sumAndCount as default };
//# sourceMappingURL=sumAndCount.js.map