occurrences

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

npm install occurrences
4 downloads in the last week
8 downloads in the last month

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
npm loves you