A medium's like reading time estimator with internationalization support.
Reading Time Estimator was created to provide an estimate of how long to read an article or blog as seen on medium.
With NPM
npm install reading-time-estimatoror Yarn
yarn add reading-time-estimatorThe 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'
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`
// }This package does not offer internationalization support which was a must for me.
Thanks goes to these wonderful people (emoji key):
Lucien Bénié 💻 📖 |
Victor Sierra 💻 |
ZhangC 💻 |
Rich11 💻 📖 |
Matheus Oliveira 💻 |
Can Güven 💻 |
Alexander Strutz 💻 |
凝结尾迹 💻 |
Muhammad Faisal Amin 💻 |
Oliver Groma 💻 |
Luo Wenjie 💻 |
CK Wong 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!