Skip to content

TitleCase

Functions

Number(number)string

Formats a number to a string with thousand separators.

TitleCase(str)string

Formats a string to title case.

SentenceCase(str)string

Formats a string to sentence case.

CamelCase(str)string

Formats a string to camel case.

KebabCase(str)string

Formats a string to kebab case.

SnakeCase(str)string

Formats a string to snake case.

DateFor(date, [order])string

Formats a date as a string with a customizable order of day, month and year.

Number(number) ⇒ string

Formats a number to a string with thousand separators.

Kind: global function
Returns: string - The formatted string.

ParamTypeDescription
numbernumberThe number to format.

Example

console.log(formats.Number(10000))

TitleCase(str) ⇒ string

Formats a string to title case.

Kind: global function
Returns: string - The formatted string.

ParamTypeDescription
strstringThe string to format. console.log(formats.TitleCase(“Example of text”))

SentenceCase(str) ⇒ string

Formats a string to sentence case.

Kind: global function
Returns: string - The formatted string.

ParamTypeDescription
strstringThe string to format. console.log(formats.SentenceCase(“Example Of Text”))

CamelCase(str) ⇒ string

Formats a string to camel case.

Kind: global function
Returns: string - The formatted string.

ParamTypeDescription
strstringThe string to format. console.log(formats.CamelCase(“Example of text”))

KebabCase(str) ⇒ string

Formats a string to kebab case.

Kind: global function
Returns: string - The formatted string.

ParamTypeDescription
strstringThe string to format. console.log(formats.KebabCase(“Example of text”))

SnakeCase(str) ⇒ string

Formats a string to snake case.

Kind: global function
Returns: string - The formatted string.

ParamTypeDescription
strstringThe string to format. console.log(formats.SnakeCase(“Example of text”))

DateFor(date, [order]) ⇒ string

Formats a date as a string with a customizable order of day, month and year.

Kind: global function
Returns: string - A string representation of the date.

ParamTypeDefaultDescription
dateDateThe date to format.
[order]string”"dmy"“The order in which to display the day, month and year. Can be “dmy”, “mdy”, “ymd”, “ydm”, “myd” or “dym”.

Example

console.log(formats.DateFor(new Date(), "dmy"))
console.log(formats.DateFor(new Date(), "mdy"))
console.log(formats.DateFor(new Date(), "ymd"))
console.log(formats.DateFor(new Date(), "ydm"))
console.log(formats.DateFor(new Date(), "myd"))
console.log(formats.DateFor(new Date(), "dym"))