strkits
Version:
String transform module
43 lines (42 loc) • 2.15 kB
TypeScript
export type Separator = ' ' | '-' | '_';
export declare function isSpecialCharacter(subject: string): boolean;
export declare function isUpperCase(subject: string): boolean;
export declare function removedMultiplesCharacters(subject: string, characters: string): string;
/**
* Works like strip() in python
* @param subject The string that will be trimmed
* @param characters A string or list of strings specifying the set of
* characters to be removed from the left and right part of the string.
* @returns The string with both leading and trailing characters stripped.
*/
export declare function strip(subject: string, characters: string | string[] | Readonly<string[]>): string;
export declare function transformToSpecialCase(subject: string, separator: Separator): string;
export declare function transformToCamelCase(subject: string): string;
export declare function transformToPascalCase(subject: string): string;
export declare function transformToKebabCase(subject: string): string;
export declare function transformToSnakeCase(subject: string): string;
export declare function transformToTitleCase(subject: string, separator?: ' ' | '-' | '_'): string;
export type ReplaceRangeConfig = {
start: number;
end: number;
value: string;
};
export declare function replaceRange(subject: string, args: ReplaceRangeConfig[]): string;
export declare function getLineBreakChar(subject: string): "\n" | "\r" | "\r\n";
export declare const StrKits: Readonly<{
isUpperCase: typeof isUpperCase;
isSpecialCharacter: typeof isSpecialCharacter;
strip: typeof strip;
removedMultiplesCharacters: typeof removedMultiplesCharacters;
replaceRange: typeof replaceRange;
getLineBreakChar: typeof getLineBreakChar;
transform: Readonly<{
toCamelCase: typeof transformToCamelCase;
toPascalCase: typeof transformToPascalCase;
toKebabCase: typeof transformToKebabCase;
toSnakeCase: typeof transformToSnakeCase;
toTitleCase: typeof transformToTitleCase;
toSpecialCase: typeof transformToSpecialCase;
}>;
}>;
export default StrKits;