Skip to content

IFormatterService

katanakit-js / IFormatterService

Defined in: types/core/formatter.ts:4

Contract of the formatter facade.

useCapitalize(text, locale?): string;

Defined in: types/core/formatter.ts:5

Parameter Type
text string
locale? "en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh"

string


useFormatCurrency(options): string;

Defined in: types/core/formatter.ts:6

Parameter Type Description
options { amount: number; currency?: | "USD" | "EUR" | "GBP" | "JPY" | "CHF" | "CAD" | "AUD" | "NZD" | "MXN" | "BRL" | "ARS" | "COP" | "CLP" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "RON" | "TRY" | "ISK" | "CNY" | "HKD" | "SGD" | "INR" | "KRW" | "THB" | "IDR" | "MYR" | "PHP" | "ILS" | "ZAR"; digits?: number; locale?: "en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh"; taxes?: number; } -
options.amount? number -
options.currency? | "USD" | "EUR" | "GBP" | "JPY" | "CHF" | "CAD" | "AUD" | "NZD" | "MXN" | "BRL" | "ARS" | "COP" | "CLP" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "RON" | "TRY" | "ISK" | "CNY" | "HKD" | "SGD" | "INR" | "KRW" | "THB" | "IDR" | "MYR" | "PHP" | "ILS" | "ZAR" -
options.digits? number Exact number of fraction digits in the output. Omit it to keep each currency’s own digits as Intl defines them ("¥100", "$1.00"); pass 2 to pin exactly two decimals ("¥100.00").
options.locale? "en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh" -
options.taxes? number Tax rate: percentage when > 1 (e.g. 21 → 21%), or decimal fraction when in (0, 1] (e.g. 0.21 → 21%). Prefer a fraction for rates ≤ 1%.

string


useFormatNumber(
value,
locale?,
digits?
): string;

Defined in: types/core/formatter.ts:7

Parameter Type
value number
locale? "en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh"
digits? number

string


useJsonParse<T>(json): T;

Defined in: types/core/formatter.ts:9

Type Parameter Default type
T unknown
Parameter Type
json string

T


useJsonStringify(data): string;

Defined in: types/core/formatter.ts:10

Parameter Type
data unknown

string


useLowerCase(text, locale?): string;

Defined in: types/core/formatter.ts:11

Parameter Type
text string
locale? "en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh"

string


useSalePrice(options): SalePrice;

Defined in: types/core/formatter.ts:8

Parameter Type Description
options { discount: number; price: number; } -
options.discount? number Discount rate: percentage when > 1 (e.g. 40 → 40%), or decimal fraction when in (0, 1] (e.g. 0.4 → 40%). Same convention as taxes.
options.price? number Regular price, before the discount.

SalePrice


useUpperCase(text, locale?): string;

Defined in: types/core/formatter.ts:12

Parameter Type
text string
locale? "en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh"

string