UNPKG

textconvert

Version:

Public library to convert text into many conventions and formats.

73 lines (72 loc) 1.93 kB
/** * Text statistics interface containing various metrics about text */ export interface TextStatistics { /** * Total character count including whitespace and punctuation */ characterCount: number; /** * Character count excluding whitespace */ characterCountNoSpaces: number; /** * Letter count (only alphabetic characters) */ letterCount: number; /** * Letter and number count (alphanumeric characters) */ alphanumericCount: number; /** * Word count in the text */ wordCount: number; /** * Sentence count in the text */ sentenceCount: number; /** * Paragraph count in the text (separated by 2+ newlines) */ paragraphCount: number; /** * Average word length in characters */ averageWordLength: number; /** * Average sentence length in words */ averageSentenceLength: number; /** * Estimated reading time in seconds (based on average reading speed) */ readingTimeSeconds: number; /** * Estimated reading time as formatted string (e.g., "2 min 30 sec") */ readingTimeFormatted: string; } /** * Analyzes text and returns comprehensive statistics about it * * @param text The text to analyze * @param wordsPerMinute Reading speed in words per minute (default: 200) * @returns TextStatistics object with various metrics * @example * getTextStats('Hello world! This is a test.'); * // { * // characterCount: 28, * // characterCountNoSpaces: 24, * // letterCount: 20, * // alphanumericCount: 20, * // wordCount: 6, * // sentenceCount: 2, * // paragraphCount: 1, * // averageWordLength: 3.3, * // averageSentenceLength: 3, * // readingTimeSeconds: 2, * // readingTimeFormatted: '2 sec' * // } */ export declare function getTextStats(text: string, wordsPerMinute?: number): TextStatistics;