Mathias Bynens | 79e2cf0 | 2020-05-29 14:46:17 | [diff] [blame] | 1 | # ccount |
| 2 | |
| 3 | [![Build][build-badge]][build] |
| 4 | [![Coverage][coverage-badge]][coverage] |
| 5 | [![Downloads][downloads-badge]][downloads] |
| 6 | [![Size][size-badge]][size] |
| 7 | |
| 8 | Count characters. |
| 9 | |
| 10 | ## Install |
| 11 | |
| 12 | [npm][]: |
| 13 | |
| 14 | ```sh |
| 15 | npm install ccount |
| 16 | ``` |
| 17 | |
| 18 | ## Use |
| 19 | |
| 20 | ```js |
| 21 | var ccount = require('ccount') |
| 22 | |
| 23 | ccount('foo(bar(baz)', '(') // => 2 |
| 24 | ccount('foo(bar(baz)', ')') // => 1 |
| 25 | ``` |
| 26 | |
| 27 | ## API |
| 28 | |
| 29 | ### `ccount(value, character)` |
| 30 | |
| 31 | Get the total count of `character` in `value`. |
| 32 | |
| 33 | ###### Parameters |
| 34 | |
| 35 | * `value` (`string`) — Content, coerced to string |
| 36 | * `character` (`string`) — Single character to look for |
| 37 | |
| 38 | ###### Returns |
| 39 | |
| 40 | `number` — Number of times `character` occurred in `value`. |
| 41 | |
| 42 | ## License |
| 43 | |
| 44 | [MIT][license] © [Titus Wormer][author] |
| 45 | |
| 46 | <!-- Definitions --> |
| 47 | |
| 48 | [build-badge]: https://img.shields.io/travis/wooorm/ccount.svg |
| 49 | |
| 50 | [build]: https://travis-ci.org/wooorm/ccount |
| 51 | |
| 52 | [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/ccount.svg |
| 53 | |
| 54 | [coverage]: https://codecov.io/github/wooorm/ccount |
| 55 | |
| 56 | [downloads-badge]: https://img.shields.io/npm/dm/ccount.svg |
| 57 | |
| 58 | [downloads]: https://www.npmjs.com/package/ccount |
| 59 | |
| 60 | [size-badge]: https://img.shields.io/bundlephobia/minzip/ccount.svg |
| 61 | |
| 62 | [size]: https://bundlephobia.com/result?p=ccount |
| 63 | |
| 64 | [npm]: https://docs.npmjs.com/cli/install |
| 65 | |
| 66 | [license]: license |
| 67 | |
| 68 | [author]: https://wooorm.com |