1.0.1 • Published 5 years ago

@fjflala/words-counter v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Words counter

Simple package to count how many times a word appears in a string.

Live example

How to use it

Install

npm install @fjflala/words-counter

Require

const WordsCounter = require('@fjflala/words-counter');

Create new constructor

const wordsCounter = new WordsCounter('Home, sweet home!', {
  caseSensitive: true,
  minCharacters: 2,
});

Public methods

MethodInfoParamsExample
orderAscendingThis method will return a list of elements with all the words in the string, and will order them in a ascending wayLimit: Number (default 5) / Offset: Number (default 0)wordCounter.orderAscending(offset, limit)
orderDescendingThis method will return a list of elements with all the words in the string, and will order them in a descending wayLimit: Number (default 5) / Offset: Number (default 0)wordCounter.orderAscending(offset, limit)
searchThis method will return the word searched as an ObjectWord: String (Required) wordCounter.search(word)
updateThis method should update the stringString: String (Required)wordCounter.update(string)

Test (It uses jest)

npm run test
1.0.1

5 years ago

1.0.0

5 years ago