src/parser.js
/**
 * Calculate readability statistics from text
 * @param {object} count Descriptive data from text
 * @param {string} lang Language to use
 * @returns {object}
 */
Calculate readability statistics from text
@param {object} count Descriptive data from text
@param {string} lang Language to use
@returns {object}
Calculate readability statistics from text @param { object } count Descriptive data from text @param { string } lang Language to use @returns { object }
function statistics(count, lang) {
  if (typeof count != "object" || Object.keys(count).length < 1) {
    throw new TypeError("Invalid input: count");
  }
  if (typeof lang != "string" || lang.length < 1) {
    throw new TypeError("Invalid input: lang");
  }
  return {
    automatedReadability: Math.ceil(
      automatedReadability({
        sentence: count.sentences,
        word: count.words,
        character: count.letters
      })
    ),
    flesch: parseFloat(
      compute
        .Flesch(
          {
            sentences: count.sentences,
            words: count.words,
            syllables: count.syllables
          },
          lang
        )
        .toFixed(1)
    ),
    fleschKincaid: Math.floor(
      fleschKincaid({
        sentence: count.sentences,
        word: count.words,
        syllable: count.syllables
      })
    ),
    colemanLiau: parseFloat(
      colemanLiau({
        sentence: count.sentences,
        word: count.words,
        letter: count.letters
      }).toFixed(1)
    ),
    smog: parseFloat(
      smogFormula({
        sentence: count.sentences,
        polysillabicWord: count.polysillabicWords
      }).toFixed(1)
    ),
    lix: Math.round(
      compute.LIX({
        words: count.words,
        periods: count.periods,
        longwords: count.longwords
      })
    ),
    rix: parseFloat(
      compute
        .RIX({
          sentences: count.sentences,
          longwords: count.longwords
        })
        .toFixed(2)
    )
  };
}
function statistics ( count , lang ) { if ( typeof count != "object" || Object . keys ( count ) . length < 1 ) { throw new TypeError ( "Invalid input: count" ) ; } if ( typeof lang != "string" || lang . length < 1 ) { throw new TypeError ( "Invalid input: lang" ) ; } return { automatedReadability : Math . ceil ( automatedReadability ( { sentence : count . sentences , word : count . words , character : count . letters } ) ) , flesch : parseFloat ( compute . Flesch ( { sentences : count . sentences , words : count . words , syllables : count . syllables } , lang ) . toFixed ( 1 ) ) , fleschKincaid : Math . floor ( fleschKincaid ( { sentence : count . sentences , word : count . words , syllable : count . syllables } ) ) , colemanLiau : parseFloat ( colemanLiau ( { sentence : count . sentences , word : count . words , letter : count . letters } ) . toFixed ( 1 ) ) , smog : parseFloat ( smogFormula ( { sentence : count . sentences , polysillabicWord : count . polysillabicWords } ) . toFixed ( 1 ) ) , lix : Math . round ( compute . LIX ( { words : count . words , periods : count . periods , longwords : count . longwords } ) ) , rix : parseFloat ( compute . RIX ( { sentences : count . sentences , longwords : count . longwords } ) . toFixed ( 2 ) ) } ; }
Calculate readability statistics from text
 @param {object} count Descriptive data from text
 @param {string} lang Language to use
 @returns {object}
Calculate readability statistics from text @param { object } count Descriptive data from text @param { string } lang Language to use @returns { object }