Sha256: bc1fdf7b7896107dcd0cdb226c70fe056c5a863c927b2debdeaf294da97b5571

Contents?: true

Size: 381 Bytes

Versions: 23

Compression:

Stored size: 381 Bytes

Contents

'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
}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-4.1.7 node_modules/ccount/index.js
trusty-cms-4.1.6 node_modules/ccount/index.js
trusty-cms-4.1.5 node_modules/ccount/index.js