@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
21 lines (20 loc) • 698 B
TypeScript
/**
* Estimates the reading time for a given text.
* Assumes an average reading speed of 200 words per minute.
*
* @param text - The text to analyze.
* @param wordsPerMinute - (Optional) The average reading speed in words per minute (default is 200).
* @returns An object containing the total reading time in minutes and seconds.
*
* @example
* readingTime("This is a sample text.");
* // Output: { minutes: 0, seconds: 1 }
*
* @example
* readingTime("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 250);
* // Output: { minutes: 0, seconds: 2 }
*/
export default function readingTime(text: string, wordsPerMinute?: number): {
minutes: number;
seconds: number;
};