1.0.2 • Published 4 years ago

word-per-minute v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Word-per-minute

word-per-minute helps you estimate how long an article will take to read. It works perfectly with plain text, but also with markdown or html.

Installation

npm install word-per-minute --production

Usage

Classic

const readTime = require('word-per-minute');

const stats = readTime(text);
// ->
// stats: {
//   text: '1 min read',
//   minutes: 1,
//   time: 60000,
//   words: 200
// }

Stream

const readTime = require('word-per-minute/stream');

fs.createReadStream('foo')
  .pipe(readTime)
  .on('data', stats => {
    // ...
  });

API

readingTime(text, options?)

  • text: the text to analyze
  • options (optional)
    • options.wordsPerMinute: (optional) the words per minute an average reader can read (default: 200)
    • options.wordBound: (optional) a function that returns a boolean value depending on if a character is considered as a word bound (default: spaces, new lines and tabulations)
  • options.language: you can set a language for return of reading text (default: en-us) |