diff options
Diffstat (limited to 'assets/node_modules/ccount/index.js')
-rw-r--r-- | assets/node_modules/ccount/index.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/assets/node_modules/ccount/index.js b/assets/node_modules/ccount/index.js new file mode 100644 index 0000000..3051998 --- /dev/null +++ b/assets/node_modules/ccount/index.js @@ -0,0 +1,22 @@ +'use strict' + +module.exports = ccount + +function ccount(value, character) { + var val = String(value) + var count = 0 + var index + + if (typeof character !== 'string' || character.length !== 1) { + throw new Error('Expected character') + } + + index = val.indexOf(character) + + while (index !== -1) { + count++ + index = val.indexOf(character, index + 1) + } + + return count +} |