sum
sum() function
Adds all the elements of a Iterable/AsyncIterable.
Signature:declare function sum<A extends Iterable<number> | AsyncIterable<number>>(iterable: A): A extends Iterable<number> ? number : A extends AsyncIterable<number> ? Promise<number> : never;
Example
sum([]); // 0
sum([1, 2, 3, 4]); // 10
await sum(toAsync([1, 2, 3, 4])); // 10