@kyco-utils/number 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8,6 +8,15 @@ const DEFAULT_DECIMAL_SEPARATOR = ".";
8
8
  * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
9
9
  * @returns The {@link NumberSeparators} for the locale.
10
10
  * @see {@link UserLocale} for the list of supported locales.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { UserLocale } from '@kyco-utils/enums'
15
+ * import { getNumberSeparators } from '@kyco-utils/number'
16
+ *
17
+ * getNumberSeparators(UserLocale.EN_GB) // { thousandsSeparator: ',', decimalSeparator: '.' }
18
+ * getNumberSeparators(UserLocale.DE_DE) // { thousandsSeparator: '.', decimalSeparator: ',' }
19
+ * ```
11
20
  */
12
21
  const getNumberSeparators = (locale) => {
13
22
  const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { UserLocale } from '@kyco-utils/enums'\nimport type { NumberSeparators } from '@kyco-utils/types'\n\nconst DEFAULT_THOUSANDS_SEPARATOR = ','\nconst DEFAULT_DECIMAL_SEPARATOR = '.'\n\n/**\n * Gets the thousands and decimal separators for a given locale\n *\n * @param locale - A supported {@link UserLocale} (BCP 47 language tag).\n * @returns The {@link NumberSeparators} for the locale.\n * @see {@link UserLocale} for the list of supported locales.\n */\nexport const getNumberSeparators = (locale: UserLocale): NumberSeparators => {\n // @locale-updates\n const parts = new Intl.NumberFormat(locale).formatToParts(12345.6)\n const thousandsSeparator = parts.find((part) => part.type === 'group')?.value ?? DEFAULT_THOUSANDS_SEPARATOR\n const decimalSeparator = parts.find((part) => part.type === 'decimal')?.value ?? DEFAULT_DECIMAL_SEPARATOR\n\n return { thousandsSeparator, decimalSeparator }\n}\n"],"mappings":";;AAGA,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;;;;;;;;AASlC,MAAa,uBAAuB,WAAyC;CAE3E,MAAM,QAAQ,IAAI,KAAK,aAAa,MAAM,CAAC,CAAC,cAAc,OAAO;CAIjE,OAAO;EAAE,oBAHkB,MAAM,MAAM,SAAS,KAAK,SAAS,OAAO,CAAC,EAAE,SAAS;EAGpD,kBAFJ,MAAM,MAAM,SAAS,KAAK,SAAS,SAAS,CAAC,EAAE,SAAS;CAEnC;AAChD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { UserLocale } from '@kyco-utils/enums'\nimport type { NumberSeparators } from '@kyco-utils/types'\n\nconst DEFAULT_THOUSANDS_SEPARATOR = ','\nconst DEFAULT_DECIMAL_SEPARATOR = '.'\n\n/**\n * Gets the thousands and decimal separators for a given locale\n *\n * @param locale - A supported {@link UserLocale} (BCP 47 language tag).\n * @returns The {@link NumberSeparators} for the locale.\n * @see {@link UserLocale} for the list of supported locales.\n *\n * @example\n * ```ts\n * import { UserLocale } from '@kyco-utils/enums'\n * import { getNumberSeparators } from '@kyco-utils/number'\n *\n * getNumberSeparators(UserLocale.EN_GB) // { thousandsSeparator: ',', decimalSeparator: '.' }\n * getNumberSeparators(UserLocale.DE_DE) // { thousandsSeparator: '.', decimalSeparator: ',' }\n * ```\n */\nexport const getNumberSeparators = (locale: UserLocale): NumberSeparators => {\n // @locale-updates\n const parts = new Intl.NumberFormat(locale).formatToParts(12345.6)\n const thousandsSeparator = parts.find((part) => part.type === 'group')?.value ?? DEFAULT_THOUSANDS_SEPARATOR\n const decimalSeparator = parts.find((part) => part.type === 'decimal')?.value ?? DEFAULT_DECIMAL_SEPARATOR\n\n return { thousandsSeparator, decimalSeparator }\n}\n"],"mappings":";;AAGA,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;;;;;;;;;;;;;;;;;AAkBlC,MAAa,uBAAuB,WAAyC;CAE3E,MAAM,QAAQ,IAAI,KAAK,aAAa,MAAM,CAAC,CAAC,cAAc,OAAO;CAIjE,OAAO;EAAE,oBAHkB,MAAM,MAAM,SAAS,KAAK,SAAS,OAAO,CAAC,EAAE,SAAS;EAGpD,kBAFJ,MAAM,MAAM,SAAS,KAAK,SAAS,SAAS,CAAC,EAAE,SAAS;CAEnC;AAChD"}
