From d856d8451a0d48fd9d7532aa133d0e79febeed2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Mon, 17 Oct 2022 12:38:20 +0200 Subject: [PATCH] docs: autogenerate API reference with Typedoc (#127) --- .github/workflows/docs.yaml | 29 +++ .gitignore | 1 + README.md | 317 ++------------------------------- package.json | 4 + src/lib/number-format/index.ts | 208 ++++++++++++++++++++- src/lib/number-format/intl.ts | 1 + typedoc.json | 6 + yarn.lock | 53 +++++- 8 files changed, 312 insertions(+), 307 deletions(-) create mode 100644 .github/workflows/docs.yaml create mode 100644 typedoc.json diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..c9787d2 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,29 @@ +name: Documentation + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Use Node.js v16.13 + uses: actions/setup-node@v2 + with: + node-version: 16.13 + cache: 'yarn' + - name: Install dependencies + run: yarn --pure-lockfile --prefer-offline + - name: Generate documentation + run: yarn docs + - name: Upload documentation to GitHub Wiki + uses: SwiftDocOrg/github-wiki-publish-action@v1 + with: + path: 'docs' + env: + GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_ACTIONS_PAT }} diff --git a/.gitignore b/.gitignore index abd3780..029ea06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Project dist +docs junit.xml __coverage__ __reports__ diff --git a/README.md b/README.md index dbbac4c..0782b48 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,7 @@ Format 🔢 numbers and 💱currency values for any locale with the [ECMAScript - [Installation](#installation) - [Usage](#usage) - - [Format as string](#format-as-string) - - [Format as parts](#format-as-parts) - - [Resolve format](#resolve-format) - - [Constants](#constants) +- [API reference](https://github.com/sumup-oss/intl-js/wiki/Exports) - [Code of Conduct](#code-of-conduct) - [About SumUp](#about-sumup) @@ -42,309 +39,25 @@ $ npm install @sumup/intl All functions exported by `@sumup/intl` share a similar interface such as the common [`locales`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument), [`options`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#options_argument), and [`currency`](https://en.wikipedia.org/wiki/ISO_4217) arguments. These are passed on almost unchanged to the [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) constructor and thus support the same values. If the `locales` argument is not provided or is undefined, the runtime's default locale is used. Please refer to the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) for more details. -### Format as string +## API reference -#### `formatNumber` +### Number Functions -Formats a number according to the locale with support for various [styles, units](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_style_and_unit), and [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). +- [formatNumber](https://github.com/sumup-oss/intl-js/wiki/Exports#formatnumber) +- [formatNumberToParts](https://github.com/sumup-oss/intl-js/wiki/Exports#formatnumbertoparts) +- [resolveNumberFormat](https://github.com/sumup-oss/intl-js/wiki/Exports#resolvenumberformat) -**Arguments** +### Currency Functions -| Name | Type | Examples | -| -------- | ------------------------ | ------------------------------------------------------- | -| value | number | `12345.67`, `-0.89` | -| locales? | string \| string[] | `'de-DE'`, `'DE'`, `'zh-Hans-CN'`, `['de-AT', 'de-DE']` | -| options? | Intl.NumberFormatOptions | `{ style: 'unit', unit: 'mile-per-hour' }` | +- [formatCurrency](https://github.com/sumup-oss/intl-js/wiki/Exports#formatcurrency) +- [formatCurrencyToParts](https://github.com/sumup-oss/intl-js/wiki/Exports#formatcurrencytoparts) +- [resolveCurrencyFormat](https://github.com/sumup-oss/intl-js/wiki/Exports#resolvecurrencyformat) -**Examples** +### Variables -```ts -import { formatNumber } from '@sumup/intl'; - -formatNumber(12345.67, 'de-DE'); // '12.345,67' -formatNumber(-0.89, ['ban', 'id']); // '-0,89' -formatNumber(16, 'en-GB', { - style: 'unit', - unit: 'liter', - unitDisplay: 'long', -}); // 16 litres -``` - -#### `formatCurrency` - -Formats a number according to the locale in the country's official currency with support for various [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). - -**Arguments** - -| Name | Type | Examples | -| --------- | ------------------------ | ------------------------------------------------------- | -| value | number | `12345.67`, `-0.89` | -| locales? | string \| string[] | `'de-DE'`, `'DE'`, `'zh-Hans-CN'`, `['de-AT', 'de-DE']` | -| currency? | string | `'EUR'`, `'BRL'`, `'USD'` | -| options? | Intl.NumberFormatOptions | `{ style: 'unit', unit: 'mile-per-hour' }` | - -**Examples** - -```ts -import { formatCurrency } from '@sumup/intl'; - -formatCurrency(12345.67, 'de-DE'); // '12.345,67 €' -formatCurrency(89, 'ja-JP', 'JPY'); // '¥89' -formatCurrency(16, 'en-GB', null, { currencyDisplay: 'name' }); // '16.00 British pounds' -``` - -### Format as parts - -#### `formatNumberToParts` - -Formats a number according to the locale with support for various [styles, units](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_style_and_unit), and [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). - -**Arguments** - -| Name | Type | Examples | -| -------- | ------------------------ | ------------------------------------------------------- | -| value | number | `12345.67`, `-0.89` | -| locales? | string \| string[] | `'de-DE'`, `'DE'`, `'zh-Hans-CN'`, `['de-AT', 'de-DE']` | -| options? | Intl.NumberFormatOptions | `{ style: 'unit', unit: 'mile-per-hour' }` | - -```ts -import { formatNumberToParts } from '@sumup/intl'; - -formatNumberToParts(12345.67, 'de-DE'); -// [ -// { type: "integer", value: "12" }, -// { type: "group", value: "." }, -// { type: "integer", value: "345" }, -// { type: "decimal", value: "," }, -// { type: "fraction", value: "67" }, -// ] - -formatNumberToParts(-0.89, ['ban', 'id']); -// [ -// { type: "minusSign", value: "-" }, -// { type: "integer", value: "0" }, -// { type: "decimal", value: "," }, -// { type: "fraction", value: "89" }, -// ] - -formatNumberToParts(16, 'en-GB', { - style: 'unit', - unit: 'liter', - unitDisplay: 'long', -}); -// [ -// { type: "integer", value: "16" }, -// { type: "literal", value: " " }, -// { type: "unit", value: "litres" }, -// ] -``` - -#### `formatCurrencyToParts` - -Formats a number according to the locale in the country's official currency with support for various [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). - -**Arguments** - -| Name | Type | Examples | -| --------- | ------------------------ | ------------------------------------------------------- | -| value | number | `12345.67`, `-0.89` | -| locales? | string \| string[] | `'de-DE'`, `'DE'`, `'zh-Hans-CN'`, `['de-AT', 'de-DE']` | -| currency? | string | `'EUR'`, `'BRL'`, `'USD'` | -| options? | Intl.NumberFormatOptions | `{ style: 'unit', unit: 'mile-per-hour' }` | - -**Examples** - -```ts -import { formatCurrencyToParts } from '@sumup/intl'; - -formatCurrencyToParts(12345.67, 'de-DE'); -// [ -// { type: "integer", value: "12" }, -// { type: "group", value: "." }, -// { type: "integer", value: "345" }, -// { type: "decimal", value: "," }, -// { type: "fraction", value: "67" }, -// { type: "literal", value: " " }, -// { type: "currency", value: "€" }, -// ] - -formatCurrencyToParts(-89, 'ja-JP', 'JPY'); -// [ -// { type: "minusSign", value: "-" }, -// { type: "currency", value: "¥" }, -// { type: "integer", value: "89" }, -// ] - -formatCurrencyToParts(16, 'en-GB', null, { currencyDisplay: 'name' }); -// [ -// { type: "integer", value: "16" }, -// { type: "decimal", value: "." }, -// { type: "fraction", value: "00" }, -// { type: "literal", value: " " }, -// { type: "currency", value: "British pounds" }, -// ] -``` - -### Resolve format - -#### `resolveNumberFormat` - -Resolves the locale and collation options that are used to format a number. - -**Arguments** - -| Name | Type | Examples | -| -------- | ------------------------ | ------------------------------------------------------- | -| locales? | string \| string[] | `'de-DE'`, `'DE'`, `'zh-Hans-CN'`, `['de-AT', 'de-DE']` | -| options? | Intl.NumberFormatOptions | `{ style: 'unit', unit: 'mile-per-hour' }` | - -**Examples** - -```ts -import { resolveNumberFormat } from '@sumup/intl'; - -resolveNumberFormat(); -// { -// 'locale': 'en-US', -// 'numberingSystem': 'latn', -// 'style': 'decimal', -// 'minimumIntegerDigits': 1, -// 'minimumFractionDigits': 0, -// 'maximumFractionDigits': 3, -// 'useGrouping': true, -// 'groupDelimiter': ',', -// 'decimalDelimiter': '.', -// } - -resolveNumberFormat(['ban', 'id']); -// { -// 'locale': 'id', -// 'numberingSystem': 'latn', -// 'style': 'decimal', -// 'minimumIntegerDigits': 1, -// 'minimumFractionDigits': 0, -// 'maximumFractionDigits': 3, -// 'useGrouping': true, -// 'groupDelimiter': '.', -// 'decimalDelimiter': ',', -// } - -resolveNumberFormat('en-GB', { - style: 'unit', - unit: 'liter', - unitDisplay: 'long', -}); -// { -// 'locale': 'en-GB', -// 'numberingSystem': 'latn', -// 'style': 'unit', -// 'unit': 'liter', -// 'unitDisplay': 'long', -// 'minimumIntegerDigits': 1, -// 'minimumFractionDigits': 0, -// 'maximumFractionDigits': 3, -// 'useGrouping': true, -// 'notation': 'standard', -// 'signDisplay': 'auto', -// 'groupDelimiter': ',', -// 'decimalDelimiter': '.', -// } -``` - -#### `resolveCurrencyFormat` - -Resolves the locale and collation options that are used to format a number in the country's official currency. - -**Arguments** - -| Name | Type | Examples | -| --------- | ------------------------ | ------------------------------------------------------- | -| locales? | string \| string[] | `'de-DE'`, `'DE'`, `'zh-Hans-CN'`, `['de-AT', 'de-DE']` | -| currency? | string | `'EUR'`, `'BRL'`, `'USD'` | -| options? | Intl.NumberFormatOptions | `{ style: 'unit', unit: 'mile-per-hour' }` | - -**Examples** - -```ts -import { resolveCurrencyFormat } from '@sumup/intl'; - -resolveCurrencyFormat(); -// { -// 'locale': 'en-US', -// 'numberingSystem': 'latn', -// 'style': 'currency', -// 'currency': 'USD', -// 'currencyDisplay': 'symbol', -// 'minimumIntegerDigits': 1, -// 'minimumFractionDigits': 2, -// 'maximumFractionDigits': 2, -// 'useGrouping': true, -// 'groupDelimiter': '.', -// 'decimalDelimiter': ',', -// 'currencySymbol': '$', -// 'currencyPosition': 'prefix', -// } - -resolveCurrencyFormat('ja-JP'); -// { -// 'locale': 'ja-JP', -// 'numberingSystem': 'latn', -// 'style': 'currency', -// 'currency': 'JPY', -// 'currencyDisplay': 'symbol', -// 'minimumIntegerDigits': 1, -// 'minimumFractionDigits': 0, -// 'maximumFractionDigits': 0, -// 'useGrouping': true, -// 'groupDelimiter': ',', -// 'decimalDelimiter': undefined, -// 'currencySymbol': '¥', -// 'currencyPosition': 'prefix', -// } - -resolveCurrencyFormat('en-GB', { currencyDisplay: 'name' }); -// { -// 'locale': 'en-GB', -// 'numberingSystem': 'latn', -// 'style': 'currency', -// 'currency': 'GBP', -// 'currencyDisplay': 'symbol', -// 'minimumIntegerDigits': 1, -// 'minimumFractionDigits': 2, -// 'maximumFractionDigits': 2, -// 'useGrouping': true, -// 'groupDelimiter': ',', -// 'decimalDelimiter': '.', -// 'currencySymbol': 'British pounds', -// 'currencyPosition': 'suffix', -// } -``` - -### Constants - -#### `isNumberFormatSupported` - -Whether the `Intl` and `Intl.NumberFormat` APIs are supported by the runtime. - -```ts -const isNumberFormatSupported: boolean; -``` - -#### `isNumberFormatToPartsSupported` - -Whether the `Intl`, `Intl.NumberFormat`, and `Intl.NumberFormat.formatToParts` APIs are supported by the runtime. - -```ts -const isNumberFormatToPartsSupported: boolean; -``` - -#### `CURRENCIES` - -An object that maps a 2 char country code to its official 3 char currency code. [View all supported countries](https://github.com/sumup-oss/intl-js/blob/main/src/data/currencies.ts). - -```ts -const CURRENCIES: { [country: string]: string }; -``` +- [CURRENCIES](https://github.com/sumup-oss/intl-js/wiki/Exports#currencies) +- [isNumberFormatSupported](https://github.com/sumup-oss/intl-js/wiki/Exports#isnumberformatsupported) +- [isNumberFormatToPartsSupported](https://github.com/sumup-oss/intl-js/wiki/Exports#isnumberformattopartssupported) ## Code of Conduct @@ -361,6 +74,6 @@ If you feel another member of the community violated our CoC or you are experien ![SumUp logo](https://raw.githubusercontent.com/sumup-oss/assets/master/sumup-logo.svg?sanitize=true) -[SumUp](https://sumup.com) is a mobile-point of sale provider. It is our mission to make easy and fast card payments a reality across the _entire_ world. You can pay with SumUp in more than 30 countries, already. Our engineers work in Berlin, Cologne, Sofia, and Sāo Paulo. They write code in JavaScript, Swift, Ruby, Go, Java, Erlang, Elixir, and more. +[SumUp](https://sumup.com) is a mobile point-of-sale provider. It is our mission to make easy and fast card payments a reality across the _entire_ world. You can pay with SumUp in more than 30 countries, already. Our engineers work in Berlin, Cologne, Sofia, and Sāo Paulo. They write code in JavaScript, Swift, Ruby, Go, Java, Erlang, Elixir, and more. Want to come work with us? [Head to our careers page](https://sumup.com/careers) to find out more. diff --git a/package.json b/package.json index e707f6a..5d40105 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "build": "yarn build:es && yarn build:cjs", "build:es": "tsc", "build:cjs": "tsc --project tsconfig.cjs.json", + "docs": "typedoc", "lint": "foundry run eslint . --ext .js,.jsx,.ts,.tsx", "lint:fix": "yarn lint --fix", "lint:ci": "yarn lint --format github", @@ -54,6 +55,9 @@ "jest-github-reporter": "^1.0.2", "license-checker": "^25.0.1", "ts-jest": "^29.0.3", + "typedoc": "^0.23.16", + "typedoc-github-wiki-theme": "^1.0.1", + "typedoc-plugin-markdown": "^3.13.6", "typescript": "^4.3.2" } } diff --git a/src/lib/number-format/index.ts b/src/lib/number-format/index.ts index fae01c3..4701e27 100644 --- a/src/lib/number-format/index.ts +++ b/src/lib/number-format/index.ts @@ -43,9 +43,22 @@ type GetOptions = ( ) => NumericOptions; /** - * Formats a number according to the locale with support for various + * Formats a number with support for various * [styles, units](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_style_and_unit), * and [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). + * + * @example + * import { formatNumber } from '@sumup/intl'; + * + * formatNumber(12345.67, 'de-DE'); // '12.345,67' + * formatNumber(-0.89, ['ban', 'id']); // '-0,89' + * formatNumber(16, 'en-GB', { + * style: 'unit', + * unit: 'liter', + * unitDisplay: 'long', + * }); // 16 litres + * + * @category Number */ export const formatNumber = formatNumberFactory(getNumberOptions) as ( value: number, @@ -55,12 +68,22 @@ export const formatNumber = formatNumberFactory(getNumberOptions) as ( /** * @deprecated Use {@link formatNumber} instead. + * @hidden */ export const format = formatNumber; /** - * Formats a number according to the locale in the country's official currency + * Formats a number in the country's official currency * with support for various [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). + * + * @example + * import { formatCurrency } from '@sumup/intl'; + * + * formatCurrency(12345.67, 'de-DE'); // '12.345,67 €' + * formatCurrency(89, 'ja-JP', 'JPY'); // '¥89' + * formatCurrency(16, 'en-GB', null, { currencyDisplay: 'name' }); // '16.00 British pounds' + * + * @category Currency */ export const formatCurrency = formatNumberFactory(getCurrencyOptions) as ( value: number, @@ -85,9 +108,42 @@ function formatNumberFactory( } /** - * Formats a number according to the locale with support for various + * Formats a number with support for various * [styles, units](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_style_and_unit), * and [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). + * + * @example + * import { formatNumberToParts } from '@sumup/intl'; + * + * formatNumberToParts(12345.67, 'de-DE'); + * // [ + * // { type: "integer", value: "12" }, + * // { type: "group", value: "." }, + * // { type: "integer", value: "345" }, + * // { type: "decimal", value: "," }, + * // { type: "fraction", value: "67" }, + * // ] + * + * formatNumberToParts(-0.89, ['ban', 'id']); + * // [ + * // { type: "minusSign", value: "-" }, + * // { type: "integer", value: "0" }, + * // { type: "decimal", value: "," }, + * // { type: "fraction", value: "89" }, + * // ] + * + * formatNumberToParts(16, 'en-GB', { + * style: 'unit', + * unit: 'liter', + * unitDisplay: 'long', + * }); + * // [ + * // { type: "integer", value: "16" }, + * // { type: "literal", value: " " }, + * // { type: "unit", value: "litres" }, + * // ] + * + * @category Number */ export const formatNumberToParts = formatNumberToPartsFactory( getNumberOptions, @@ -99,12 +155,46 @@ export const formatNumberToParts = formatNumberToPartsFactory( /** * @deprecated Use {@link formatNumberToParts} instead. + * @hidden */ export const formatToParts = formatNumberToParts; +/* eslint-disable no-irregular-whitespace */ /** - * Formats a number according to the locale in the country's official currency + * Formats a number in the country's official currency * with support for various [notations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_notation). + * + * @example + * import { formatCurrencyToParts } from '@sumup/intl'; + * + * formatCurrencyToParts(12345.67, 'de-DE'); + * // [ + * // { type: "integer", value: "12" }, + * // { type: "group", value: "." }, + * // { type: "integer", value: "345" }, + * // { type: "decimal", value: "," }, + * // { type: "fraction", value: "67" }, + * // { type: "literal", value: " " }, + * // { type: "currency", value: "€" }, + * // ] + * + * formatCurrencyToParts(-89, 'ja-JP', 'JPY'); + * // [ + * // { type: "minusSign", value: "-" }, + * // { type: "currency", value: "¥" }, + * // { type: "integer", value: "89" }, + * // ] + * + * formatCurrencyToParts(16, 'en-GB', null, { currencyDisplay: 'name' }); + * // [ + * // { type: "integer", value: "16" }, + * // { type: "decimal", value: "." }, + * // { type: "fraction", value: "00" }, + * // { type: "literal", value: " " }, + * // { type: "currency", value: "British pounds" }, + * // ] + * + * @category Currency */ export const formatCurrencyToParts = formatNumberToPartsFactory( getCurrencyOptions, @@ -114,6 +204,7 @@ export const formatCurrencyToParts = formatNumberToPartsFactory( currency?: Currency, options?: Intl.NumberFormatOptions, ) => Intl.NumberFormatPart[]; +/* eslint-enable no-irregular-whitespace */ function formatNumberToPartsFactory( getOptions: T, @@ -134,6 +225,58 @@ function formatNumberToPartsFactory( /** * Resolves the locale and collation options that are used to format a number. + * + * @example + * import { resolveNumberFormat } from '@sumup/intl'; + * + * resolveNumberFormat(); + * // { + * // 'locale': 'en-US', + * // 'numberingSystem': 'latn', + * // 'style': 'decimal', + * // 'minimumIntegerDigits': 1, + * // 'minimumFractionDigits': 0, + * // 'maximumFractionDigits': 3, + * // 'useGrouping': true, + * // 'groupDelimiter': ',', + * // 'decimalDelimiter': '.', + * // } + * + * resolveNumberFormat(['ban', 'id']); + * // { + * // 'locale': 'id', + * // 'numberingSystem': 'latn', + * // 'style': 'decimal', + * // 'minimumIntegerDigits': 1, + * // 'minimumFractionDigits': 0, + * // 'maximumFractionDigits': 3, + * // 'useGrouping': true, + * // 'groupDelimiter': '.', + * // 'decimalDelimiter': ',', + * // } + * + * resolveNumberFormat('en-GB', { + * style: 'unit', + * unit: 'liter', + * unitDisplay: 'long', + * }); + * // { + * // 'locale': 'en-GB', + * // 'numberingSystem': 'latn', + * // 'style': 'unit', + * // 'unit': 'liter', + * // 'unitDisplay': 'long', + * // 'minimumIntegerDigits': 1, + * // 'minimumFractionDigits': 0, + * // 'maximumFractionDigits': 3, + * // 'useGrouping': true, + * // 'notation': 'standard', + * // 'signDisplay': 'auto', + * // 'groupDelimiter': ',', + * // 'decimalDelimiter': '.', + * // } + * + * @category Number */ export const resolveNumberFormat = resolveNumberFormatFactory( getNumberOptions, @@ -144,12 +287,69 @@ export const resolveNumberFormat = resolveNumberFormatFactory( /** * @deprecated Use {@link resolveNumberFormat} instead. + * @hidden */ export const resolveFormat = resolveNumberFormat; /** * Resolves the locale and collation options that are used to format a number * in the country's official currency. + * + * @example + * import { resolveCurrencyFormat } from '@sumup/intl'; + * + * resolveCurrencyFormat(); + * // { + * // 'locale': 'en-US', + * // 'numberingSystem': 'latn', + * // 'style': 'currency', + * // 'currency': 'USD', + * // 'currencyDisplay': 'symbol', + * // 'minimumIntegerDigits': 1, + * // 'minimumFractionDigits': 2, + * // 'maximumFractionDigits': 2, + * // 'useGrouping': true, + * // 'groupDelimiter': '.', + * // 'decimalDelimiter': ',', + * // 'currencySymbol': '$', + * // 'currencyPosition': 'prefix', + * // } + * + * resolveCurrencyFormat('ja-JP'); + * // { + * // 'locale': 'ja-JP', + * // 'numberingSystem': 'latn', + * // 'style': 'currency', + * // 'currency': 'JPY', + * // 'currencyDisplay': 'symbol', + * // 'minimumIntegerDigits': 1, + * // 'minimumFractionDigits': 0, + * // 'maximumFractionDigits': 0, + * // 'useGrouping': true, + * // 'groupDelimiter': ',', + * // 'decimalDelimiter': undefined, + * // 'currencySymbol': '¥', + * // 'currencyPosition': 'prefix', + * // } + * + * resolveCurrencyFormat('en-GB', { currencyDisplay: 'name' }); + * // { + * // 'locale': 'en-GB', + * // 'numberingSystem': 'latn', + * // 'style': 'currency', + * // 'currency': 'GBP', + * // 'currencyDisplay': 'symbol', + * // 'minimumIntegerDigits': 1, + * // 'minimumFractionDigits': 2, + * // 'maximumFractionDigits': 2, + * // 'useGrouping': true, + * // 'groupDelimiter': ',', + * // 'decimalDelimiter': '.', + * // 'currencySymbol': 'British pounds', + * // 'currencyPosition': 'suffix', + * // } + * + * @category Currency */ export const resolveCurrencyFormat = resolveNumberFormatFactory( getCurrencyOptions, diff --git a/src/lib/number-format/intl.ts b/src/lib/number-format/intl.ts index 55fa83c..7d01a3b 100644 --- a/src/lib/number-format/intl.ts +++ b/src/lib/number-format/intl.ts @@ -46,6 +46,7 @@ export const isNumberFormatToPartsSupported = (() => { /** * @deprecated Use {@link isNumberFormatSupported} instead. + * @hidden */ export const isIntlSupported = isNumberFormatSupported; diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..51793e8 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,6 @@ +{ + "entryPoints": ["src/index.ts"], + "sort": ["source-order"], + "categoryOrder": ["Number", "Currency", "*"], + "theme": "github-wiki" +} diff --git a/yarn.lock b/yarn.lock index c59eaaa..0423848 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5084,6 +5084,11 @@ lru-cache@^7.4.4, lru-cache@^7.5.1, lru-cache@^7.7.1: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.10.1.tgz#db577f42a94c168f676b638d15da8fb073448cab" integrity sha512-BQuhQxPuRl79J5zSXRP+uNzPOyZw2oFI9JLRQ80XswSvg21KMKNtQza9eF42rfI/3Z40RvzBdXgziEkudzjo8A== +lunr@^2.3.9: + version "2.3.9" + resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1" + integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== + macos-release@^2.2.0: version "2.5.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.5.0.tgz#067c2c88b5f3fb3c56a375b2ec93826220fa1ff2" @@ -5184,6 +5189,11 @@ marked@^4.0.10: resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.16.tgz#9ec18fc1a723032eb28666100344d9428cf7a264" integrity sha512-wahonIQ5Jnyatt2fn8KqF/nIqZM8mh3oRu2+l5EANGMhu6RFjiSG52QNE2eWzFMI94HqYSgN184NurgNG6CztA== +marked@^4.0.19: + version "4.1.1" + resolved "https://registry.yarnpkg.com/marked/-/marked-4.1.1.tgz#2f709a4462abf65a283f2453dc1c42ab177d302e" + integrity sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw== + meow@^8.0.0: version "8.1.2" resolved "https://registry.yarnpkg.com/meow/-/meow-8.1.2.tgz#bcbe45bda0ee1729d350c03cffc8395a36c4e897" @@ -5256,7 +5266,7 @@ minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" -minimatch@^5.0.1: +minimatch@^5.0.1, minimatch@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.0.tgz#1717b464f4971b144f6aabe8f2d0b8e4511e09c7" integrity sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg== @@ -6692,6 +6702,15 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +shiki@^0.11.1: + version "0.11.1" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.11.1.tgz#df0f719e7ab592c484d8b73ec10e215a503ab8cc" + integrity sha512-EugY9VASFuDqOexOgXR18ZV+TbFrQHeCpEYaXamO+SZlsnT/2LxuLBX25GGtIrwaEVFXUAbUQ601SWE2rMwWHA== + dependencies: + jsonc-parser "^3.0.0" + vscode-oniguruma "^1.6.1" + vscode-textmate "^6.0.0" + side-channel@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" @@ -7352,6 +7371,28 @@ type-fest@^1.0.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.4.0.tgz#e9fb813fe3bf1744ec359d55d1affefa76f14be1" integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA== +typedoc-github-wiki-theme@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/typedoc-github-wiki-theme/-/typedoc-github-wiki-theme-1.0.1.tgz#412b9c9aeaa15f1360e79296c9dd186caf711e2c" + integrity sha512-FaO7fENGK6IJLpkddbNXxJfNbooF9KBC7xfk7Lj4uqG5SCC7YQFPTLDyNmbpJKO93QEenRYgqBwI5E5d/bKrHw== + +typedoc-plugin-markdown@^3.13.6: + version "3.13.6" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.13.6.tgz#a419794e3bdbe459fb22772d8e6e02bac05211c1" + integrity sha512-ISSc9v3BK7HkokxSBuJPttXox4tJ6hP0N9wfSIk0fmLN67+eqtAxbk97gs2nDiuha+RTO5eW9gdeAb+RPP0mgg== + dependencies: + handlebars "^4.7.7" + +typedoc@^0.23.16: + version "0.23.16" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.23.16.tgz#09881ada725c2190ac5d3bb0edadcc5bfeda4bfe" + integrity sha512-rumYsCeNRXlyuZVzefD7050n7ptL2uudsCJg50dY0v/stKniqIlRpvx/F/6expC0/Q6Dbab+g/JpZuB7Sw90FA== + dependencies: + lunr "^2.3.9" + marked "^4.0.19" + minimatch "^5.1.0" + shiki "^0.11.1" + typescript@^4.3.2: version "4.8.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" @@ -7495,6 +7536,16 @@ vscode-nls@^5.0.0: resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840" integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA== +vscode-oniguruma@^1.6.1: + version "1.6.2" + resolved "https://registry.yarnpkg.com/vscode-oniguruma/-/vscode-oniguruma-1.6.2.tgz#aeb9771a2f1dbfc9083c8a7fdd9cccaa3f386607" + integrity sha512-KH8+KKov5eS/9WhofZR8M8dMHWN2gTxjMsG4jd04YhpbPR91fUj7rYQ2/XjeHCJWbg7X++ApRIU9NUwM2vTvLA== + +vscode-textmate@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-6.0.0.tgz#a3777197235036814ac9a92451492f2748589210" + integrity sha512-gu73tuZfJgu+mvCSy4UZwd2JXykjK9zAZsfmDeut5dx/1a7FeTk0XwJsSuqQn+cuMCGVbIBfl+s53X4T19DnzQ== + vscode-uri@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-3.0.3.tgz#a95c1ce2e6f41b7549f86279d19f47951e4f4d84"