https://github.com/lbenie/reading-time-estimator
A medium's like reading time estimator with internationalization support
https://github.com/lbenie/reading-time-estimator
es6 estimator i18n javascript javascript-library medium reading reading-time time typescript typescript-library
Last synced: about 2 months ago
JSON representation
A medium's like reading time estimator with internationalization support
- Host: GitHub
- URL: https://github.com/lbenie/reading-time-estimator
- Owner: lbenie
- Created: 2018-07-24T15:36:37.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T11:40:16.000Z (about 1 year ago)
- Last Synced: 2025-03-28T18:07:10.207Z (about 1 year ago)
- Topics: es6, estimator, i18n, javascript, javascript-library, medium, reading, reading-time, time, typescript, typescript-library
- Language: TypeScript
- Homepage: https://lbenie.xyz
- Size: 7.63 MB
- Stars: 49
- Watchers: 3
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/funding.yml
Awesome Lists containing this project
README
# reading-time-estimator
[](https://github.com/lbenie/reading-time-estimator/actions/workflows/test.yml)
[](https://github.com/lbenie/reading-time-estimator/actions/workflows/commintlint.yml)
[](https://github.com/lbenie/reading-time-estimator/actions/workflows/release.yml)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/semantic-release/semantic-release)
[](https://github.com/lbenie/reading-time-estimator/blob/main/LICENSE)
[](https://www.npmjs.com/package/reading-time-estimator)
[](https://www.npmjs.com/package/reading-time-estimator)
[](#contributors-)
[](https://forthebadge.com)
[](https://forthebadge.com)
[](https://forthebadge.com)
A [medium](https://medium.com/)'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](https://medium.com/).
### Installation
With NPM
```bash
npm install reading-time-estimator
```
or Yarn
```bash
yarn add reading-time-estimator
```
### API
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`.
Inputs are parsed as Markdown and sanitized as HTML automatically before word counting.
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', 'id' and 'hi'`
### Usage
Try it live [here](https://codesandbox.io/s/condescending-rosalind-lll23r?file=/src/App.tsx)
```typescript
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](https://www.npmjs.com/package/reading-time) does not offer
internationalization support which was a must for me.
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/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
💻

Shubhankar Valimbe
💻
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!