Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

substr-occurrence

codetheweb12MIT1.1.0

Gets the number of occurrences of a string or character in a string.

substr, substring, string, character, number, occurrence, count

readme

Substr Occurrence

forthebadge Build Status

A small, extremely lightweight library that counts the number of occurrences of a substring or single character in a larger string. Created because string-occurrence was too bloated and slow.

Installation

npm install codetheweb/substr-occurrence

Usage

var occurrence = require('substr-occurrence');

console.log(occurrence('o', 'foo bar');

Output should be 2.

Tests

npm test