Skip to content

samouss/count-words-occurrence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Count words occurrence

npm version Build Status

Installation

npm install --save count-words-occurrence

Usage

Import the module in your application:

// From ES6
import countWords from 'count-words-occurrence'

// From CJS
const countWords = require('count-words-occurrence');

// From global
const countWords = countWordsOccurrence.default;

// Then use it juste like that:
const result = countWords(input, options);

Documentation

countWords(input, options);

input

Type: string

options.caseSensitive

Type: boolean | default: false

options.minLength

Type: number | default: 2

The minimum length of words to count.

options.predicates

Type: Array<(x: string) => boolean> | default: []

An array of functions to apply to each word for enable custom filters.

Run the test

npm test

About

Count occurrence of words in the given string

Resources

License

Stars

Watchers

Forks

Packages

No packages published