@ndusad/smart-reading-time
v1.0.0
Published
Accurate, zero-dependency reading and speaking time estimator for text and markdown.
Maintainers
Readme
@ndusad/smart-reading-time
Accurate, zero-dependency reading and speaking time estimator for plain text and Markdown. Automatically strips Markdown formatting (code blocks, inline code, links, images, and symbols) so syntax characters don't inflate word counts.
Installation
npm install @ndusad/smart-reading-timeQuick Start
import { readingTime } from '@ndusad/smart-reading-time';
const markdown = `
# Getting Started
This is a **sample** article with a [link](https://example.com) and some \`inline code\`.
`;
const stats = readingTime(markdown);
console.log(stats);
/*
{
words: 11,
readingMinutes: 1,
readingText: '1 min read',
speechMinutes: 1,
speechText: '1 min speech'
}
*/Custom Reading & Speech Rates
const stats = readingTime(articleText, {
wordsPerMinute: 250,
speechRate: 150
});API Reference
readingTime(text, [options])
Parameters
| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| text | string | Required | Plain text or Markdown content to analyze. |
| options.wordsPerMinute | number | 200 | Average silent reading speed (words per minute). |
| options.speechRate | number | 130 | Average spoken delivery speed (words per minute). |
Return Value
Returns an object with the following properties:
| Property | Type | Description |
| :--- | :--- | :--- |
| words | number | Total word count after stripping Markdown syntax. |
| readingMinutes | number | Estimated reading duration rounded up to the nearest minute. |
| readingText | string | Formatted reading duration string (e.g., "2 min read"). |
| speechMinutes | number | Estimated speaking duration rounded up to the nearest minute. |
| speechText | string | Formatted speaking duration string (e.g., "3 min speech"). |
License
MIT © ndusad
