UNPKG

textconvert

Version:

Public library to convert text into many conventions and formats.

34 lines (33 loc) 1.28 kB
/** * Return a boolean value number of the letters in a string. * * @param text String input to get letters count from. * @param countNumbers boolean value to determine if numbers should be counted as letters. * * @returns Number of letters and numbers (if requested) in a string. * @example * count('Hello, world!'); // 10 * count('Hello0 world', true); // 11 */ export declare function count(text: string, countNumbers?: boolean): number; /** * Counts the number of words in a string. * Words are defined as sequences of letters, numbers, and apostrophes separated by whitespace. * * @param text String input to count words from * @returns Number of words in the string * @example * countWords('Hello, world!'); // 2 */ export declare function countWords(text: string): number; /** * Counts the number of sentences in a string. * Sentences are defined as sequences of text ending with ., !, or ? followed by whitespace or end of string. * Text without any sentence-ending punctuation is considered to be a single sentence. * * @param text String input to count sentences from * @returns Number of sentences in the string * @example * countSentences('Hello world! How are you?'); // 2 */ export declare function countSentences(text: string): number;