@rzl-zone/utils-js 3.3.1 → 3.5.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.
Files changed (132) hide show
  1. package/README.md +94 -45
  2. package/dist/assertions/index.cjs +34 -1
  3. package/dist/assertions/index.d.ts +2 -2
  4. package/dist/assertions/index.js +5 -1
  5. package/dist/chunk-2CQX5CBG.js +247 -1
  6. package/dist/chunk-2IOOEY45.cjs +20 -1
  7. package/dist/chunk-2WA36TC5.cjs +176 -0
  8. package/dist/chunk-3IBQ5MOM.js +6 -1
  9. package/dist/chunk-3VA554KW.js +23 -1
  10. package/dist/chunk-5757UBXJ.cjs +144 -1
  11. package/dist/chunk-5IGC6PBH.js +22 -1
  12. package/dist/chunk-5KJFVIQT.cjs +55 -1
  13. package/dist/chunk-6JFCSH7J.js +24 -1
  14. package/dist/chunk-6JFZL7YE.cjs +14 -1
  15. package/dist/chunk-7ODAAXX5.cjs +361 -1
  16. package/dist/chunk-BAV5T2E3.cjs +5 -1
  17. package/dist/chunk-CAH33WOQ.cjs +25 -1
  18. package/dist/chunk-CDCERIZ2.js +164 -0
  19. package/dist/chunk-CKTLUNWX.js +12 -1
  20. package/dist/chunk-CMW2TBOQ.js +522 -1
  21. package/dist/chunk-D3ENH7H6.cjs +87 -1
  22. package/dist/chunk-DEZZUYE2.js +139 -1
  23. package/dist/chunk-DVMHRLKP.cjs +6 -1
  24. package/dist/chunk-DWF2R5GD.cjs +212 -1
  25. package/dist/chunk-E55EQK2U.cjs +8 -1
  26. package/dist/chunk-E74U6CYP.cjs +8 -1
  27. package/dist/chunk-EL6A35UR.cjs +51 -1
  28. package/dist/chunk-F6IPNNSJ.cjs +531 -1
  29. package/dist/chunk-FJZGG54N.cjs +252 -1
  30. package/dist/chunk-FWCKOJZM.js +519 -1
  31. package/dist/chunk-FWHNWL2P.cjs +409 -1
  32. package/dist/chunk-GGEADHZO.js +78 -1
  33. package/dist/chunk-GQR4R5WY.js +21 -1
  34. package/dist/chunk-H66AC7GK.cjs +81 -1
  35. package/dist/chunk-HQWOFR56.cjs +23 -1
  36. package/dist/chunk-HYRQMTRH.cjs +14 -1
  37. package/dist/chunk-IRFL4MAX.js +53 -1
  38. package/dist/chunk-IVL7CKVH.cjs +26 -1
  39. package/dist/chunk-IZPBKKPO.js +6 -1
  40. package/dist/chunk-JBQMXC5I.cjs +93 -1
  41. package/dist/chunk-JEQEF5WD.js +81 -1
  42. package/dist/chunk-JMJQCN74.js +334 -1
  43. package/dist/chunk-KHO2SBNA.cjs +6 -1
  44. package/dist/chunk-KVAL5PAG.cjs +16 -1
  45. package/dist/chunk-L5RDAVVH.js +5 -1
  46. package/dist/chunk-LS6U7FAY.cjs +98 -1
  47. package/dist/chunk-NBZWMBO6.js +88 -1
  48. package/dist/chunk-NRF6LWBC.cjs +45 -1
  49. package/dist/chunk-OI5XKNZO.js +42 -1
  50. package/dist/chunk-ONZFBJVW.js +5 -1
  51. package/dist/chunk-OYTYSY7G.js +94 -1
  52. package/dist/chunk-PET42Z7W.js +107 -1
  53. package/dist/chunk-PZQ6I4JJ.cjs +559 -1
  54. package/dist/chunk-QBKAEVYG.js +102 -1
  55. package/dist/chunk-QNKGP5DY.js +5 -1
  56. package/dist/chunk-RIPKY4RU.js +407 -1
  57. package/dist/chunk-RZW35UN5.cjs +105 -1
  58. package/dist/chunk-SBFNXGTJ.js +207 -1
  59. package/dist/chunk-SBKGWRS5.js +12 -1
  60. package/dist/chunk-SIM77PU4.js +46 -1
  61. package/dist/chunk-T2T7K3KR.js +18 -1
  62. package/dist/chunk-T7PU2V7X.cjs +111 -1
  63. package/dist/chunk-UDA26MCU.cjs +6 -1
  64. package/dist/chunk-V45XJKHW.cjs +8 -1
  65. package/dist/chunk-VJDDGRIK.cjs +6 -1
  66. package/dist/chunk-W2WNBUDE.js +6 -1
  67. package/dist/chunk-WVSPXFTY.js +5 -1
  68. package/dist/chunk-XABCB3Y7.cjs +563 -1
  69. package/dist/chunk-XEDXFSGI.js +14 -1
  70. package/dist/chunk-YKPSRP5G.js +552 -1
  71. package/dist/chunk-YWHHVDT4.js +4 -1
  72. package/dist/chunk-ZETAZZLD.cjs +27 -1
  73. package/dist/conversions/index.cjs +97 -1
  74. package/dist/conversions/index.d.ts +2 -2
  75. package/dist/conversions/index.js +16 -1
  76. package/dist/events/index.cjs +25 -1
  77. package/dist/events/index.d.ts +1 -1
  78. package/dist/events/index.js +4 -1
  79. package/dist/formatters/index.cjs +55 -1
  80. package/dist/formatters/index.d.ts +2 -2
  81. package/dist/formatters/index.js +10 -1
  82. package/dist/generators/index.cjs +31 -1
  83. package/dist/generators/index.d.ts +2 -2
  84. package/dist/generators/index.js +6 -1
  85. package/dist/index.d.ts +1 -1
  86. package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-FWmcJF6k.d.ts} +5 -5
  87. package/dist/next/index.cjs +205 -1
  88. package/dist/next/index.d.ts +2 -2
  89. package/dist/next/index.js +200 -1
  90. package/dist/next/server/index.cjs +34 -1
  91. package/dist/next/server/index.d.ts +1 -1
  92. package/dist/next/server/index.js +32 -1
  93. package/dist/operations/index.cjs +26 -1
  94. package/dist/operations/index.d.ts +2 -2
  95. package/dist/operations/index.js +9 -1
  96. package/dist/parsers/index.cjs +11 -1
  97. package/dist/parsers/index.d.ts +1 -1
  98. package/dist/parsers/index.js +2 -1
  99. package/dist/predicates/index.cjs +292 -1
  100. package/dist/predicates/index.d.ts +4 -4
  101. package/dist/predicates/index.js +15 -1
  102. package/dist/promises/index.cjs +18 -1
  103. package/dist/promises/index.d.ts +2 -2
  104. package/dist/promises/index.js +5 -1
  105. package/dist/rzl-utils.global.js +16 -1
  106. package/dist/strings/index.cjs +75 -1
  107. package/dist/strings/index.d.ts +2 -2
  108. package/dist/strings/index.js +6 -1
  109. package/dist/tailwind/index.cjs +36 -1
  110. package/dist/tailwind/index.d.ts +1 -1
  111. package/dist/tailwind/index.js +3 -1
  112. package/dist/urls/index.cjs +44 -1
  113. package/dist/urls/index.d.ts +1 -1
  114. package/dist/urls/index.js +15 -1
  115. package/package.json +16 -24
  116. package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
  117. package/dist/any-v4TsK9ES.d.ts +0 -66
  118. package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
  119. package/dist/chunk-JYQTCICM.js +0 -1
  120. package/dist/chunk-YLA3DURS.cjs +0 -1
  121. package/dist/extends-DtdRjDyU.d.ts +0 -343
  122. package/dist/if-ChM35c_q.d.ts +0 -19
  123. package/dist/is-array-BJeHxPM3.d.ts +0 -952
  124. package/dist/never-D89PbPh5.d.ts +0 -66
  125. package/dist/nils-CO8zLHSB.d.ts +0 -151
  126. package/dist/or-C6qzKt2I.d.ts +0 -82
  127. package/dist/override-CL2olHE5.d.ts +0 -59
  128. package/dist/pick-BSMX6Xe2.d.ts +0 -15
  129. package/dist/prettify-3o8_Kw6b.d.ts +0 -564
  130. package/dist/promises-LU7K00H0.d.ts +0 -72
  131. package/dist/string-B1jlOnws.d.ts +0 -312
  132. package/dist/types/index.d.ts +0 -3345
