src/interpretors.js
/**
 * Translate Flesch-score to description
 * @param {number} x Flesch-score
 * @param {object} annotate Localized annotation
 * @returns {string} Difficulty of reading text
 */
Translate Flesch-score to description
@param {number} x Flesch-score
@param {object} annotate Localized annotation
@returns {string} Difficulty of reading text
Translate Flesch - score to description @param { number } x Flesch - score @param { object } annotate Localized annotation @returns { string } Difficulty of reading text
function Flesch(x, annotate) {
  if (typeof x != "number" || x < 1) {
    throw new TypeError("Parameter 'x' must be a number >= 1");
  }
  if (typeof annotate != "object" || Object.keys(annotate).length < 1) {
    throw new TypeError("Parameter 'annotate' must be a non-empty object");
  }
  var level;
  if (x <= 30) {
    level = annotate.stats.flesch.levels["0"];
  } else if (x > 30 && x <= 50) {
    level = annotate.stats.flesch.levels["1"];
  } else if (x > 50 && x <= 60) {
    level = annotate.stats.flesch.levels["2"];
  } else if (x > 60 && x <= 70) {
    level = annotate.stats.flesch.levels["3"];
  } else if (x > 70 && x <= 80) {
    level = annotate.stats.flesch.levels["4"];
  } else if (x > 80 && x <= 90) {
    level = annotate.stats.flesch.levels["5"];
  } else if (x > 90) {
    level = annotate.stats.flesch.levels["6"];
  }
  return `${level} ${annotate.stats.flesch.descriptor}.`;
}
function Flesch ( x , annotate ) { if ( typeof x != "number" || x < 1 ) { throw new TypeError ( "Parameter 'x' must be a number >= 1" ) ; } if ( typeof annotate != "object" || Object . keys ( annotate ) . length < 1 ) { throw new TypeError ( "Parameter 'annotate' must be a non-empty object" ) ; } var level ; if ( x <= 30 ) { level = annotate . stats . flesch . levels [ "0" ] ; } else if ( x > 30 && x <= 50 ) { level = annotate . stats . flesch . levels [ "1" ] ; } else if ( x > 50 && x <= 60 ) { level = annotate . stats . flesch . levels [ "2" ] ; } else if ( x > 60 && x <= 70 ) { level = annotate . stats . flesch . levels [ "3" ] ; } else if ( x > 70 && x <= 80 ) { level = annotate . stats . flesch . levels [ "4" ] ; } else if ( x > 80 && x <= 90 ) { level = annotate . stats . flesch . levels [ "5" ] ; } else if ( x > 90 ) { level = annotate . stats . flesch . levels [ "6" ] ; } return ` ${ level } ${ annotate . stats . flesch . descriptor } ` ; }
Translate Flesch-score to description
 @param {number} x Flesch-score
 @param {object} annotate Localized annotation
 @returns {string} Difficulty of reading text
Translate Flesch - score to description @param { number } x Flesch - score @param { object } annotate Localized annotation @returns { string } Difficulty of reading text