UNPKG

736 BSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/sum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,MAAM,UAAU,GAAG,CAAC,MAAqB,EAAE,KAAyB,QAAQ;IAC1E,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;KACnB;IAED,OAAO,KAAK,CAAC;AACf,CAAC","file":"sum.js","sourcesContent":["import { identity } from '../util/identity';\n\nexport function sum(source: Iterable<number>, fn?: (x: number) => number): number;\nexport function sum<T>(source: Iterable<T>, fn: (x: T) => number): number;\nexport function sum(source: Iterable<any>, fn: (x: any) => number = identity): number {\n let value = 0;\n for (const item of source) {\n value += fn(item);\n }\n\n return value;\n}\n"]}
\No newline at end of file