package/dist/index.d.cts CHANGED
@@ -6,6 +6,15 @@ import { NumberSeparators } from "@kyco-utils/types";
6
6
  * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
7
7
  * @returns The {@link NumberSeparators} for the locale.
8
8
  * @see {@link UserLocale} for the list of supported locales.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { UserLocale } from '@kyco-utils/enums'
13
+ * import { getNumberSeparators } from '@kyco-utils/number'
14
+ *
15
+ * getNumberSeparators(UserLocale.EN_GB) // { thousandsSeparator: ',', decimalSeparator: '.' }
16
+ * getNumberSeparators(UserLocale.DE_DE) // { thousandsSeparator: '.', decimalSeparator: ',' }
17
+ * ```
9
18
  */
10
19
  export declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
20
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;qBAaa,sBAAmB,QAAY,eAAa"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAsBa,sBAAmB,QAAY,eAAa"}
package/dist/index.d.mts CHANGED
@@ -6,6 +6,15 @@ import { NumberSeparators } from "@kyco-utils/types";
6
6
  * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
7
7
  * @returns The {@link NumberSeparators} for the locale.
8
8
  * @see {@link UserLocale} for the list of supported locales.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { UserLocale } from '@kyco-utils/enums'
13
+ * import { getNumberSeparators } from '@kyco-utils/number'
14
+ *
15
+ * getNumberSeparators(UserLocale.EN_GB) // { thousandsSeparator: ',', decimalSeparator: '.' }
16
+ * getNumberSeparators(UserLocale.DE_DE) // { thousandsSeparator: '.', decimalSeparator: ',' }
17
+ * ```
9
18
  */
10
19
  export declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
20
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;qBAaa,sBAAmB,QAAY,eAAa"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAsBa,sBAAmB,QAAY,eAAa"}
package/dist/index.mjs CHANGED
@@ -7,6 +7,15 @@ const DEFAULT_DECIMAL_SEPARATOR = ".";
7
7
  * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
8
8
  * @returns The {@link NumberSeparators} for the locale.
9
9
  * @see {@link UserLocale} for the list of supported locales.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { UserLocale } from '@kyco-utils/enums'
