Files
coopgo/node_modules/ccount/index.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

23 lines
378 B
JavaScript

'use strict'
module.exports = ccount
function ccount(source, character) {
var value = String(source)
var count = 0
var index
if (typeof character !== 'string') {
throw new Error('Expected character')
}
index = value.indexOf(character)
while (index !== -1) {
count++
index = value.indexOf(character, index + character.length)
}
return count
}