IFormatterService
katanakit-js / IFormatterService
Interface: IFormatterService
Section titled “Interface: IFormatterService”Defined in: types/core/formatter.ts:4
Contract of the formatter facade.
Methods
Section titled “Methods”useCapitalize()
Section titled “useCapitalize()”useCapitalize(text, locale?): string;Defined in: types/core/formatter.ts:5
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
locale? |
"en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh" |
Returns
Section titled “Returns”string
useFormatCurrency()
Section titled “useFormatCurrency()”useFormatCurrency(options): string;Defined in: types/core/formatter.ts:6
Parameters
Section titled “Parameters”| 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%. |
Returns
Section titled “Returns”string
useFormatNumber()
Section titled “useFormatNumber()”useFormatNumber( value, locale?, digits?): string;Defined in: types/core/formatter.ts:7
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
number |
locale? |
"en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh" |
digits? |
number |
Returns
Section titled “Returns”string
useJsonParse()
Section titled “useJsonParse()”useJsonParse<T>(json): T;Defined in: types/core/formatter.ts:9
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T |
unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
json |
string |
Returns
Section titled “Returns”T
useJsonStringify()
Section titled “useJsonStringify()”useJsonStringify(data): string;Defined in: types/core/formatter.ts:10
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data |
unknown |
Returns
Section titled “Returns”string
useLowerCase()
Section titled “useLowerCase()”useLowerCase(text, locale?): string;Defined in: types/core/formatter.ts:11
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
locale? |
"en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh" |
Returns
Section titled “Returns”string
useSalePrice()
Section titled “useSalePrice()”useSalePrice(options): SalePrice;Defined in: types/core/formatter.ts:8
Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”useUpperCase()
Section titled “useUpperCase()”useUpperCase(text, locale?): string;Defined in: types/core/formatter.ts:12
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
locale? |
"en" | "es" | "fr" | "de" | "it" | "pt" | "ja" | "zh" |
Returns
Section titled “Returns”string