UNPKG

@difizen/mana-common

Version:

102 lines 4.63 kB
export declare function isFalsyOrWhitespace(str: string | undefined): boolean; /** * Helper to produce a string with a variable number of arguments. Insert variable segments * into the string using the {n} notation where N is the index of the argument following the string. * @param value string to which formatting is applied * @param args replacements for {n}-entries */ export declare function format(value: string, ...args: any[]): string; /** * Converts HTML characters inside the string to use entities instead. Makes the string safe from * being used e.g. in HTMLElement.innerHTML. */ export declare function escape(html: string): string; /** * Escapes regular expression characters in a given string */ export declare function escapeRegExpCharacters(value: string): string; /** * Counts how often `character` occurs inside `value`. */ export declare function count(value: string, character: string): number; export declare function truncate(value: string, maxLength: number, suffix?: string): string; /** * Removes all occurrences of needle from the beginning and end of haystack. * @param haystack string to trim * @param needle the thing to trim (default is a blank) */ export declare function trim(haystack: string, needle?: string): string; /** * Removes all occurrences of needle from the beginning of haystack. * @param haystack string to trim * @param needle the thing to trim */ export declare function ltrim(haystack: string, needle: string): string; /** * Removes all occurrences of needle from the end of haystack. * @param haystack string to trim * @param needle the thing to trim */ export declare function rtrim(haystack: string, needle: string): string; export declare function convertSimple2RegExpPattern(pattern: string): string; export declare function stripWildcards(pattern: string): string; export interface RegExpOptions { matchCase?: boolean; wholeWord?: boolean; multiline?: boolean; global?: boolean; unicode?: boolean; } export declare function createRegExp(searchString: string, isRegex: boolean, options?: RegExpOptions): RegExp; export declare function regExpLeadsToEndlessLoop(regexp: RegExp): boolean; export declare function regExpContainsBackreference(regexpValue: string): boolean; export declare function regExpFlags(regexp: RegExp): string; export declare function splitLines(str: string): string[]; /** * Returns first index of the string that is not whitespace. * If string is empty or contains only whitespaces, returns -1 */ export declare function firstNonWhitespaceIndex(str: string): number; /** * Returns the leading whitespace of the string. * If the string contains only whitespaces, returns entire string */ export declare function getLeadingWhitespace(str: string, start?: number, end?: number): string; /** * Returns last index of the string that is not whitespace. * If string is empty or contains only whitespaces, returns -1 */ export declare function lastNonWhitespaceIndex(str: string, startIndex?: number): number; export declare function compare(a: string, b: string): number; export declare function compareSubstring(a: string, b: string, aStart?: number, aEnd?: number, bStart?: number, bEnd?: number): number; export declare function compareIgnoreCase(a: string, b: string): number; export declare function compareSubstringIgnoreCase(a: string, b: string, aStart?: number, aEnd?: number, bStart?: number, bEnd?: number): number; export declare function isLowerAsciiLetter(code: number): boolean; export declare function isUpperAsciiLetter(code: number): boolean; export declare function equalsIgnoreCase(a: string, b: string): boolean; export declare function startsWithIgnoreCase(str: string, candidate: string): boolean; /** * @returns the length of the common prefix of the two strings. */ export declare function commonPrefixLength(a: string, b: string): number; /** * @returns the length of the common suffix of the two strings. */ export declare function commonSuffixLength(a: string, b: string): number; /** * See http://en.wikipedia.org/wiki/Surrogate_pair */ export declare function isHighSurrogate(charCode: number): boolean; /** * See http://en.wikipedia.org/wiki/Surrogate_pair */ export declare function isLowSurrogate(charCode: number): boolean; /** * See http://en.wikipedia.org/wiki/Surrogate_pair */ export declare function computeCodePoint(highSurrogate: number, lowSurrogate: number): number; /** * get the code point that begins at offset `offset` */ export declare function getNextCodePoint(str: string, len: number, offset: number): number; //# sourceMappingURL=strings.d.ts.map