Spaces:
Configuration error
Configuration error
Download sessions/node_modules/ccount/index.js from CPISTO/TARSTHENEXT: direct link, hf CLI and curl.
- Browser
- Download file 619 Bytes
-
https://huggingface.co/spaces/CPISTO/TARSTHENEXT/resolve/main/sessions/node_modules/ccount/index.js
- Command line
-
hf download hf://spaces/CPISTO/TARSTHENEXT/sessions/node_modules/ccount/index.js
-
curl -L -o index.js https://huggingface.co/spaces/CPISTO/TARSTHENEXT/resolve/main/sessions/node_modules/ccount/index.js
619 Bytes
| /** | |
| * Count how often a character (or substring) is used in a string. | |
| * | |
| * @param {string} value | |
| * Value to search in. | |
| * @param {string} character | |
| * Character (or substring) to look for. | |
| * @return {number} | |
| * Number of times `character` occurred in `value`. | |
| */ | |
| export function ccount(value, character) { | |
| const source = String(value) | |
| if (typeof character !== 'string') { | |
| throw new TypeError('Expected character') | |
| } | |
| let count = 0 | |
| let index = source.indexOf(character) | |
| while (index !== -1) { | |
| count++ | |
| index = source.indexOf(character, index + character.length) | |
| } | |
| return count | |
| } | |