Skip to content

Commit

Permalink
Add docs to types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 1, 2022
1 parent 35320c7 commit 19a36e1
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
/**
* @typedef Counts
* Counts from input document.
* @property {number} sentence
* Number of sentences.
* @property {number} word
* Number of words.
* @property {number} letter
* Number of letters.
*/

/**
* @typedef {Counts} ColemanLiauCounts
* Deprecated: please use the `Counts` type instead.
*/

const letterWeight = 0.0588
const sentenceWeight = 0.296
const base = 15.8
const percentage = 100

/**
* @typedef {Object.<string, number>} ColemanLiauCounts
* @propert {number} sentence
* @propert {number} word
* @propert {number} letter
*/

/**
* Given an object containing the number of words (`word`), the number of sentences (`sentence`), and the number of letters (`letter`) in a document, returns the grade level associated with the document.
* Given an object containing the number of words (`word`), the number of
* sentences (`sentence`), and the number of letters (`letter`) in a
* document, returns the grade level associated with the document.
*
* @param {ColemanLiauCounts} counts
* @param {Counts} counts
* Counts from input document.
* @returns {number}
* Grade level associated with the document.
*/
export function colemanLiau(counts) {
if (!counts || !counts.sentence || !counts.word || !counts.letter) {
Expand Down

0 comments on commit 19a36e1

Please sign in to comment.