Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 5 days ago
JSON representation

A medium's like reading time estimator with internationalization support

Awesome Lists containing this project

README

        

# reading-time-estimator

![Test](https://github.com/lbenie/reading-time-estimator/workflows/Test/badge.svg)
![Lint](https://github.com/lbenie/reading-time-estimator/workflows/Lint/badge.svg)
![Semantic Release](https://github.com/lbenie/reading-time-estimator/workflows/Semantic%20Release/badge.svg)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![npm](https://img.shields.io/npm/l/reading-time-estimator.svg)](https://github.com/lbenie/reading-time-estimator/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/dt/reading-time-estimator.svg)](https://www.npmjs.com/package/reading-time-estimator)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/reading-time-estimator.svg)](https://www.npmjs.com/package/reading-time-estimator)

[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)

[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/made-with-typescript.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/uses-badges.svg)](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. Here are the types definition for this module.

It is a simple function that takes the data as a required argument with the words per minute and locale as optional arguments.

Per default the locale is set to english `en`.

Per default the word per minute is set to `300`.

At the moment there is only 12 supported locales: `en`, `fr`, `es`, `pt-br`, `cn`, `ja`, `de`, `tr`, `ro`, `bn`, `sk` and `cs`.

### 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'

// default options
const result = readingTime(text, 10)

// output:
// {
// minutes: 4,
// words: 43,
// text: `4 min read`
// }

// with french locale
const result = readingTime(text, 10, '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é
Lucien Bénié

💻 📖
Victor Sierra
Victor Sierra

💻
ZhangC
ZhangC

💻
Rich11
Rich11

💻 📖
Matheus Oliveira
Matheus Oliveira

💻
Can Güven
Can Güven

💻
Alexander Strutz
Alexander Strutz

💻


凝结尾迹
凝结尾迹

💻
Muhammad Faisal Amin
Muhammad Faisal Amin

💻
Oliver Groma
Oliver Groma

💻

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