@kyco-utils/number 0.1.1 → 0.1.3

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,13 +1,21 @@
1
- 'use strict';
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
2
  // src/index.ts
4
- 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 ?? ".";
8
- return { thousandsSeparator, decimalSeparator };
3
+ const DEFAULT_THOUSANDS_SEPARATOR = ",";
4
+ const DEFAULT_DECIMAL_SEPARATOR = ".";
5
+ /**
6
+ * Gets the thousands and decimal separators for a given locale
7
+ *
8
+ * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
9
+ * @returns The {@link NumberSeparators} for the locale.
10
+ * @see {@link UserLocale} for the list of supported locales.
11
+ */
12
+ const getNumberSeparators = (locale) => {
13
+ const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
14
+ return {
15
+ thousandsSeparator: parts.find((part) => part.type === "group")?.value ?? DEFAULT_THOUSANDS_SEPARATOR,
16
+ decimalSeparator: parts.find((part) => part.type === "decimal")?.value ?? DEFAULT_DECIMAL_SEPARATOR
17
+ };
9
18
  };
10
-
11
19
  exports.getNumberSeparators = getNumberSeparators;
12
- //# sourceMappingURL=index.cjs.map
20
+
13
21
  //# sourceMappingURL=index.cjs.map
@@ -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,"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"}
package/dist/index.d.cts CHANGED
@@ -1,12 +1,11 @@
1
- import { UserLocale } from '@kyco-utils/enums';
2
- import { NumberSeparators } from '@kyco-utils/types';
3
-
1
+ import { UserLocale } from "@kyco-utils/enums";
2
+ import { NumberSeparators } from "@kyco-utils/types";
4
3
  /**
5
4
  * Gets the thousands and decimal separators for a given locale
6
5
  *
7
- * @param locale - The locale to get separators for
8
- * @returns Object containing `thousandsSeparator` and `decimalSeparator`
6
+ * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
7
+ * @returns The {@link NumberSeparators} for the locale.
8
+ * @see {@link UserLocale} for the list of supported locales.
9
9
  */
10
- declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
-
12
- export { getNumberSeparators };
10
+ export declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;qBAaa,sBAAmB,QAAY,eAAa"}
@@ -0,0 +1,11 @@
1
+ import { UserLocale } from "@kyco-utils/enums";
2
+ import { NumberSeparators } from "@kyco-utils/types";
3
+ /**
4
+ * Gets the thousands and decimal separators for a given locale
5
+ *
6
+ * @param locale - A supported {@link UserLocale} (BCP 47 language tag).
7
+ * @returns The {@link NumberSeparators} for the locale.
8
+ * @see {@link UserLocale} for the list of supported locales.
9
+ */
10
+ export declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;qBAaa,sBAAmB,QAAY,eAAa"}
package/dist/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ // src/index.ts
2
+ const DEFAULT_THOUSANDS_SEPARATOR = ",";
3
+ const DEFAULT_DECIMAL_SEPARATOR = ".";
4
+ /**
5
+ * Gets the thousands and decimal separators for a given locale
6
+ *
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.
10
+ */
11
+ const getNumberSeparators = (locale) => {
12
+ const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
13
+ return {
14
+ thousandsSeparator: parts.find((part) => part.type === "group")?.value ?? DEFAULT_THOUSANDS_SEPARATOR,
15
+ decimalSeparator: parts.find((part) => part.type === "decimal")?.value ?? DEFAULT_DECIMAL_SEPARATOR
16
+ };
17
+ };
18
+ export { getNumberSeparators };
19
+
20
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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"}
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.3",
4
4
  "description": "Locale-aware number utilities for kyco-utils.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -16,27 +16,32 @@
16
16
  ],
17
17
  "exports": {
18
18
  ".": {
19
- "types": "./dist/index.d.ts",
20
- "import": "./dist/index.js",
21
- "require": "./dist/index.cjs"
19
+ "@kyco-utils/source": "./src/index.ts",
20
+ "import": {
21
+ "types": "./dist/index.d.mts",
22
+ "default": "./dist/index.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/index.d.cts",
26
+ "default": "./dist/index.cjs"
27
+ }
22
28
  }
23
29
  },
24
30
  "main": "./dist/index.cjs",
25
- "module": "./dist/index.js",
26
- "types": "./dist/index.d.ts",
31
+ "module": "./dist/index.mjs",
32
+ "types": "./dist/index.d.cts",
27
33
  "dependencies": {
28
- "@kyco-utils/enums": "^0.1.1",
29
- "@kyco-utils/types": "^0.1.1"
34
+ "@kyco-utils/enums": "^0.1.2",
35
+ "@kyco-utils/types": "^0.1.2"
30
36
  },
31
37
  "publishConfig": {
32
38
  "access": "public",
33
39
  "provenance": true
34
40
  },
35
41
  "scripts": {
36
- "build": "tsup",
37
- "dev": "tsup --watch",
42
+ "build": "vp pack",
43
+ "dev": "vp pack --watch",
38
44
  "typecheck": "tsc --noEmit",
39
- "test": "vitest run",
40
45
  "lint": "biome check ."
41
46
  }
42
47
  }
package/dist/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { UserLocale } from '@kyco-utils/enums';
2
- import { NumberSeparators } from '@kyco-utils/types';
3
-
4
- /**
5
- * Gets the thousands and decimal separators for a given locale
6
- *
7
- * @param locale - The locale to get separators for
8
- * @returns Object containing `thousandsSeparator` and `decimalSeparator`
9
- */
10
- declare const getNumberSeparators: (locale: UserLocale) => NumberSeparators;
11
-
12
- export { getNumberSeparators };
package/dist/index.js DELETED
@@ -1,11 +0,0 @@
1
- // src/index.ts
2
- 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 ?? ".";
6
- return { thousandsSeparator, decimalSeparator };
7
- };
8
-
9
- export { getNumberSeparators };
10
- //# sourceMappingURL=index.js.map
11
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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"]}