words-occurrences

1.0.2 • Public • Published

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

/words-occurrences/

    Package Sidebar

    Install

    npm i words-occurrences

    Weekly Downloads

    1

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    123 kB

    Total Files

    12

    Last publish

    Collaborators

    • emmanuelvacher