1 | /**
|
2 | * Returns a number that represents how many elements in the specified sequence satisfy a condition if present,
|
3 | * else the number of items in the collection.
|
4 | * @param {Iterable<T>} source A sequence that contains elements to be tested and counted.
|
5 | * @param {function(value: T): boolean} [predicate] A function to test each element for a condition.
|
6 | */
|
7 | export function count(source, predicate = () => true) {
|
8 | let i = 0;
|
9 | for (const item of source) {
|
10 | if (predicate(item)) {
|
11 | i++;
|
12 | }
|
13 | }
|
14 | return i;
|
15 | }
|
16 |
|
17 | //# sourceMappingURL=count.mjs.map
|