@kyco-utils/number 0.1.1 → 0.1.2

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
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  // src/index.ts
4
+ var DEFAULT_THOUSANDS_SEPARATOR = ",";
5
+ var DEFAULT_DECIMAL_SEPARATOR = ".";
4
6
  var getNumberSeparators = (locale) => {
5
- const parts = new Intl.NumberFormat(locale).formatToParts(11111.1);
6
- const thousandsSeparator = parts.find((part) => part.type === "group")?.value ?? ",";
7
- const decimalSeparator = parts.find((part) => part.type === "decimal")?.value ?? ".";
7
+ const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
8
+ const thousandsSeparator = parts.find((part) => part.type === "group")?.value ?? DEFAULT_THOUSANDS_SEPARATOR;
9
+ const decimalSeparator = parts.find((part) => part.type === "decimal")?.value ?? DEFAULT_DECIMAL_SEPARATOR;
8
10
  return { thousandsSeparator, decimalSeparator };
9
11
  };
10
12
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AASO,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAyC;AAE3E,EAAA,MAAM,QAAQ,IAAI,IAAA,CAAK,aAAa,MAAM,CAAA,CAAE,cAAc,OAAO,CAAA;AACjE,EAAA,MAAM,kBAAA,GAAqB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,OAAO,CAAA,EAAG,KAAA,IAAS,GAAA;AACjF,EAAA,MAAM,gBAAA,GAAmB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,SAAS,CAAA,EAAG,KAAA,IAAS,GAAA;AACjF,EAAA,OAAO,EAAE,oBAAoB,gBAAA,EAAiB;AAChD","file":"index.cjs","sourcesContent":["import type { UserLocale } from '@kyco-utils/enums'\nimport type { NumberSeparators } from '@kyco-utils/types'\n\n/**\n * Gets the thousands and decimal separators for a given locale\n *\n * @param locale - The locale to get separators for\n * @returns Object containing `thousandsSeparator` and `decimalSeparator`\n */\nexport const getNumberSeparators = (locale: UserLocale): NumberSeparators => {\n // @locale-updates\n const parts = new Intl.NumberFormat(locale).formatToParts(11111.1)\n const thousandsSeparator = parts.find((part) => part.type === 'group')?.value ?? ','\n const decimalSeparator = parts.find((part) => part.type === 'decimal')?.value ?? '.'\n return { thousandsSeparator, decimalSeparator }\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAGA,IAAM,2BAAA,GAA8B,GAAA;AACpC,IAAM,yBAAA,GAA4B,GAAA;AAS3B,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAyC;AAE3E,EAAA,MAAM,QAAQ,IAAI,IAAA,CAAK,aAAa,MAAM,CAAA,CAAE,cAAc,OAAO,CAAA;AACjE,EAAA,MAAM,kBAAA,GAAqB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,OAAO,CAAA,EAAG,KAAA,IAAS,2BAAA;AACjF,EAAA,MAAM,gBAAA,GAAmB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,SAAS,CAAA,EAAG,KAAA,IAAS,yBAAA;AAEjF,EAAA,OAAO,EAAE,oBAAoB,gBAAA,EAAiB;AAChD","file":"index.cjs","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"]}
package/dist/index.d.cts CHANGED
@@ -4,8 +4,9 @@ import { NumberSeparators } from '@kyco-utils/types';
4
4
  /**
5
5
  * Gets the thousands and decimal separators for a given locale
6
6
  *
7
- * @param locale - The locale to get separators for
8
- * @returns Object containing `thousandsSeparator` and `decimalSeparator`
7
+ * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
8
+ * @returns The {@link NumberSeparators} for the locale.
9
+ * @see {@link UserLocale} for the list of supported locales.
9
10
  */
10
11
  declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
12
 
package/dist/index.d.ts CHANGED
@@ -4,8 +4,9 @@ import { NumberSeparators } from '@kyco-utils/types';
4
4
  /**
5
5
  * Gets the thousands and decimal separators for a given locale
6
6
  *
7
- * @param locale - The locale to get separators for
8
- * @returns Object containing `thousandsSeparator` and `decimalSeparator`
7
+ * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
8
+ * @returns The {@link NumberSeparators} for the locale.
9
+ * @see {@link UserLocale} for the list of supported locales.
9
10
  */
10
11
  declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
12
 
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  // src/index.ts
2
+ var DEFAULT_THOUSANDS_SEPARATOR = ",";
3
+ var DEFAULT_DECIMAL_SEPARATOR = ".";
2
4
  var getNumberSeparators = (locale) => {
3
- const parts = new Intl.NumberFormat(locale).formatToParts(11111.1);
4
- const thousandsSeparator = parts.find((part) => part.type === "group")?.value ?? ",";
5
- const decimalSeparator = parts.find((part) => part.type === "decimal")?.value ?? ".";
5
+ const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
6
+ const thousandsSeparator = parts.find((part) => part.type === "group")?.value ?? DEFAULT_THOUSANDS_SEPARATOR;
7
+ const decimalSeparator = parts.find((part) => part.type === "decimal")?.value ?? DEFAULT_DECIMAL_SEPARATOR;
6
8
  return { thousandsSeparator, decimalSeparator };
7
9
  };
8
10
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AASO,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAyC;AAE3E,EAAA,MAAM,QAAQ,IAAI,IAAA,CAAK,aAAa,MAAM,CAAA,CAAE,cAAc,OAAO,CAAA;AACjE,EAAA,MAAM,kBAAA,GAAqB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,OAAO,CAAA,EAAG,KAAA,IAAS,GAAA;AACjF,EAAA,MAAM,gBAAA,GAAmB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,SAAS,CAAA,EAAG,KAAA,IAAS,GAAA;AACjF,EAAA,OAAO,EAAE,oBAAoB,gBAAA,EAAiB;AAChD","file":"index.js","sourcesContent":["import type { UserLocale } from '@kyco-utils/enums'\nimport type { NumberSeparators } from '@kyco-utils/types'\n\n/**\n * Gets the thousands and decimal separators for a given locale\n *\n * @param locale - The locale to get separators for\n * @returns Object containing `thousandsSeparator` and `decimalSeparator`\n */\nexport const getNumberSeparators = (locale: UserLocale): NumberSeparators => {\n // @locale-updates\n const parts = new Intl.NumberFormat(locale).formatToParts(11111.1)\n const thousandsSeparator = parts.find((part) => part.type === 'group')?.value ?? ','\n const decimalSeparator = parts.find((part) => part.type === 'decimal')?.value ?? '.'\n return { thousandsSeparator, decimalSeparator }\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAGA,IAAM,2BAAA,GAA8B,GAAA;AACpC,IAAM,yBAAA,GAA4B,GAAA;AAS3B,IAAM,mBAAA,GAAsB,CAAC,MAAA,KAAyC;AAE3E,EAAA,MAAM,QAAQ,IAAI,IAAA,CAAK,aAAa,MAAM,CAAA,CAAE,cAAc,OAAO,CAAA;AACjE,EAAA,MAAM,kBAAA,GAAqB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,OAAO,CAAA,EAAG,KAAA,IAAS,2BAAA;AACjF,EAAA,MAAM,gBAAA,GAAmB,MAAM,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,IAAA,KAAS,SAAS,CAAA,EAAG,KAAA,IAAS,yBAAA;AAEjF,EAAA,OAAO,EAAE,oBAAoB,gBAAA,EAAiB;AAChD","file":"index.js","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyco-utils/number",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Locale-aware number utilities for kyco-utils.",
5
5
  "type": "module",
6
6
  "sideEffects": false,