Skip to content

Latest commit

 

History

History
145 lines (81 loc) · 3.03 KB

File metadata and controls

145 lines (81 loc) · 3.03 KB

dummy-typescript-api


dummy-typescript-api

This module contains generic utility functions useful for various operations.

Utilities include formatting currencies, manipulating strings, generating identifiers, and validating inputs.

Functions

formatCurrency()

formatCurrency(amount, currencyCode): string

Defined in: utilities.ts:17

Formats a number as currency with a given currency code. Utilizes the Intl.NumberFormat API to handle locale-specific currency formatting.

Parameters

Parameter Type Description
amount number The numeric value to be formatted.
currencyCode string The ISO currency code (e.g., USD, EUR) to specify the currency.

Returns

string

The formatted currency string in the format "$1,234.56".


generateUniqueId()

generateUniqueId(): string

Defined in: utilities.ts:41

Converts a string to title case, making the first character of each word uppercase. Effective for formatting titles or names in a readable format.

Returns

string

The string transformed to title case.


isValidEmail()

isValidEmail(email): boolean

Defined in: utilities.ts:65

Function to check if a value is a valid email address.

Parameters

Parameter Type Description
email string The email address to be validated.

Returns

boolean

True if the email address is valid, false otherwise.


shuffleArray()

shuffleArray<T>(array): T[]

Defined in: utilities.ts:75

Function to shuffle an array.

Type Parameters

Type Parameter
T

Parameters

Parameter Type Description
array T[] The array to be shuffled.

Returns

T[]

The shuffled array.


toTitleCase()

toTitleCase(input): string

Defined in: utilities.ts:29

Function to convert a string to title case.

Parameters

Parameter Type Description
input string The input string.

Returns

string

The input string in title case.


truncateString()

truncateString(input, maxLength): string

Defined in: utilities.ts:53

Function to truncate a string to a specified length.

Parameters

Parameter Type Description
input string The input string.
maxLength number The maximum length of the truncated string.

Returns

string

The truncated string.