3.0.0 • Published 1 month ago

@untemps/read-per-minute v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@untemps/read-per-minute

Class to parse a long text and return an estimated reading time based on a lang rate.

npm GitHub Workflow Status Codecov

Installation

yarn add @untemps/read-per-minute

Usage

Import ReadPerMinute:

import { ReadPerMinute } from '@untemps/read-per-minute'

Create an instance of ReadPerMinute:

const rpm = new ReadPerMinute()

Call the parse method with a string and a lang:

rpm.parse('Long text', 'en')

Get the parsed values:

const estimatedReadingTime = rpm.time
const numberOfWords = rpm.words
const langRate = rpm.rate

Alternative Use with Custom Rates

Override all the values

You can specify an entire custom rates object in the constructor of an instance:

const customRates = {
	default: 220,
	ar: 191,
	zh: 255,
	nl: 234,
	en: 244,
}
const rpm = new ReadPerMinute(customRates)

NOTE: Set a default property in the object if you want the parsing to fallback to a specific value.
Otherwise, the static value will be used (ReadPerMinute.rates.default).

Override the value for a one-time parsing

Simply pass the desired custom reading rate in words per minute instead of a language code:

// For very fast readers: 425 words per minute.
rpm.parse('Long text', 425)

NOTE: The custom reading rate must be greater than zero or the default value will be used.

Rates

Reading rates by lang come from "How many words do we read per minute? A review and meta-analysis of reading rate" by Marc Brysbaert - Department of Experimental Psychology Ghent University

LangRate
default200
ar181
zh260
nl228
en236
fi195
fr214
de260
he224
it285
ko226
es278
sv218

If the lang is not listed or is undefined, the default value will be used.

3.0.0

1 month ago

2.1.0

1 month ago

2.0.1

8 months ago

2.0.0

8 months ago

1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago