String
String manipulation utilities for formatting and transforming text.
Installation
typescript
import * as string from '@beerush/utils/global/string'
// or
import { toCamelCase } from '@beerush/utils/global/string'Functions
toCamelCase
Convert string into camelCase format.
typescript
toCamelCase<T extends string>(text: T): CamelCase<T>toKebabCase
Convert string into kebab-case format.
typescript
toKebabCase<T extends string>(text: T): KebabCase<T>toPascalCase
Convert string into PascalCase format.
typescript
toPascalCase<T extends string>(text: T): PascalCase<T>toSnakeCase
Convert string into snake_case format.
typescript
toSnakeCase<T extends string>(text: T): SnakeCase<T>capitalize
Convert string into capital format.
typescript
capitalize<T extends string>(text: T): Capitalize<T>humanize
Convert dash format into human-readable format, and optionally capitalize it.
typescript
humanize(text: string, capital?: boolean): stringdashify
Convert string such camelCase to dash format.
typescript
dashify(text: string): stringmakePath
Convert string into a path.
typescript
makePath(path: string): stringcleanPath
Make sure no double-slash in a path.
typescript
cleanPath(path: string): stringbase64
Convert string into a valid Base64 encoding.
typescript
base64(input: string, mime?: string): stringbase64Decode
Decode Base64 string.
typescript
base64Decode(input: string): stringcamelize
Convert string into camelCase format. (Deprecated: Use toCamelCase instead)
typescript
camelize(text: string): stringTypes
CamelCase<T>- Type for converting string literal types to camelCaseKebabCase<T>- Type for converting string literal types to kebab-casePascalCase<T>- Type for converting string literal types to PascalCaseSnakeCase<T>- Type for converting string literal types to snake_case