https://github.com/thang2162/wordfrequency
A simple script to count the frequency of words in a string.
https://github.com/thang2162/wordfrequency
Last synced: 2 months ago
JSON representation
A simple script to count the frequency of words in a string.
- Host: GitHub
- URL: https://github.com/thang2162/wordfrequency
- Owner: thang2162
- License: unlicense
- Created: 2021-09-17T20:38:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-17T21:48:29.000Z (over 3 years ago)
- Last Synced: 2025-02-14T15:50:18.578Z (3 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
1. String (required) - String to be processed.
2. 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
```javascript
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
```htmlconst str = "With great power there must also come -- great responsibility.";
WordFrequency(str, 'asc').then(res => {
alert(JSON.stringify(res));
});```