UNPKG

946 BSource Map (JSON)View Raw
1{"version":3,"sources":["iterable/count.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CACnB,MAAmB,EACnB,YAAmC,GAAG,EAAE,CAAC,IAAI;IAE7C,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;YACnB,CAAC,EAAE,CAAC;SACL;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC","file":"count.js","sourcesContent":["/**\n * Returns a number that represents how many elements in the specified sequence satisfy a condition if present,\n * else the number of items in the collection.\n * @param {Iterable<T>} source A sequence that contains elements to be tested and counted.\n * @param {function(value: T): boolean} [predicate] A function to test each element for a condition.\n */\nexport function count<T>(\n source: Iterable<T>,\n predicate: (value: T) => boolean = () => true\n): number {\n let i = 0;\n\n for (const item of source) {\n if (predicate(item)) {\n i++;\n }\n }\n\n return i;\n}\n"]}
\No newline at end of file