stringzy
Version:
A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.
18 lines (17 loc) • 801 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.readingDuration = readingDuration;
const wordCount_1 = require("./wordCount");
/**
* Calculates the estimated reading duration for a given text based on an average reading speed.
*
* The default reading speed is set to 230 words per minute, which is derived from various research studies.
*
* @param {string} text - The text for which the reading duration is to be calculated.
* @param {number} [readingSpeed=230] - The reading speed in words per minute. Defaults to 230.
* @returns {number} - The estimated reading duration in minutes.
*/
function readingDuration(text, readingSpeed = 230) {
const amountOfWords = (0, wordCount_1.wordCount)(text);
return Math.round(amountOfWords / readingSpeed);
}
;