@thang2162/wordfrequency
v1.0.2
Published
A simple script to count the frequency of words in a string.
Downloads
5
Readme
WordFrequency
A simple script to count the frequency of words in a string.
Installation
npm install @thang2162/wordfrequency --save
or
yarn add @thang2162/wordfrequency
Arguments
- String (required) - String to be processed.
- SortBy (optional) - 'desc' for descending or 'asc' ascending. Example:
WordCounter(String, SortBy).then(res => { alert(JSON.stringify(res)); });
This returns a sorted object array.
Usage
import {WordFrequency} from '@thang2162/wordfrequency'
const str = "With great power there must also come -- great responsibility.";
WordFrequency(str, 'asc').then(res => {
alert(JSON.stringify(res));
});
CDN
<!DOCTYPE html>
<html>
<script src="https://thang2162.github.io/WordFrequency/cdn.min.js"></script>
<script>
const str = "With great power there must also come -- great responsibility.";
WordFrequency(str, 'asc').then(res => {
alert(JSON.stringify(res));
});
</script>
</html>