1.0.2 • Published 6 years ago

words-occurrences v1.0.2

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

Words-occurrences

words-occurrences is a zero-dependency (except Jest for testing) tool for counting occurrences of higher than two-letter words in strings. It supports only English, French and some (non tested) other languages with latin alphabet.

Installation

npm install words-occurrences

or

yarn add words-occurrences

Usage

const WordsOccurrencesCounter = require('words-occurrences');

const text = 'Hello I am Brian';

// the second parameter is the case sensitivity
const wordsOccurrences = new WordsOccurrencesCounter(text, false);

const numberOfBrian = wordsOccurrences.getNumberOfOccurrencesOf('brian');
// numberOfBrian = 1 since "Brian" appears only once

const numberOfI = wordsOccurrences.getNumberOfOccurrencesOf('I');
// numberOfI = 0 since "I" is less than two-letter long

Test

You can run the test suite by cloning this repo and running :

yarn install
yarn test
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago