Simple medium like estimated read times.
https://easyreadtime.netlify.com/
- Less than 4kb! (1.08kb Minified)
- Zero dependencies!
- Calculates read time of input string (rounds to closest minute).
- Pass in plain text / HTML / markdown.
- Strips all markdown and HTML for better read time estimates.
- Easy to use! 💪
$ npm i easy-read-time
or
$ yarn add easy-read-time
import getReadTime from "easy-read-time";
getReadTime(text, 200);
The function takes three arguments the string you wish to get the read time for, the speed of reading the text in words per minute, the default is set to 200 (the average reading time for adults is 250 - 300 words per minute) allowing extra time for viewing of images and other content, and a custom string this field is optional and the default is 'min read', if you pass in 'minute read' formattedString will return '2 minute read'.
Argument | Type | Description |
---|---|---|
string: required | string | Input String |
wordTime: optional | number | Defaults to 200 - Speed of reading the text in Words per Minute |
customString: optional | number | Default to 'min read' - The text after the duration eg: 2 + 'minute read' |
The method returns an object
Property | Type | Description |
---|---|---|
duration | number | Duration of the input string (in minutes) |
roundDuration | number | Duration of the input string (in minutes) rounded to closest minute |
totalWords | number | Number of words in the input string |
formattedString | string | Medium like read time string '2 min read' |
{
duration: 2.3,
roundDuration: 2,
totalWords: 400,
formattedString: '2 min read'
}
-
🐞 For Bug Reports and Enhancements please use the issues section
-
🕊️ To contact me directly you can find me via my twitter