yummies 5.10.0 → 5.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yummies",
3
- "version": "5.10.0",
3
+ "version": "5.11.0",
4
4
  "keywords": [
5
5
  "javascript",
6
6
  "typescript",
@@ -29,6 +29,7 @@
29
29
  "optional": true
30
30
  }
31
31
  },
32
+ "sideEffects": false,
32
33
  "dependencies": {
33
34
  "class-variance-authority": "^0.7.1",
34
35
  "clsx": "^2.1.1",
@@ -51,7 +52,7 @@
51
52
  "lefthook": "^1.11.16",
52
53
  "nodemon": "^3.1.9",
53
54
  "rimraf": "^6.0.1",
54
- "sborshik": "^1.0.22",
55
+ "sborshik": "^1.0.25",
55
56
  "tsx": "^4.20.5",
56
57
  "typescript": "^5.8.3",
57
58
  "vite": "^7.1.9",
@@ -61,6 +62,8 @@
61
62
  },
62
63
  "type": "module",
63
64
  "exports": {
65
+ "./LICENSE": "./LICENSE",
66
+ "./README": "./README.md",
64
67
  "./async": {
65
68
  "import": "./async.js",
66
69
  "default": "./async.js",
@@ -76,7 +79,7 @@
76
79
  "./complex": {
77
80
  "import": "./complex.js",
78
81
  "default": "./complex.js",
79
- "types": "./complex/index.d.ts",
82
+ "types": "./complex.d.ts",
80
83
  "require": "./complex.cjs"
81
84
  },
82
85
  "./cookie": {
@@ -130,7 +133,7 @@
130
133
  "./format": {
131
134
  "import": "./format.js",
132
135
  "default": "./format.js",
133
- "types": "./format/index.d.ts",
136
+ "types": "./format.d.ts",
134
137
  "require": "./format.cjs"
135
138
  },
136
139
  "./html": {
@@ -166,7 +169,7 @@
166
169
  "./mobx": {
167
170
  "import": "./mobx.js",
168
171
  "default": "./mobx.js",
169
- "types": "./mobx/index.d.ts",
172
+ "types": "./mobx.d.ts",
170
173
  "require": "./mobx.cjs"
171
174
  },
172
175
  "./ms": {
@@ -184,7 +187,7 @@
184
187
  "./parser": {
185
188
  "import": "./parser.js",
186
189
  "default": "./parser.js",
187
- "types": "./parser/index.d.ts",
190
+ "types": "./parser.d.ts",
188
191
  "require": "./parser.cjs"
189
192
  },
190
193
  "./price": {
@@ -202,7 +205,7 @@
202
205
  "./react": {
203
206
  "import": "./react.js",
204
207
  "default": "./react.js",
205
- "types": "./react/index.d.ts",
208
+ "types": "./react.d.ts",
206
209
  "require": "./react.cjs"
207
210
  },
208
211
  "./sound": {
@@ -220,7 +223,7 @@
220
223
  "./type-guard": {
221
224
  "import": "./type-guard.js",
222
225
  "default": "./type-guard.js",
223
- "types": "./type-guard/index.d.ts",
226
+ "types": "./type-guard.d.ts",
224
227
  "require": "./type-guard.cjs"
225
228
  },
226
229
  "./utility-types": {
@@ -0,0 +1,7 @@
1
+ const s = "–", N = "-", o = "∞";
2
+ export {
3
+ N as H,
4
+ o as I,
5
+ s as N
6
+ };
7
+ //# sourceMappingURL=~constants-CFexlSUS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"~constants-CFexlSUS.js","sources":["../src/format/constants.ts"],"sourcesContent":["export const NO_VALUE = '–'; // en-dash\n\nexport const HYPHEN = '-';\n\nexport const INFINITY = '∞';\n"],"names":["NO_VALUE","HYPHEN","INFINITY"],"mappings":"AAAO,MAAMA,IAAW,KAEXC,IAAS,KAETC,IAAW;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const N="–",I="-",s="∞";exports.HYPHEN=I;exports.INFINITY=s;exports.NO_VALUE=N;
2
+ //# sourceMappingURL=~constants-HmaulHpr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"~constants-HmaulHpr.js","sources":["../src/format/constants.ts"],"sourcesContent":["export const NO_VALUE = '–'; // en-dash\n\nexport const HYPHEN = '-';\n\nexport const INFINITY = '∞';\n"],"names":["NO_VALUE","HYPHEN","INFINITY"],"mappings":"aAAO,MAAMA,EAAW,IAEXC,EAAS,IAETC,EAAW"}
@@ -1,2 +0,0 @@
1
- "use strict";const I=require("yummies/parser"),u=require("yummies/type-guard"),f="–",$="-",x="∞",n=(o,m)=>{const t={...n.defaultSettings,...m},a=t.digits??0,g=t?.cutZeros??!1,c=t.delimiter??" ",p=t.postfix??"",N=t.emptyText??f,y=t.digitsOnlyForFloat??!0;let e;if(u.typeGuard.isString(o)?e=I.parser.number(e,{fallback:void 0}):e=o,u.typeGuard.isNumber(e)){let s=`${e}`;a!==!1&&(s=e.toFixed(a)),g&&(s=`${+s}`);const[F,i]=s.split(".",2);let r=F,l="";i&&(!y||!/^0+$/.test(i))&&(l=`.${i}`);const d=/(\d+)(\d{3})/;for(;d.test(r)&&c;)r=r.replace(d,`$1${c}$2`);return r+l+p}return N};n.defaultSettings={};exports.HYPHEN=$;exports.INFINITY=x;exports.NO_VALUE=f;exports.number=n;
2
- //# sourceMappingURL=~number-DX076ykA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"~number-DX076ykA.js","sources":["../src/format/constants.ts","../src/format/number.ts"],"sourcesContent":["export const NO_VALUE = '–'; // en-dash\n\nexport const HYPHEN = '-';\n\nexport const INFINITY = '∞';\n","import { parser } from 'yummies/parser';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/utils/types';\nimport { NO_VALUE } from './constants.js';\n\nexport interface NumberFormatSettings {\n delimiter?: string;\n /**\n * digitsOnlyForFloat - Show digits after decimal point only if they are not zeros after converting to number.\n * Example: \"0.00\" -> \"0\", \"0.10\" -> \"0.1\", but \"0.003\" -> \"0.003\"\n *\n * @default true\n */\n digitsOnlyForFloat?: boolean;\n /**\n * Text which will be returned if the value is undefined, null, NaN, Infinity or empty string.\n * Example: \"–\" will be returned if the value is undefined and emptyText is \"–\".\n */\n emptyText?: string;\n /**\n * Text to append to the end of the formatted number.\n * Example: if value is 1000 and postfix is \"₽\", result will be \"1 000₽\".\n */\n postfix?: string;\n /**\n * Fixed number of digits after the decimal point (number.toFixed() method)\n * If set to false, the truncation is ignored!\n */\n digits?: number | false;\n /**\n * Remove trailing zeros from the end of the number\n * Example: 0.010000000000000000000000000000000000000000000 -> 0.01\n */\n cutZeros?: boolean;\n}\n\nexport const number = (\n rawValue: Maybe<string | number>,\n userSettings?: Maybe<NumberFormatSettings>,\n): string => {\n const settings = {\n ...number.defaultSettings,\n ...userSettings,\n };\n\n const digits = settings.digits ?? 0;\n const cutZeros = settings?.cutZeros ?? false;\n const delimiter = settings.delimiter ?? ' ';\n const postfix = settings.postfix ?? '';\n const emptyText = settings.emptyText ?? NO_VALUE;\n const digitsOnlyForFloat = settings.digitsOnlyForFloat ?? true;\n\n let value: Maybe<number>;\n\n if (typeGuard.isString(rawValue)) {\n value = parser.number(value, { fallback: undefined });\n } else {\n value = rawValue;\n }\n\n if (typeGuard.isNumber(value)) {\n let raw: string = `${value}`;\n\n if (digits !== false) {\n raw = value.toFixed(digits);\n }\n if (cutZeros) {\n raw = `${+raw}`;\n }\n\n const [integerPart, decimalPart] = raw.split('.', 2);\n\n let formattedIntegerPart = integerPart;\n let formattedDecimalPart = '';\n\n if (decimalPart && (!digitsOnlyForFloat || !/^0+$/.test(decimalPart))) {\n formattedDecimalPart = `.${decimalPart}`;\n }\n\n const rgx = /(\\d+)(\\d{3})/;\n\n while (rgx.test(formattedIntegerPart) && delimiter) {\n formattedIntegerPart = formattedIntegerPart.replace(\n rgx,\n `$1${delimiter}$2`,\n );\n }\n\n return formattedIntegerPart + formattedDecimalPart + postfix;\n }\n\n return emptyText;\n};\n\nnumber.defaultSettings = {} as NumberFormatSettings;\n"],"names":["NO_VALUE","HYPHEN","INFINITY","number","rawValue","userSettings","settings","digits","cutZeros","delimiter","postfix","emptyText","digitsOnlyForFloat","value","typeGuard","parser","raw","integerPart","decimalPart","formattedIntegerPart","formattedDecimalPart","rgx"],"mappings":"+EAAaA,EAAW,IAEXC,EAAS,IAETC,EAAW,ICgCXC,EAAS,CACpBC,EACAC,IACW,CACX,MAAMC,EAAW,CACf,GAAGH,EAAO,gBACV,GAAGE,CAAA,EAGCE,EAASD,EAAS,QAAU,EAC5BE,EAAWF,GAAU,UAAY,GACjCG,EAAYH,EAAS,WAAa,IAClCI,EAAUJ,EAAS,SAAW,GAC9BK,EAAYL,EAAS,WAAaN,EAClCY,EAAqBN,EAAS,oBAAsB,GAE1D,IAAIO,EAQJ,GANIC,EAAAA,UAAU,SAASV,CAAQ,EAC7BS,EAAQE,EAAAA,OAAO,OAAOF,EAAO,CAAE,SAAU,OAAW,EAEpDA,EAAQT,EAGNU,EAAAA,UAAU,SAASD,CAAK,EAAG,CAC7B,IAAIG,EAAc,GAAGH,CAAK,GAEtBN,IAAW,KACbS,EAAMH,EAAM,QAAQN,CAAM,GAExBC,IACFQ,EAAM,GAAG,CAACA,CAAG,IAGf,KAAM,CAACC,EAAaC,CAAW,EAAIF,EAAI,MAAM,IAAK,CAAC,EAEnD,IAAIG,EAAuBF,EACvBG,EAAuB,GAEvBF,IAAgB,CAACN,GAAsB,CAAC,OAAO,KAAKM,CAAW,KACjEE,EAAuB,IAAIF,CAAW,IAGxC,MAAMG,EAAM,eAEZ,KAAOA,EAAI,KAAKF,CAAoB,GAAKV,GACvCU,EAAuBA,EAAqB,QAC1CE,EACA,KAAKZ,CAAS,IAAA,EAIlB,OAAOU,EAAuBC,EAAuBV,CACvD,CAEA,OAAOC,CACT,EAEAR,EAAO,gBAAkB,CAAA"}
@@ -1,32 +0,0 @@
1
- import { parser as F } from "yummies/parser";
2
- import { typeGuard as d } from "yummies/type-guard";
3
- const N = "–", P = "-", b = "∞", f = (o, m) => {
4
- const t = {
5
- ...f.defaultSettings,
6
- ...m
7
- }, n = t.digits ?? 0, g = t?.cutZeros ?? !1, a = t.delimiter ?? " ", p = t.postfix ?? "", u = t.emptyText ?? N, x = t.digitsOnlyForFloat ?? !0;
8
- let e;
9
- if (d.isString(o) ? e = F.number(e, { fallback: void 0 }) : e = o, d.isNumber(e)) {
10
- let s = `${e}`;
11
- n !== !1 && (s = e.toFixed(n)), g && (s = `${+s}`);
12
- const [$, r] = s.split(".", 2);
13
- let i = $, l = "";
14
- r && (!x || !/^0+$/.test(r)) && (l = `.${r}`);
15
- const c = /(\d+)(\d{3})/;
16
- for (; c.test(i) && a; )
17
- i = i.replace(
18
- c,
19
- `$1${a}$2`
20
- );
21
- return i + l + p;
22
- }
23
- return u;
24
- };
25
- f.defaultSettings = {};
26
- export {
27
- P as H,
28
- b as I,
29
- N,
30
- f as n
31
- };
32
- //# sourceMappingURL=~number-baxVnzrJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"~number-baxVnzrJ.js","sources":["../src/format/constants.ts","../src/format/number.ts"],"sourcesContent":["export const NO_VALUE = '–'; // en-dash\n\nexport const HYPHEN = '-';\n\nexport const INFINITY = '∞';\n","import { parser } from 'yummies/parser';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/utils/types';\nimport { NO_VALUE } from './constants.js';\n\nexport interface NumberFormatSettings {\n delimiter?: string;\n /**\n * digitsOnlyForFloat - Show digits after decimal point only if they are not zeros after converting to number.\n * Example: \"0.00\" -> \"0\", \"0.10\" -> \"0.1\", but \"0.003\" -> \"0.003\"\n *\n * @default true\n */\n digitsOnlyForFloat?: boolean;\n /**\n * Text which will be returned if the value is undefined, null, NaN, Infinity or empty string.\n * Example: \"–\" will be returned if the value is undefined and emptyText is \"–\".\n */\n emptyText?: string;\n /**\n * Text to append to the end of the formatted number.\n * Example: if value is 1000 and postfix is \"₽\", result will be \"1 000₽\".\n */\n postfix?: string;\n /**\n * Fixed number of digits after the decimal point (number.toFixed() method)\n * If set to false, the truncation is ignored!\n */\n digits?: number | false;\n /**\n * Remove trailing zeros from the end of the number\n * Example: 0.010000000000000000000000000000000000000000000 -> 0.01\n */\n cutZeros?: boolean;\n}\n\nexport const number = (\n rawValue: Maybe<string | number>,\n userSettings?: Maybe<NumberFormatSettings>,\n): string => {\n const settings = {\n ...number.defaultSettings,\n ...userSettings,\n };\n\n const digits = settings.digits ?? 0;\n const cutZeros = settings?.cutZeros ?? false;\n const delimiter = settings.delimiter ?? ' ';\n const postfix = settings.postfix ?? '';\n const emptyText = settings.emptyText ?? NO_VALUE;\n const digitsOnlyForFloat = settings.digitsOnlyForFloat ?? true;\n\n let value: Maybe<number>;\n\n if (typeGuard.isString(rawValue)) {\n value = parser.number(value, { fallback: undefined });\n } else {\n value = rawValue;\n }\n\n if (typeGuard.isNumber(value)) {\n let raw: string = `${value}`;\n\n if (digits !== false) {\n raw = value.toFixed(digits);\n }\n if (cutZeros) {\n raw = `${+raw}`;\n }\n\n const [integerPart, decimalPart] = raw.split('.', 2);\n\n let formattedIntegerPart = integerPart;\n let formattedDecimalPart = '';\n\n if (decimalPart && (!digitsOnlyForFloat || !/^0+$/.test(decimalPart))) {\n formattedDecimalPart = `.${decimalPart}`;\n }\n\n const rgx = /(\\d+)(\\d{3})/;\n\n while (rgx.test(formattedIntegerPart) && delimiter) {\n formattedIntegerPart = formattedIntegerPart.replace(\n rgx,\n `$1${delimiter}$2`,\n );\n }\n\n return formattedIntegerPart + formattedDecimalPart + postfix;\n }\n\n return emptyText;\n};\n\nnumber.defaultSettings = {} as NumberFormatSettings;\n"],"names":["NO_VALUE","HYPHEN","INFINITY","number","rawValue","userSettings","settings","digits","cutZeros","delimiter","postfix","emptyText","digitsOnlyForFloat","value","typeGuard","parser","raw","integerPart","decimalPart","formattedIntegerPart","formattedDecimalPart","rgx"],"mappings":";;AAAO,MAAMA,IAAW,KAEXC,IAAS,KAETC,IAAW,KCgCXC,IAAS,CACpBC,GACAC,MACW;AACX,QAAMC,IAAW;AAAA,IACf,GAAGH,EAAO;AAAA,IACV,GAAGE;AAAA,EAAA,GAGCE,IAASD,EAAS,UAAU,GAC5BE,IAAWF,GAAU,YAAY,IACjCG,IAAYH,EAAS,aAAa,KAClCI,IAAUJ,EAAS,WAAW,IAC9BK,IAAYL,EAAS,aAAaN,GAClCY,IAAqBN,EAAS,sBAAsB;AAE1D,MAAIO;AAQJ,MANIC,EAAU,SAASV,CAAQ,IAC7BS,IAAQE,EAAO,OAAOF,GAAO,EAAE,UAAU,QAAW,IAEpDA,IAAQT,GAGNU,EAAU,SAASD,CAAK,GAAG;AAC7B,QAAIG,IAAc,GAAGH,CAAK;AAE1B,IAAIN,MAAW,OACbS,IAAMH,EAAM,QAAQN,CAAM,IAExBC,MACFQ,IAAM,GAAG,CAACA,CAAG;AAGf,UAAM,CAACC,GAAaC,CAAW,IAAIF,EAAI,MAAM,KAAK,CAAC;AAEnD,QAAIG,IAAuBF,GACvBG,IAAuB;AAE3B,IAAIF,MAAgB,CAACN,KAAsB,CAAC,OAAO,KAAKM,CAAW,OACjEE,IAAuB,IAAIF,CAAW;AAGxC,UAAMG,IAAM;AAEZ,WAAOA,EAAI,KAAKF,CAAoB,KAAKV;AACvC,MAAAU,IAAuBA,EAAqB;AAAA,QAC1CE;AAAA,QACA,KAAKZ,CAAS;AAAA,MAAA;AAIlB,WAAOU,IAAuBC,IAAuBV;AAAA,EACvD;AAEA,SAAOC;AACT;AAEAR,EAAO,kBAAkB,CAAA;"}