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-5.0.7 node_modules/ccount/index.js
trusty-cms-5.0.6 node_modules/ccount/index.js
trusty-cms-5.0.5 node_modules/ccount/index.js
trusty-cms-5.0.4 node_modules/ccount/index.js
trusty-cms-5.0.3 node_modules/ccount/index.js
trusty-cms-5.0.2 node_modules/ccount/index.js
trusty-cms-5.0.1 node_modules/ccount/index.js
trusty-cms-4.3.5 node_modules/ccount/index.js
trusty-cms-5.0.0 node_modules/ccount/index.js
trusty-cms-4.3.4 node_modules/ccount/index.js
trusty-cms-4.3.3 node_modules/ccount/index.js
trusty-cms-4.3.2 node_modules/ccount/index.js
trusty-cms-4.3.1 node_modules/ccount/index.js
trusty-cms-4.3 node_modules/ccount/index.js
trusty-cms-4.2.3 node_modules/ccount/index.js
trusty-cms-4.2.2 node_modules/ccount/index.js
trusty-cms-4.2.1 node_modules/ccount/index.js
trusty-cms-4.2 node_modules/ccount/index.js
trusty-cms-4.1.9 node_modules/ccount/index.js
trusty-cms-4.1.8 node_modules/ccount/index.js