@guanghechen/helper-string
Version:
Utilities for processing strings or stringify other type data.
132 lines (130 loc) • 3.53 kB
TypeScript
/**
* Text transformer.
*/
type ITextTransformer = (text: string) => string;
/**
* Compose multiple ITextTransformer into one.
* @param transformers
* @returns
*/
declare function composeTextTransformers(...transformers: ReadonlyArray<ITextTransformer>): ITextTransformer;
/**
* Transform into a string with the separator
* denoted by the next word capitalized.
*
* 'test string' => 'testString'
*
* @param text
* @see https://github.com/blakeembrey/change-case#camelcase
*/
declare const toCamelCase: ITextTransformer;
/**
* Transform into a space separated string with each word capitalized.
*
* 'test string' => 'Test String'
*
* @param text
* @see https://github.com/blakeembrey/change-case#capitalCase
*/
declare const toCapitalCase: ITextTransformer;
/**
* Transform into upper case string with an underscore between words.
*
* 'test string' => 'TEST_STRING'
*
* @param text
* @see https://github.com/blakeembrey/change-case#constantCase
*/
declare const toConstantCase: ITextTransformer;
/**
* Transform into a lower case string with a period between words.
*
* 'test string' => 'test.string'
*
* @param text
* @see https://github.com/blakeembrey/change-case#dotcase
*/
declare const toDotCase: ITextTransformer;
/**
* Transform into a lower cased string with dashes between words.
*
* 'test string' => 'test-string'
*
* @param text
* @see https://github.com/blakeembrey/change-case#paramcase
*/
declare const toKebabCase: ITextTransformer;
/**
* Transforms the string to lower case.
*
* 'TEST STRING' => 'test string'
*
* @param text
* @see https://github.com/blakeembrey/change-case#lowerCase
*/
declare const toLowerCase: ITextTransformer;
/**
* Transform into a string of capitalized words without separators.
*
* 'test string' => 'TestString'
*
* @param text
* @see https://github.com/blakeembrey/change-case#pascalcase
*/
declare const toPascalCase: ITextTransformer;
/**
* Transform into a lower case string with slashes between words.
*
* 'test string' => 'test/string'
*
* @param text
* @see https://github.com/blakeembrey/change-case#pathcase
*/
declare const toPathCase: ITextTransformer;
/**
* Transform into a lower case with spaces between words,
* then capitalize the string.
*
* 'testString' => 'Test string'
*
* @param text
* @see https://github.com/blakeembrey/change-case#sentencecase
*/
declare const toSentenceCase: ITextTransformer;
/**
* Transform into a lower case string with underscores between words.
*
* 'test string' => 'test_string'
*
* @param text
* @see https://github.com/blakeembrey/change-case#snakeCase
*/
declare const toSnakeCase: ITextTransformer;
/**
* Transform a string into title case following English rules.
*
* 'a simple test' => 'A Simple Test'
*
* @param text
* @see https://github.com/blakeembrey/change-case#titlecase
*/
declare const toTitleCase: ITextTransformer;
/**
* Perform trim operation
*
* ' a simple test ' => 'a simple test'
*
* @param text
* @returns
*/
declare const toTrim: ITextTransformer;
/**
* Transforms the string to upper case.
*
* 'test string' => 'TEST STRING'
*
* @param text
* @see https://github.com/blakeembrey/change-case#upperCase
*/
declare const toUpperCase: ITextTransformer;
export { type ITextTransformer, composeTextTransformers, toCamelCase, toCapitalCase, toConstantCase, toDotCase, toKebabCase, toLowerCase, toPascalCase, toPathCase, toSentenceCase, toSnakeCase, toTitleCase, toTrim, toUpperCase };