Count the occurrences of a substring within a string.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
test
.travis.yml
LICENSE
Makefile
README.md
index.js
package.json

README.md

Occurrences Build Status

Count the occurrences of a substring within a string and keep track of each occurrence's position.

Installation

$ npm install occurrences

Usage

var occurrences = require('occurrences');

occurrences('foobar', 'o', function(result) {
  console.log('Occurrences: ' + result.count);
  console.log('Positions of each occurrence: ' + result.positions);
});

Example

$ cd example
$ node demo.js

Test

$ npm install
$ make test