Skip to main content

Module: utils

Type Aliases

Parseable

Ƭ Parseable: string | number | boolean | null | undefined | Record<string, unknown>

A value that can be stringified using one of the util functions.

Defined in

src/utils.ts:15


DeepRequired

Ƭ DeepRequired<T>: { [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : NonNullable<T[P]> }

A type that makes all properties of an object required, recursively.

Type parameters

Name
T

Defined in

src/utils.ts:18

Functions

strConcat

strConcat(...strs): string

Concatenates strings, arrays of strings, and objects with truthy values.

It works recursively, so adding an array of strings to an array of strings will work.

Falsy values are ignored, so pasing undefined or null will not add anything to the result, and using a boolean will only add it if it is true. Using 0 will also not add anything.

Parameters

NameType
...strs(Parseable | Parseable[])[]

Returns

string

Defined in

src/utils.ts:30


indent

indent(str, indent?): string

Indents a string or an array of strings. Concatenates them all using strConcat.

Parameters

NameTypeDefault value
strParseable | Parseable[]undefined
indentnumber2

Returns

string

Defined in

src/utils.ts:63


capitalize

capitalize(str): string

Parameters

NameType
strstring

Returns

string

Defined in

src/utils.ts:91


splitWords

splitWords(str): string[]

Splits a name into words, using camelCase, PascalCase, snake_case, and kebab-case or regular spaced strings.

Parameters

NameType
strstring

Returns

string[]

Defined in

src/utils.ts:99


toCamelCase

toCamelCase(str): string

Parameters

NameType
strstring

Returns

string

Defined in

src/utils.ts:111


toPascalCase

toPascalCase(str): string

Parameters

NameType
strstring

Returns

string

Defined in

src/utils.ts:117


getErrorMessage

getErrorMessage(err): string

Parameters

NameType
errunknown

Returns

string

Defined in

src/utils.ts:123