@@ -1 +1,5 @@
1
- var t=t=>"bigint"==typeof t;export{t as isBigInt};
1
+ var isBigInt = (value) => {
2
+ return typeof value === "bigint";
3
+ };
4
+
5
+ export { isBigInt };
@@ -1 +1,407 @@
1
- import{isNonEmptyString as s}from"./chunk-CMW2TBOQ.js";var a=new Set(["txt","md","rtf","tex","doc","docx","odt","ott","pdf","djvu","epub","mobi","azw","azw3","xls","xlsx","ods","csv","tsv","ppt","pptx","odp","pps","md","bib","tex","log","jpg","jpeg","png","gif","bmp","tif","tiff","webp","svg","ico","heif","heic","raw","cr2","nef","orf","sr2","dng","dds","psd","exr","xcf","ai","eps","cdr","psd","indd","mp3","wav","ogg","flac","aac","m4a","wma","alac","aiff","amr","mid","midi","opus","au","caf","ape","opus","mp4","mkv","avi","mov","flv","wmv","webm","mpeg","mpg","3gp","3g2","m4v","ts","mts","asf","rm","rmvb","vob","f4v","ogv","m2ts","mod","dav","zip","rar","7z","tar","gz","bz2","xz","tgz","tbz2","txz","lz","lzma","z","cab","arj","ace","iso","dmg","rpm","deb","pkg","apk","jar","iso","img","vhd","vmdk","qcow2","dmg","sql","db","dbf","mdb","accdb","json","xml","yaml","yml","toml","ini","plist","yaml","pkl","msgpack","h5","hdf5","parquet","avro","orc","ndjson","db","pdb","sqlite","sqlite3","dbx","sdf","js","jsx","ts","tsx","c","cpp","h","hpp","java","py","rb","go","rs","php","pl","sh","bat","cmd","ps1","lua","swift","kt","scala","cs","vb","dart","m","r","jl","fs","vbproj","sln","pri","Makefile","html","htm","xhtml","css","scss","sass","less","xml","json","yaml","yml","xlf","xlf","po","pot","jsp","asp","aspx","php","jspf","cgi","cfm","pl","env","conf","config","xml","ini","cfg","toml","yaml","dockerfile","gitignore","gitconfig","gitattributes","npmignore","lock","gradle","pom","yaml","prettierrc","eslintrc","babelrc","editorconfig","ttf","otf","woff","woff2","eot","dwg","dxf","shp","kml","kmz","gpx","stl","step","iges","3ds","3dm","fbx","obj","exe","msi","bin","run","com","cmd","apk","app","deb","rpm","elf","dll","so","dylib","sys","pem","crt","cer","key","der","csr","p12","pfx","jks","iso","cue","bin","nes","sfc","gba","nds","nes","sav","rom","pak","vpk","bik","epub","mobi","azw","azw3","fb2","lit","lrf","cbr","cbz","cbt","cba","opds","fasta","fa","fas","ffn","faa","fna","frn","fastq","fq","gb","gbk","sam","bam","vcf","gff","bed","log","bak","tmp","old","backup","swp","part","crdownload","torrent","ics","vcf","ics","ical","ics","ical","calendar","srt","sub","idx","cue","cdf","hdf","h5","nc","grib","fits","netcdf","sdf","vtk","xmind","drawio","jar","war","ear","crx","xpi","plugin","vsix","safariextz"]),t=new Set(["tar.gz","tar.bz2","tar.xz","tar.lz","tar.lzma","tar.Z","tar.zst","tar.xz"]),r=r=>{if(!s(r))return;let p=r.split("/").pop();if(""===p)return"";if(p){for(const s of t){const a=`.${s}`;if(p.toLowerCase().endsWith(a))return p.slice(0,-a.length)}for(;;){const s=p.lastIndexOf(".");if(-1===s)break;const t=p.slice(s+1).toLowerCase();if(!a.has(t))break;p=p.slice(0,s)}return p}};export{r as extractFileName};
1
+ import { isNonEmptyString } from './chunk-CMW2TBOQ.js';
2
+ var KNOWN_EXTENSIONS = /* @__PURE__ */ new Set([
3
+ // 📄 Text & Document
4
+ "txt",
5
+ "md",
6
+ "rtf",
7
+ "tex",
8
+ "doc",
9
+ "docx",
10
+ "odt",
11
+ "ott",
12
+ "pdf",
13
+ "djvu",
14
+ "epub",
15
+ "mobi",
16
+ "azw",
17
+ "azw3",
18
+ "xls",
19
+ "xlsx",
20
+ "ods",
21
+ "csv",
22
+ "tsv",
23
+ "ppt",
24
+ "pptx",
25
+ "odp",
26
+ "pps",
27
+ "md",
28
+ "bib",
29
+ "tex",
30
+ "log",
31
+ // 🖼️ Image
32
+ "jpg",
33
+ "jpeg",
34
+ "png",
35
+ "gif",
36
+ "bmp",
37
+ "tif",
38
+ "tiff",
39
+ "webp",
40
+ "svg",
41
+ "ico",
42
+ "heif",
43
+ "heic",
44
+ "raw",
45
+ "cr2",
46
+ "nef",
47
+ "orf",
48
+ "sr2",
49
+ "dng",
50
+ "dds",
51
+ "psd",
52
+ "exr",
53
+ "xcf",
54
+ "ai",
55
+ "eps",
56
+ "cdr",
57
+ "psd",
58
+ "indd",
59
+ // 🎵 Audio
60
+ "mp3",
61
+ "wav",
62
+ "ogg",
63
+ "flac",
64
+ "aac",
65
+ "m4a",
66
+ "wma",
67
+ "alac",
68
+ "aiff",
69
+ "amr",
70
+ "mid",
71
+ "midi",
72
+ "opus",
73
+ "au",
74
+ "caf",
75
+ "ape",
76
+ "opus",
77
+ // 🎥 Video
78
+ "mp4",
79
+ "mkv",
80
+ "avi",
81
+ "mov",
82
+ "flv",
83
+ "wmv",
84
+ "webm",
85
+ "mpeg",
86
+ "mpg",
87
+ "3gp",
88
+ "3g2",
89
+ "m4v",
90
+ "ts",
91
+ "mts",
92
+ "asf",
93
+ "rm",
94
+ "rmvb",
95
+ "vob",
96
+ "f4v",
97
+ "ogv",
98
+ "m2ts",
99
+ "mod",
100
+ "dav",
101
+ // 🗃️ Archive & Compression
102
+ "zip",
103
+ "rar",
104
+ "7z",
105
+ "tar",
106
+ "gz",
107
+ "bz2",
108
+ "xz",
109
+ "tgz",
110
+ "tbz2",
111
+ "txz",
112
+ "lz",
113
+ "lzma",
114
+ "z",
115
+ "cab",
116
+ "arj",
117
+ "ace",
118
+ "iso",
119
+ "dmg",
120
+ "rpm",
121
+ "deb",
122
+ "pkg",
123
+ "apk",
124
+ "jar",
125
+ // 💾 Disk Image
126
+ "iso",
127
+ "img",
128
+ "vhd",
129
+ "vmdk",
130
+ "qcow2",
131
+ "dmg",
132
+ // 🗃️ Database & Data
133
+ "sql",
134
+ "db",
135
+ "dbf",
136
+ "mdb",
137
+ "accdb",
138
+ "json",
139
+ "xml",
140
+ "yaml",
141
+ "yml",
142
+ "toml",
143
+ "ini",
144
+ "plist",
145
+ "yaml",
146
+ "pkl",
147
+ "msgpack",
148
+ "h5",
149
+ "hdf5",
150
+ "parquet",
151
+ "avro",
152
+ "orc",
153
+ "ndjson",
154
+ "db",
155
+ "pdb",
156
+ "sqlite",
157
+ "sqlite3",
158
+ "dbx",
159
+ "sdf",
160
+ // 💻 Code & Script
161
+ "js",
162
+ "jsx",
163
+ "ts",
164
+ "tsx",
165
+ "c",
166
+ "cpp",
167
+ "h",
168
+ "hpp",
169
+ "java",
170
+ "py",
171
+ "rb",
172
+ "go",
173
+ "rs",
174
+ "php",
175
+ "pl",
176
+ "sh",
177
+ "bat",
178
+ "cmd",
179
+ "ps1",
180
+ "lua",
181
+ "swift",
182
+ "kt",
183
+ "scala",
184
+ "cs",
185
+ "vb",
186
+ "dart",
187
+ "m",
188
+ "r",
189
+ "jl",
190
+ "fs",
191
+ "vbproj",
192
+ "sln",
193
+ "pri",
194
+ "Makefile",
195
+ // 🌐 Web & Config
196
+ "html",
197
+ "htm",
198
+ "xhtml",
199
+ "css",
200
+ "scss",
201
+ "sass",
202
+ "less",
203
+ "xml",
204
+ "json",
205
+ "yaml",
206
+ "yml",
207
+ "xlf",
208
+ "xlf",
209
+ "po",
210
+ "pot",
211
+ "jsp",
212
+ "asp",
213
+ "aspx",
214
+ "php",
215
+ "jspf",
216
+ "cgi",
217
+ "cfm",
218
+ "pl",
219
+ "env",
220
+ "conf",
221
+ "config",
222
+ "xml",
223
+ "ini",
224
+ "cfg",
225
+ "toml",
226
+ "yaml",
227
+ "dockerfile",
228
+ "gitignore",
229
+ "gitconfig",
230
+ "gitattributes",
231
+ "npmignore",
232
+ "lock",
233
+ "gradle",
234
+ "pom",
235
+ "yaml",
236
+ "prettierrc",
237
+ "eslintrc",
238
+ "babelrc",
239
+ "editorconfig",
240
+ // 🔠 Font
241
+ "ttf",
242
+ "otf",
243
+ "woff",
244
+ "woff2",
245
+ "eot",
246
+ // 🗺️ CAD & GIS
247
+ "dwg",
248
+ "dxf",
249
+ "shp",
250
+ "kml",
251
+ "kmz",
252
+ "gpx",
253
+ "stl",
254
+ "step",
255
+ "iges",
256
+ "3ds",
257
+ "3dm",
258
+ "fbx",
259
+ "obj",
260
+ // 🔧 System / Binary / Execution
261
+ "exe",
262
+ "msi",
263
+ "bin",
264
+ "run",
265
+ "com",
266
+ "cmd",
267
+ "apk",
268
+ "app",
269
+ "deb",
270
+ "rpm",
271
+ "elf",
272
+ "dll",
273
+ "so",
274
+ "dylib",
275
+ "sys",
276
+ // 🔐 Certificates / Crypto
277
+ "pem",
278
+ "crt",
279
+ "cer",
280
+ "key",
281
+ "der",
282
+ "csr",
283
+ "p12",
284
+ "pfx",
285
+ "jks",
286
+ // 🎮 Games & Projects
287
+ "iso",
288
+ "cue",
289
+ "bin",
290
+ "nes",
291
+ "sfc",
292
+ "gba",
293
+ "nds",
294
+ "nes",
295
+ "sav",
296
+ "rom",
297
+ "pak",
298
+ "vpk",
299
+ "bik",
300
+ // 📚 E-books and Comics
301
+ "epub",
302
+ "mobi",
303
+ "azw",
304
+ "azw3",
305
+ "fb2",
306
+ "lit",
307
+ "lrf",
308
+ "cbr",
309
+ "cbz",
310
+ "cbt",
311
+ "cba",
312
+ "opds",
313
+ // 🔬 Bioinformatics
314
+ "fasta",
315
+ "fa",
316
+ "fas",
317
+ "ffn",
318
+ "faa",
319
+ "fna",
320
+ "frn",
321
+ "fastq",
322
+ "fq",
323
+ "gb",
324
+ "gbk",
325
+ "sam",
326
+ "bam",
327
+ "vcf",
328
+ "gff",
329
+ "bed",
330
+ // 📝 Etc
331
+ "log",
332
+ "bak",
333
+ "tmp",
334
+ "old",
335
+ "backup",
336
+ "swp",
337
+ "part",
338
+ "crdownload",
339
+ "torrent",
340
+ "ics",
341
+ "vcf",
342
+ "ics",
343
+ "ical",
344
+ "ics",
345
+ "ical",
346
+ "calendar",
347
+ "srt",
348
+ "sub",
349
+ "idx",
350
+ "cue",
351
+ // 🧠 Other broad (technical & scientific extensions)
352
+ "cdf",
353
+ "hdf",
354
+ "h5",
355
+ "nc",
356
+ "grib",
357
+ "fits",
358
+ "netcdf",
359
+ "sdf",
360
+ "vtk",
361
+ "xmind",
362
+ "drawio",
363
+ // ⚙️ Packages & Plugins
364
+ "jar",
365
+ "war",
366
+ "ear",
367
+ "crx",
368
+ "xpi",
369
+ "plugin",
370
+ "vsix",
371
+ "safariextz"
372
+ ]);
373
+ var DOUBLE_EXTENSIONS = /* @__PURE__ */ new Set([
374
+ "tar.gz",
375
+ "tar.bz2",
376
+ "tar.xz",
377
+ "tar.lz",
378
+ "tar.lzma",
379
+ "tar.Z",
380
+ "tar.zst",
381
+ "tar.xz"
382
+ ]);
383
+ var extractFileName = (url) => {
384
+ if (!isNonEmptyString(url)) return void 0;
385
+ let fileName = url.split("/").pop();
386
+ if (fileName === "") return "";
387
+ if (!fileName) return void 0;
388
+ for (const ext of DOUBLE_EXTENSIONS) {
389
+ const fullExt = `.${ext}`;
390
+ if (fileName.toLowerCase().endsWith(fullExt)) {
391
+ return fileName.slice(0, -fullExt.length);
392
+ }
393
+ }
394
+ while (true) {
395
+ const lastDot = fileName.lastIndexOf(".");
396
+ if (lastDot === -1) break;
397
+ const ext = fileName.slice(lastDot + 1).toLowerCase();
398
+ if (KNOWN_EXTENSIONS.has(ext)) {
399
+ fileName = fileName.slice(0, lastDot);
400
+ } else {
401
+ break;
402
+ }
403
+ }
404
+ return fileName;
405
+ };
406
+
407
+ export { extractFileName };
@@ -1 +1,105 @@
1
- "use strict";var e=require("./chunk-DVMHRLKP.cjs"),r=require("./chunk-T7PU2V7X.cjs"),t=require("./chunk-PZQ6I4JJ.cjs"),s=class extends Error{constructor(e="The operation was aborted",r="AbortError"){super(e),this.name=r}};exports.CustomPromise=class extends Promise{_value;_error;_finish=[];constructor(e){let r,t;super((e,s)=>{r=e,t=s}),e(e=>{this._value=e,r(e),this._finish.forEach(r=>r(e,void 0))},e=>{this._error=e,t(e),this._finish.forEach(r=>r(void 0,e))}),Object.setPrototypeOf(this,new.target.prototype)}then(e,r){return super.then(e,r)}catch(e){return super.catch(e)}finish(e){return void 0!==this._value||void 0!==this._error?e(this._value,this._error):this._finish.push(e),this}},exports.delay=(i=1e3,o)=>{if(!e.isInteger(i)||i<=0)throw new TypeError(`First parameter (\`milliSeconds\`) must be of type \`number\` and value must be a \`non-zero\`, \`non-NaN\`, \`non-negative\`, and \`integer-number\`, but received: \`${t.getPreciseType(i)}\`, with value: \`${r.safeStableStringify(i)}\`.`);if(t.isNull(o)||o&&!(o instanceof AbortSignal))throw new TypeError("Second parameter (`signal`) must be an `instance of AbortSignal` if provided.");return new Promise((e,r)=>{const t=setTimeout(()=>{n(),e()},i),n=()=>{clearTimeout(t),o&&o.removeEventListener("abort",a)},a=()=>{n(),r(new s("Function `delay` from `@rzl-zone/utils-js` was aborted.","AbortError"))};o&&(o.aborted?a():o.addEventListener("abort",a,{once:!0}))})};
1
+ 'use strict';
2
+
3
+ var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
4
+ var chunkT7PU2V7X_cjs = require('./chunk-T7PU2V7X.cjs');
5
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
6
+ var CustomPromise = class extends Promise {
7
+ _value;
8
+ _error;
9
+ _finish = [];
10
+ constructor(executor) {
11
+ let resolveOuter;
12
+ let rejectOuter;
13
+ super((resolve, reject) => {
14
+ resolveOuter = resolve;
15
+ rejectOuter = reject;
16
+ });
17
+ executor(
18
+ (v) => {
19
+ this._value = v;
20
+ resolveOuter(v);
21
+ this._finish.forEach((f) => f(v, void 0));
22
+ },
23
+ (e) => {
24
+ this._error = e;
25
+ rejectOuter(e);
26
+ this._finish.forEach((f) => f(void 0, e));
27
+ }
28
+ );
29
+ Object.setPrototypeOf(this, new.target.prototype);
30
+ }
31
+ then(onfulfilled, onrejected) {
32
+ return super.then(onfulfilled, onrejected);
33
+ }
34
+ catch(onrejected) {
35
+ return super.catch(onrejected);
36
+ }
37
+ /**
38
+ * Registers a callback to be invoked **exactly once** when the
39
+ * promise settles, with access to both the resolved value and
40
+ * the rejection reason.
41
+ *
42
+ * If the promise is already settled when `finish` is called,
43
+ * the callback executes immediately on the same tick.
44
+ *
45
+ * @param cb Callback receiving the final `(value, error)`.
46
+ * @returns `this` for fluent chaining.
47
+ */
48
+ finish(cb) {
49
+ if (this._value !== void 0 || this._error !== void 0) {
50
+ cb(this._value, this._error);
51
+ } else {
52
+ this._finish.push(cb);
53
+ }
54
+ return this;
55
+ }
56
+ };
57
+ var AbortError = class extends Error {
58
+ constructor(message = "The operation was aborted", name = "AbortError") {
59
+ super(message);
60
+ this.name = name;
61
+ }
62
+ };
63
+ var delay = (milliSeconds = 1e3, signal) => {
64
+ if (!chunkDVMHRLKP_cjs.isInteger(milliSeconds) || milliSeconds <= 0) {
65
+ throw new TypeError(
66
+ `First parameter (\`milliSeconds\`) must be of type \`number\` and value must be a \`non-zero\`, \`non-NaN\`, \`non-negative\`, and \`integer-number\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
67
+ milliSeconds
68
+ )}\`, with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(milliSeconds)}\`.`
69
+ );
70
+ }
71
+ if (chunkPZQ6I4JJ_cjs.isNull(signal) || signal && !(signal instanceof AbortSignal)) {
72
+ throw new TypeError(
73
+ "Second parameter (`signal`) must be an `instance of AbortSignal` if provided."
74
+ );
75
+ }
76
+ return new Promise((resolve, reject) => {
77
+ const timer = setTimeout(() => {
78
+ cleanup();
79
+ resolve();
80
+ }, milliSeconds);
81
+ const cleanup = () => {
82
+ clearTimeout(timer);
83
+ if (signal) signal.removeEventListener("abort", onAbort);
84
+ };
85
+ const onAbort = () => {
86
+ cleanup();
87
+ reject(
88
+ new AbortError(
89
+ "Function `delay` from `@rzl-zone/utils-js` was aborted.",
90
+ "AbortError"
91
+ )
92
+ );
93
+ };
94
+ if (signal) {
95
+ if (signal.aborted) {
96
+ onAbort();
97
+ } else {
98
+ signal.addEventListener("abort", onAbort, { once: true });
99
+ }
100
+ }
101
+ });
102
+ };
103
+
104
+ exports.CustomPromise = CustomPromise;
105
+ exports.delay = delay;