14
+ * import { getNumberSeparators } from '@kyco-utils/number'
15
+ *
16
+ * getNumberSeparators(UserLocale.EN_GB) // { thousandsSeparator: ',', decimalSeparator: '.' }
17
+ * getNumberSeparators(UserLocale.DE_DE) // { thousandsSeparator: '.', decimalSeparator: ',' }
18
+ * ```
10
19
  */
11
20
  const getNumberSeparators = (locale) => {
12
21
  const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { UserLocale } from '@kyco-utils/enums'\nimport type { NumberSeparators } from '@kyco-utils/types'\n\nconst DEFAULT_THOUSANDS_SEPARATOR = ','\nconst DEFAULT_DECIMAL_SEPARATOR = '.'\n\n/**\n * Gets the thousands and decimal separators for a given locale\n *\n * @param locale - A supported {@link UserLocale} (BCP 47 language tag).\n * @returns The {@link NumberSeparators} for the locale.\n * @see {@link UserLocale} for the list of supported locales.\n */\nexport const getNumberSeparators = (locale: UserLocale): NumberSeparators => {\n // @locale-updates\n const parts = new Intl.NumberFormat(locale).formatToParts(12345.6)\n const thousandsSeparator = parts.find((part) => part.type === 'group')?.value ?? DEFAULT_THOUSANDS_SEPARATOR\n const decimalSeparator = parts.find((part) => part.type === 'decimal')?.value ?? DEFAULT_DECIMAL_SEPARATOR\n\n return { thousandsSeparator, decimalSeparator }\n}\n"],"mappings":";AAGA,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;;;;;;;;AASlC,MAAa,uBAAuB,WAAyC;CAE3E,MAAM,QAAQ,IAAI,KAAK,aAAa,MAAM,CAAC,CAAC,cAAc,OAAO;CAIjE,OAAO;EAAE,oBAHkB,MAAM,MAAM,SAAS,KAAK,SAAS,OAAO,CAAC,EAAE,SAAS;EAGpD,kBAFJ,MAAM,MAAM,SAAS,KAAK,SAAS,SAAS,CAAC,EAAE,SAAS;CAEnC;AAChD"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { UserLocale } from '@kyco-utils/enums'\nimport type { NumberSeparators } from '@kyco-utils/types'\n\nconst DEFAULT_THOUSANDS_SEPARATOR = ','\nconst DEFAULT_DECIMAL_SEPARATOR = '.'\n\n/**\n * Gets the thousands and decimal separators for a given locale\n *\n * @param locale - A supported {@link UserLocale} (BCP 47 language tag).\n * @returns The {@link NumberSeparators} for the locale.\n * @see {@link UserLocale} for the list of supported locales.\n *\n * @example\n * ```ts\n * import { UserLocale } from '@kyco-utils/enums'\n * import { getNumberSeparators } from '@kyco-utils/number'\n *\n * getNumberSeparators(UserLocale.EN_GB) // { thousandsSeparator: ',', decimalSeparator: '.' }\n * getNumberSeparators(UserLocale.DE_DE) // { thousandsSeparator: '.', decimalSeparator: ',' }\n * ```\n */\nexport const getNumberSeparators = (locale: UserLocale): NumberSeparators => {\n // @locale-updates\n const parts = new Intl.NumberFormat(locale).formatToParts(12345.6)\n const thousandsSeparator = parts.find((part) => part.type === 'group')?.value ?? DEFAULT_THOUSANDS_SEPARATOR\n const decimalSeparator = parts.find((part) => part.type === 'decimal')?.value ?? DEFAULT_DECIMAL_SEPARATOR\n\n return { thousandsSeparator, decimalSeparator }\n}\n"],"mappings":";AAGA,MAAM,8BAA8B;AACpC,MAAM,4BAA4B;;;;;;;;;;;;;;;;;AAkBlC,MAAa,uBAAuB,WAAyC;CAE3E,MAAM,QAAQ,IAAI,KAAK,aAAa,MAAM,CAAC,CAAC,cAAc,OAAO;CAIjE,OAAO;EAAE,oBAHkB,MAAM,MAAM,SAAS,KAAK,SAAS,OAAO,CAAC,EAAE,SAAS;EAGpD,kBAFJ,MAAM,MAAM,SAAS,KAAK,SAAS,SAAS,CAAC,EAAE,SAAS;CAEnC;AAChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyco-utils/number",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Locale-aware number utilities for kyco-utils.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -31,8 +31,8 @@
31
31
  "module": "./dist/index.mjs",
32
32
  "types": "./dist/index.d.cts",
33
33
  "dependencies": {
34
- "@kyco-utils/enums": "^0.1.2",
35
- "@kyco-utils/types": "^0.1.2"
34
+ "@kyco-utils/enums": "^0.1.3",
35
+ "@kyco-utils/types": "^0.1.3"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public",