reading-time-estimator
v2.0.4
Published
A medium's like reading time estimator with internationalization support
Downloads
31,293
Maintainers
Readme
reading-time-estimator
A medium's like reading time estimator with internationalization support.
Documentation
Reading Time Estimator was created to provide an estimate of how long to read an article or blog as seen on medium.
Installation
With NPM
npm install reading-time-estimatoror Yarn
yarn add reading-time-estimatorAPI
The API is fairly simple. readingTime accepts the text to analyze plus an optional options object.
Per default the locale is set to english en.
Per default the words per minute is set to 200.
You can also provide translations to override locale strings or htmlSanitizerOptions to customize how markup is handled.
At the moment it supports these locales: 'en', 'fr', 'es', 'zh-cn', 'zh-tw', 'ja', 'de', 'pt-br', 'tr', 'ro', 'bn', 'sk', 'cs', 'ru', 'vi', 'it' and 'id'
Usage
Try it live here
import { readingTime } from 'reading-time-estimator'
const text = 'some text to parse'
// custom words per minute
const result = readingTime(text, { wordsPerMinute: 10 })
// output:
// {
// minutes: 4,
// words: 43,
// text: `4 min read`
// }
// with french locale
import { fr } from 'reading-time-estimator/i18n/fr'
const frenchResult = readingTime(text, {
wordsPerMinute: 10,
language: 'fr',
{
fr,
},
})
// output:
// {
// minutes: 4,
// words: 43,
// text: `4 min de lecture`
// }Why Not ...?
reading-time
This package does not offer internationalization support which was a must for me.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
