src/parser.js
/**
 * Calculate and interpret statistics
 * @param {object} count Descriptive statistics
 * @param {object} stats Calculated statistics
 * @param {object} annotations Localized annotations
 * @returns {object}
 */
Calculate and interpret statistics
@param {object} count Descriptive statistics
@param {object} stats Calculated statistics
@param {object} annotations Localized annotations
@returns {object}
Calculate and interpret statistics @param { object } count Descriptive statistics @param { object } stats Calculated statistics @param { object } annotations Localized annotations @returns { object }
function interpretations(count, stats, annotations) {
  if (typeof count != "object" || Object.keys(count).length < 1) {
    throw new TypeError("Parameter 'count' must be a non-empty object");
  }
  if (typeof stats != "object" || Object.keys(stats).length < 1) {
    throw new TypeError("Parameter 'stats' must be a non-empty object");
  }
  if (typeof annotations != "object" || Object.keys(annotations).length < 1) {
    throw new TypeError("Parameter 'annotations' must be a non-empty object");
  }
  const gradeModifier = annotations.modifier.grade.constant;
  return {
    automatedReadability: {
      grade: stats.automatedReadability,
      age: stats.automatedReadability + gradeModifier
    },
    flesch: interpret.Flesch(stats.flesch, annotations),
    fleschKincaid: {
      grade: stats.fleschKincaid,
      age: stats.fleschKincaid + gradeModifier
    },
    colemanLiau: {
      grade: stats.colemanLiau,
      age: stats.colemanLiau + gradeModifier
    },
    smog: {
      grade: stats.smog,
      age: interpret.SMOG(stats.smog, count.words, gradeModifier)
    },
    lix: interpret.LIX(stats.lix, annotations),
    rix: {
      grade: interpret.RIX(stats.rix)
    }
  };
}
function interpretations ( count , stats , annotations ) { if ( typeof count != "object" || Object . keys ( count ) . length < 1 ) { throw new TypeError ( "Parameter 'count' must be a non-empty object" ) ; } if ( typeof stats != "object" || Object . keys ( stats ) . length < 1 ) { throw new TypeError ( "Parameter 'stats' must be a non-empty object" ) ; } if ( typeof annotations != "object" || Object . keys ( annotations ) . length < 1 ) { throw new TypeError ( "Parameter 'annotations' must be a non-empty object" ) ; } const gradeModifier = annotations . modifier . grade . constant ; return { automatedReadability : { grade : stats . automatedReadability , age : stats . automatedReadability + gradeModifier } , flesch : interpret . Flesch ( stats . flesch , annotations ) , fleschKincaid : { grade : stats . fleschKincaid , age : stats . fleschKincaid + gradeModifier } , colemanLiau : { grade : stats . colemanLiau , age : stats . colemanLiau + gradeModifier } , smog : { grade : stats . smog , age : interpret . SMOG ( stats . smog , count . words , gradeModifier ) } , lix : interpret . LIX ( stats . lix , annotations ) , rix : { grade : interpret . RIX ( stats . rix ) } } ; }
Calculate and interpret statistics
 @param {object} count Descriptive statistics
 @param {object} stats Calculated statistics
 @param {object} annotations Localized annotations
 @returns {object}
Calculate and interpret statistics @param { object } count Descriptive statistics @param { object } stats Calculated statistics @param { object } annotations Localized annotations @returns { object }