@thang2162/wordfrequency

1.0.2 • Public • Published

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

  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>

Readme

Keywords

none

Package Sidebar

Install

npm i @thang2162/wordfrequency

Weekly Downloads

1

Version

1.0.2

License

Unlicense

Unpacked Size

4.56 kB

Total Files

5

Last publish

Collaborators

  • thang2162