src/parser.js
/**
 * Count various descriptives in text
 * @param {object} data Static data from parsing
 * @returns {object}
 */
Count various descriptives in text
@param {object} data Static data from parsing
@returns {object}
Count various descriptives in text @param { object } data Static data from parsing @returns { object }
function count(data) {
  if (typeof data != "object" || Object.keys(data).length < 1) {
    throw new TypeError("Parameter 'data' must be a non-empty object");
  }
  return {
    roots: selectAll("RootNode", data.nlcst).length,
    letters: data.nlcstString.match(/[ÆØÅæøåA-Za-z0-9]/g).join("").length,
    characters: data.nlcstString.length,
    whitespaces: selectAll("WhiteSpaceNode", data.nlcst).length,
    paragraphs: selectAll("ParagraphNode", data.nlcst).length,
    sentences: data.sentenceNodes.length,
    words: selectAll("WordNode", data.nlcst).length,
    longwords: data.textNodes.filter(function(item) {
      return item.value.length > 6;
    }).length,
    periods: utilities.countPeriods(data.nlcstString),
    punctuations: selectAll("PunctuationNode", data.nlcst).length,
    syllables: data.syllables.syllables,
    polysillabicWords: data.syllables.polysillabicWords
  };
}
function count ( data ) { if ( typeof data != "object" || Object . keys ( data ) . length < 1 ) { throw new TypeError ( "Parameter 'data' must be a non-empty object" ) ; } return { roots : selectAll ( "RootNode" , data . nlcst ) . length , letters : data . nlcstString . match ( / [ÆØÅæøåA-Za-z0-9]/g).jo i n ( " ").l e ng t h , characters : data . nlcstString . length , whitespaces : selectAll ( "WhiteSpaceNode" , data . nlcst ) . length , paragraphs : selectAll ( "ParagraphNode" , data . nlcst ) . length , sentences : data . sentenceNodes . length , words : selectAll ( "WordNode" , data . nlcst ) . length , longwords : data . textNodes . filter ( function ( item ) { return item . value . length > 6 ; } ) . length , periods : utilities . countPeriods ( data . nlcstString ) , punctuations : selectAll ( "PunctuationNode" , data . nlcst ) . length , syllables : data . syllables . syllables , polysillabicWords : data . syllables . polysillabicWords } ; }
Count various descriptives in text
 @param {object} data Static data from parsing
 @returns {object}
Count various descriptives in text @param { object } data Static data from parsing @returns { object }