UNPKG

lesetid

Version:

A dead simple read time estimation

77 lines 2.16 kB
//#region src/types.d.ts interface Options { /** * The average number of words per minute. * @default 200 */ wordsPerMinute?: number; /** * The average number of characters per minute. * @default 500 */ charsPerMinute?: number; /** * A function that determines if a character is a word. */ isWord?: WordFN; } interface CountResult { words: number; chars: number; } interface Estimation { /** * The estimated time to read the text. */ minutes: number; /** * The estimated time to read the text in milliseconds. */ time: number; /** * The amount of words in the text. */ words: number; /** * The amount of characters in the text. */ chars: number; /** * The formatted estimated time to read the text. * @example "1 min read" */ text: string; } type WordFN = (char?: string) => boolean; //#endregion //#region src/utils.d.ts declare const CJK_CODE_RANGES: number[][]; /** * Checks if a character is a CJK character. * * NOTE: That the ranges are maybe not complete. * You can see the full list of code ranges in `CJK_CODE_RANGES` export. * * @param {string | undefined} char - the character to check. * @returns {boolean} - true if the character is a CJK character, false otherwise. */ declare const isCJK: WordFN; declare const PUNCTATION_CODE_RANGES: number[][]; /** * Checks if a character is a punctuation character. * * NOTE: That the ranges are maybe not complete. * You can see the full list of code ranges in `PUNCTATION_CODE_RANGES` export. * * @param {string | undefined} char - the character to check. * @returns {boolean} - true if the character is a punctuation character, false otherwise. */ declare const isPunctuation: WordFN; /** * Checks if a character is a ansi character. * @param {string | undefined} char - the character to check. * @returns {boolean} - true if the character is a word character, false otherwise. */ declare const isAnsi: WordFN; //#endregion export { isPunctuation as a, Options as c, isCJK as i, WordFN as l, PUNCTATION_CODE_RANGES as n, CountResult as o, isAnsi as r, Estimation as s, CJK_CODE_RANGES as t };