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 444c56a commit 8d56ead
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
/**
* @typedef {Object} SmogFormulaCounts
* @typedef Counts
* Counts from input document.
* @property {number} sentence
* Number of sentences.
* @property {number} [polysillabicWord]
* Number of of polysillabic (three or more syllables) words.
*/

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

const sentenceSize = 30
const weight = 1.043
const base = 3.1291

/**
* Get the grade level of a given value according to the SMOG formula. More information is available at WikiPedia: <https://en.wikipedia.org/wiki/SMOG>.
* Given an object containing the number of sentences (`sentence`) and the
* number of polysillabic (three or more syllables) words (`polysillabicWord`)
* in a document, returns the reading ease associated with the document.
*
* @param {SmogFormulaCounts} counts
* @param {Counts} counts
* Counts from input document.
* @returns {number}
* Reading ease associated with the document.
*/
export function smogFormula(counts) {
if (!counts || !counts.sentence) {
Expand Down

0 comments on commit 8d56ead

Please sign in to comment.