0.1.0 • Published 7 years ago

@delucis/reading-data-text-stats v0.1.0

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
7 years ago

@delucis/reading-data-text-stats

Build Status Coverage Status npm (scoped)

A plugin for @delucis/reading-data that processes a string of text returning statistics such as word count and language.

Installation

npm install --save @delucis/reading-data-text-stats

Usage

const RD = require('@delucis/reading-data')
const TEXT_STATS = require('@delucis/reading-data-text-stats')

RD.preloadData({
  myArticle: { text: 'This is a short article that needs analysing.' }
})

RD.use(TEXT_STATS, {
  scope: 'myArticle',
  textNode: 'text',     // where in the scope is the text to analyse
  outNode: 'stats'      // where in the scope should the output be saved
})

RD.run().then((res) => {
  console.log(res.data.myArticle.stats)
  // logs: { wordcount: 8, language: 'eng' }
})

Options

nametypedefaultdescription
hooksString, Object'process'The reading-data hook that should load the YAML file. Can be scoped by passing an object with scopes as keys, hooks as values.
languageBooleantrueWhether or not the plugin should return the language of the textNode.
outNodeString'stats'The property to be added to the scope containing text statistics.
scopeString, Array'textStats'The scope under which reading-data will store this plugin’s data. Can be an array to return multiple filepaths/URLs, to multiple scopes.
stripHTMLBooleanfalseWhether or not the plugin should try to strip HTML tags from the textNode.
textNodeString'text'The property in the scope that contains the string to be analysed.
wordcountBooleantrueWhether or not the plugin should return how many words are in the textNode.