UNPKG

2.13 kBSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/sum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAsB5C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CAAC,MAAqB,EAAE,OAA0B;IACnE,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAClF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,KAAK,IAAI,QAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;KACxC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","file":"sum.js","sourcesContent":["import { identity } from '../util/identity';\nimport { MathOptions } from './mathoptions';\n\n/**\n * Computes the sum of a sequence of values.\n *\n * @export\n * @param {AsyncIterable<number>} source A sequence of values to calculate the sum.\n * @param {MathOptions<number>} [options] Optional options for providing a selector, thisArg and abort signal.\n * @returns {Promise<number>} A promise containing the sum of the sequence of values.\n */\nexport function sum(source: Iterable<number>, options?: MathOptions<number>): number;\n/**\n * Computes the sum of a sequence of values.\n *\n * @export\n * @template T The type of values in the source sequence.\n * @param {Iterable<T>} source A sequence of values to calculate the sum.\n * @param {MathOptions<T>} [options] Optional options for providing a selector, thisArg and abort signal.\n * @returns {Promise<number>} A promise containing the sum of the sequence of values.\n */\nexport function sum<T>(source: Iterable<T>, options?: MathOptions<T>): number;\n/**\n * Computes the sum of a sequence of values.\n *\n * @export\n * @param {Iterable<any>} source A sequence of values to calculate the sum.\n * @param {MathOptions<any>} [options] Optional options for providing a selector, thisArg and abort signal.\n * @returns {Promise<number>} A promise containing the sum of the sequence of values.\n */\nexport function sum(source: Iterable<any>, options?: MathOptions<any>): number {\n const { ['selector']: selector = identity, ['thisArg']: thisArg } = options || {};\n let value = 0;\n for (const item of source) {\n value += selector!.call(thisArg, item);\n }\n\n return value;\n}\n"]}
\No newline at end of file