Utilities for processing strings or stringify other type data.
-
npm
npm install --save-dev @guanghechen/string
-
yarn
yarn add --dev @guanghechen/string
-
transformer
utilitiesName Description toCamelCase
'test string' => 'testString'
toCapitalCase
'test string' => 'Test String'
toConstantCase
'test string' => 'TEST_STRING'
toDotCase
'test string' => 'test.string'
toKebabCase
'test string' => 'test-string'
toLowerCase
'TEST STRING' => 'test string'
toPascalCase
'test string' => 'TestString'
toPathCase
'test string' => 'test/string'
toSentenceCase
'testString' => 'Test string'
toSnakeCase
'test string' => 'test_string'
toTitleCase
'a simple test' => 'A Simple Test'
toUpperCase
'test string' => 'TEST STRING'
-
composeTextTransformers
: Compose multiple ITextTransformer into one.import { composeTextTransformers, toKebabCase, toTrim, } from '@guanghechen/string' // function composeTextTransformers ( // ...transformers: ReadonlyArray<ITextTransformer> // ): ITextTransformer const transform = composeTextTransformers(toTrim, toKebabCase) const text: string = transform(' TeSt_StrinG ') // => 'test-string'
-