1 | Counts values which satisfy a test.
|
2 | [:package:](https://www.npmjs.com/package/@extra-array/count)
|
3 | [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
|
4 | [:running:](https://npm.runkit.com/@extra-array/count)
|
5 | [:vhs:](https://asciinema.org/a/332033)
|
6 | [:moon:](https://www.npmjs.com/package/@extra-array/count.min)
|
7 | [:scroll:](https://unpkg.com/@extra-array/count/)
|
8 | [:newspaper:](https://nodef.github.io/extra-array/)
|
9 | [:blue_book:](https://github.com/nodef/extra-array/wiki/)
|
10 |
|
11 | > Alternatives: [count], [countAs].<br>
|
12 | > Similar: [count], [partition].
|
13 |
|
14 | > This is part of package [extra-array].
|
15 |
|
16 | [extra-array]: https://www.npmjs.com/package/extra-array
|
17 |
|
18 | <br>
|
19 |
|
20 | ```javascript
|
21 | array.count(x, ft);
|
22 | // x: an array
|
23 | // ft: test function (v, i, x)
|
24 | ```
|
25 |
|
26 | ```javascript
|
27 | const array = require("extra-array");
|
28 |
|
29 | var x = [1, 1, 2, 2, 4];
|
30 | array.count(x, v => v % 2 === 1);
|
31 | // 2
|
32 |
|
33 | array.count(x, v => v % 2 === 0);
|
34 | // 3
|
35 | ```
|
36 |
|
37 | <br>
|
38 | <br>
|
39 |
|
40 |
|
41 | ## References
|
42 |
|
43 | - [List-Extra.count: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#count)
|
44 | - [_.countBy: lodash](https://lodash.com/docs/4.17.15#countBy)
|
45 | - [Array.count: sugarjs](https://sugarjs.com/docs/#/Array/count)
|
46 | - [count-iterable-values: @zeke](https://www.npmjs.com/package/count-iterable-values)
|
47 |
|
48 | [count]: https://github.com/nodef/extra-array/wiki/count
|
49 | [countAs]: https://github.com/nodef/extra-array/wiki/countAs
|
50 | [partition]: https://github.com/nodef/extra-array/wiki/partition
|