Standard utilities codes.
-
npm
npm install --save-dev @guanghechen/std
-
yarn
yarn add --dev @guanghechen/std
-
is
Name Description isArray
Check if the given data is a Array
typeisBigint
Check if the given data is a bigint
typeisBoolean
Check if the given data is a boolean
/Boolean
typeisDate
Check if the given data is a Date
typeisFunction
Check if the given data is a Function
typeisInteger
Check if the given data is a Integer
typeisNumber
Check if the given data is a number
/Number
typeisObject
Check if the given data is a Object
typeisString
Check if the given data is a string
/String
typeisSymbol
Check if the given data is a symbol
typeisUndefined
Check if the given data is a undefined
typeisPlainObject
Check if the given value is a plain object. isPrimitiveBoolean
Check if the given data is a boolean
typeisPrimitiveInteger
Check if the given data is a integer
typeisPrimitiveNumber
Check if the given data is a number
typeisPrimitiveString
Check if the given data is a string
typeisNonBlankString
Check if the given data is an non-blank string
/String
typeisNotEmptyArray
Check if the given data is an not-empty Array
typeisNotEmptyObject
Check if the given data is an not-empty Object
typeisEmptyObject
Check if the given data is an empty Object
typeisNumberLike
Check if the given data is an number
/Number
or number likestring
type -
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/std' // function composeTextTransformers ( // ...transformers: ReadonlyArray<ITextTransformer> // ): ITextTransformer const transform = composeTextTransformers(toTrim, toKebabCase) const text: string = transform(' TeSt_StrinG ') // => 'test-string'
-