@supernovaio/sdk
Version:
Supernova.io SDK
73 lines (72 loc) • 5.26 kB
TypeScript
export declare class StringUtils {
/** Returns string without whitespaces and newlines, trimmed left and right */
static trimmed(str: string): string;
/** Returns string without double quotes, trimmed left and right */
static withoutDoubleQuotes(str: string): string;
/** Returns string without single and double quotes, trimmed left and right */
static withoutQuotes(str: string): string;
/** Returns opening string until the first occurance of the character. If delimiter is not found, returns null */
static substringUntilDelimiter(str: string, delimiter: string): string | null;
/** Returns whether string is prefixed and suffixed with double quotes */
static isSurroundedWithDoubleQuotes(str: string): boolean;
/** Returns substring between two round brackets. Returns null if it doesn't fit the format */
static argumentStringBetweenBrackets(str: string, keyword: string): string | null;
/** Returns substring between two round brackets using syntax-sensitive parsing (ignoring quoted content and properly balancing number of ( ) */
static argumentStringBetweenBracketsFirstOccurance(str: string, keyword: string): string | null;
/** Returns string without single and double quotes but removes only 1 character at most */
static withoutQuotesSingleOccurance(str: string): string;
/** Returns string without single and double quotes but removes only 1 character at most */
static withoutDoubleQuotesSingleOccurance(str: string): string;
/** Returns string without round brackets, trimmed left and right */
static withoutRoundBrackets(str: string): string;
/** Creates a full range of a string, returning range of (0, length) */
static fullRange(str: string): {
location: number;
length: number;
};
/** Creates string made of N spaces */
static spaces(count: number): string;
/** Splits string using separator while properly handling quotes.
Content inside single or double quote will be ignored. Only content within closed quote pair will be ignored,
Last single, not closed quote will be ignored. Quote types can't be combined, if the quote pair
started with one type, it needs to be closed with the same one. There can be multiple types of quote pairs in single string though.
Returns original string without splitting if separator is single or double quote as this behavior is undefined */
static splitIgnoringQuotedContent(str: string, separator: string): Array<string>;
/** Removes spaces when they are inside of brackets, but properly handling spaces inside quoted content which should remain intact */
static withoutSpacesInsideRoundBrackets(str: string): string;
/** Splits string using separator while properly handling quotes and ignoring all content that comes in ().
Content inside single or double quote will be ignored. Only content within closed quote pair will be ignored,
Last single, not closed quote will be ignored. Quote types can't be combined, if the quote pair
started with one type, it needs to be closed with the same one. There can be multiple types
of quote pairs in single string though.
Returns original string without splitting if separator is single, double quote or left/right bracket as this behavior is undefined */
static splitIgnoringQuotedBracketedContent(str: string, separator: string): Array<string>;
/** Tests whether all characters of the string are lowercased and are only letters a-z */
static isLowercaseLetters(str: string): boolean;
/** Tests whether all characters of the string are lowercased and are only letters a-z, including separator dot */
static isLowercaseLettersCanIncludeDot(str: string): boolean;
/** Tests whether all characters of the string are letters */
static isLetters(str: string): boolean;
/** Tests whether all characters of the string are letters, including separator dot */
static isLettersCanIncludeDot(str: string): boolean;
/** Tests whether the first character of the string is lowercase */
static isFirstCharacterLetterLowercase(str: string): boolean;
/** Tests whether all characters of the string are spaces */
static isOnlySpaces(str: string): boolean;
/** Tests whether all characters of the string are spaces or newlines */
static isOnlySpacesOrLineBreaks(str: string): boolean;
/** Tests whether string represents array definition - starts with [, ends with ]
* and doesn't contain : unless in double quotes
*/
static isStructuralArrayDefinition(str: string): boolean;
/** Parses array if it is structuraly viable and retrieves array components */
static parsedArrayFromDefinition(str: string): Array<string> | null;
/** Tests whether string represents dictionary definition - starts with [, ends with ]
* and contains at least once :
*/
static isStructuralDictionaryDefinition(str: string): boolean;
/** Parses array if it is structuraly viable and retrieves array components */
static parsedDictionaryFromDefinition(str: string): Map<string, string> | null;
static replaceAll(str: string, find: string, replace: string): string;
static escapeRegExp(string: string): string;
}