@etsoo/shared 1.2.52 → 1.2.55

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 (106) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/__tests__/ArrayUtils.ts +126 -126
  3. package/__tests__/ColorUtils.ts +24 -24
  4. package/__tests__/ContentDisposition.ts +18 -18
  5. package/__tests__/DataTypes.ts +222 -204
  6. package/__tests__/DateUtils.ts +82 -82
  7. package/__tests__/DomUtils.ts +352 -352
  8. package/__tests__/EHistory.ts +62 -62
  9. package/__tests__/ExtendUtils.ts +40 -40
  10. package/__tests__/Keyboard.ts +14 -14
  11. package/__tests__/NumberUtils.ts +37 -39
  12. package/__tests__/StorageUtils.ts +27 -27
  13. package/__tests__/Utils.ts +361 -363
  14. package/__tests__/tsconfig.json +15 -15
  15. package/lib/cjs/ActionResult.d.ts +1 -1
  16. package/lib/cjs/ActionResult.js +3 -3
  17. package/lib/cjs/ArrayUtils.d.ts +1 -1
  18. package/lib/cjs/ArrayUtils.js +4 -4
  19. package/lib/cjs/ColorUtils.d.ts +1 -1
  20. package/lib/cjs/ColorUtils.js +2 -2
  21. package/lib/cjs/DataTypes.d.ts +6 -6
  22. package/lib/cjs/DataTypes.js +50 -51
  23. package/lib/cjs/DateUtils.d.ts +1 -1
  24. package/lib/cjs/DateUtils.js +27 -28
  25. package/lib/cjs/DomUtils.d.ts +3 -3
  26. package/lib/cjs/DomUtils.js +64 -73
  27. package/lib/cjs/ExtendUtils.d.ts +1 -1
  28. package/lib/cjs/ExtendUtils.js +6 -6
  29. package/lib/cjs/IActionResult.d.ts +1 -1
  30. package/lib/cjs/NumberUtils.d.ts +1 -1
  31. package/lib/cjs/NumberUtils.js +9 -9
  32. package/lib/cjs/StorageUtils.js +2 -2
  33. package/lib/cjs/Utils.d.ts +4 -4
  34. package/lib/cjs/Utils.js +58 -62
  35. package/lib/cjs/index.d.ts +22 -22
  36. package/lib/cjs/storage/WindowStorage.d.ts +1 -1
  37. package/lib/cjs/types/ContentDisposition.d.ts +2 -2
  38. package/lib/cjs/types/ContentDisposition.js +11 -13
  39. package/lib/cjs/types/EColor.js +5 -7
  40. package/lib/cjs/types/EHistory.d.ts +3 -3
  41. package/lib/cjs/types/EHistory.js +4 -4
  42. package/lib/cjs/types/ErrorData.d.ts +1 -1
  43. package/lib/cjs/types/EventClass.js +1 -1
  44. package/lib/mjs/ActionResult.d.ts +1 -1
  45. package/lib/mjs/ActionResult.js +3 -3
  46. package/lib/mjs/ArrayUtils.d.ts +1 -1
  47. package/lib/mjs/ArrayUtils.js +5 -5
  48. package/lib/mjs/ColorUtils.d.ts +1 -1
  49. package/lib/mjs/ColorUtils.js +3 -3
  50. package/lib/mjs/DataTypes.d.ts +6 -6
  51. package/lib/mjs/DataTypes.js +50 -51
  52. package/lib/mjs/DateUtils.d.ts +1 -1
  53. package/lib/mjs/DateUtils.js +27 -28
  54. package/lib/mjs/DomUtils.d.ts +3 -3
  55. package/lib/mjs/DomUtils.js +67 -76
  56. package/lib/mjs/ExtendUtils.d.ts +1 -1
  57. package/lib/mjs/ExtendUtils.js +6 -6
  58. package/lib/mjs/IActionResult.d.ts +1 -1
  59. package/lib/mjs/NumberUtils.d.ts +1 -1
  60. package/lib/mjs/NumberUtils.js +9 -9
  61. package/lib/mjs/StorageUtils.js +4 -4
  62. package/lib/mjs/Utils.d.ts +4 -4
  63. package/lib/mjs/Utils.js +61 -65
  64. package/lib/mjs/index.d.ts +22 -22
  65. package/lib/mjs/index.js +22 -22
  66. package/lib/mjs/storage/WindowStorage.d.ts +1 -1
  67. package/lib/mjs/storage/WindowStorage.js +2 -2
  68. package/lib/mjs/types/ContentDisposition.d.ts +2 -2
  69. package/lib/mjs/types/ContentDisposition.js +12 -14
  70. package/lib/mjs/types/EColor.js +5 -7
  71. package/lib/mjs/types/EHistory.d.ts +3 -3
  72. package/lib/mjs/types/EHistory.js +5 -5
  73. package/lib/mjs/types/ErrorData.d.ts +1 -1
  74. package/lib/mjs/types/EventClass.js +1 -1
  75. package/package.json +61 -63
  76. package/src/ActionResult.ts +23 -23
  77. package/src/ArrayUtils.ts +164 -172
  78. package/src/ColorUtils.ts +80 -82
  79. package/src/DataTypes.ts +745 -754
  80. package/src/DateUtils.ts +266 -268
  81. package/src/DomUtils.ts +806 -831
  82. package/src/ExtendUtils.ts +191 -191
  83. package/src/IActionResult.ts +42 -42
  84. package/src/Keyboard.ts +258 -258
  85. package/src/NumberUtils.ts +135 -135
  86. package/src/StorageUtils.ts +117 -117
  87. package/src/Utils.ts +908 -930
  88. package/src/index.ts +22 -22
  89. package/src/node/Storage.ts +53 -53
  90. package/src/storage/IStorage.ts +62 -62
  91. package/src/storage/WindowStorage.ts +140 -140
  92. package/src/types/ContentDisposition.ts +59 -63
  93. package/src/types/DataError.ts +15 -15
  94. package/src/types/DelayedExecutorType.ts +15 -15
  95. package/src/types/EColor.ts +241 -248
  96. package/src/types/EHistory.ts +151 -151
  97. package/src/types/ErrorData.ts +11 -11
  98. package/src/types/EventClass.ts +220 -220
  99. package/src/types/FormData.ts +25 -25
  100. package/src/types/ParsedPath.ts +5 -5
  101. package/tsconfig.cjs.json +16 -16
  102. package/tsconfig.json +16 -16
  103. package/.eslintignore +0 -3
  104. package/.eslintrc.json +0 -29
  105. package/.prettierignore +0 -5
  106. package/.prettierrc +0 -6
@@ -5,10 +5,10 @@ exports.DomUtils = void 0;
5
5
  const DataTypes_1 = require("./DataTypes");
6
6
  const DateUtils_1 = require("./DateUtils");
7
7
  const Utils_1 = require("./Utils");
8
- if (typeof navigator === 'undefined') {
8
+ if (typeof navigator === "undefined") {
9
9
  // Test mock only
10
- globalThis.navigator = { language: 'en-US' };
11
- globalThis.location = { href: 'http://localhost/' };
10
+ globalThis.navigator = { language: "en-US" };
11
+ globalThis.location = { href: "http://localhost/" };
12
12
  }
13
13
  /**
14
14
  * Dom Utilities
@@ -19,11 +19,11 @@ var DomUtils;
19
19
  /**
20
20
  * Language cache parameter name
21
21
  */
22
- DomUtils.CultureField = 'culture';
22
+ DomUtils.CultureField = "culture";
23
23
  /**
24
24
  * Country cache parameter name
25
25
  */
26
- DomUtils.CountryField = 'country';
26
+ DomUtils.CountryField = "country";
27
27
  /**
28
28
  * Clear form data
29
29
  * @param data Form data
@@ -40,7 +40,7 @@ var DomUtils;
40
40
  return;
41
41
  // Get all values
42
42
  const formValues = data.getAll(key);
43
- if (formValues.length == 1 && formValues[0] === '') {
43
+ if (formValues.length == 1 && formValues[0] === "") {
44
44
  // Remove empty field
45
45
  data.delete(key);
46
46
  }
@@ -65,7 +65,7 @@ var DomUtils;
65
65
  const sourceValue = Reflect.get(source, key);
66
66
  if (Array.isArray(sourceValue)) {
67
67
  // Array, types may differ
68
- if (formValues.join('`') === sourceValue.join('`')) {
68
+ if (formValues.join("`") === sourceValue.join("`")) {
69
69
  // Equal value, remove the key
70
70
  data.delete(key);
71
71
  }
@@ -99,8 +99,7 @@ var DomUtils;
99
99
  const entries = Object.entries(isFormData(source) ? formDataToObject(source) : source);
100
100
  for (const [key, value] of entries) {
101
101
  // Is included or keepSource
102
- const property = properties.find((p) => p.localeCompare(key, 'en', { sensitivity: 'base' }) ===
103
- 0) ?? (keepSource ? key : undefined);
102
+ const property = properties.find((p) => p.localeCompare(key, "en", { sensitivity: "base" }) === 0) ?? (keepSource ? key : undefined);
104
103
  if (property == null)
105
104
  continue;
106
105
  // Template value
@@ -138,7 +137,7 @@ var DomUtils;
138
137
  // New data
139
138
  // Object.create(...)
140
139
  const data = {};
141
- if (source != null && typeof source === 'object') {
140
+ if (source != null && typeof source === "object") {
142
141
  // Travel all properties
143
142
  dataAsTraveller(source, data, template, keepSource, false);
144
143
  }
@@ -199,8 +198,7 @@ var DomUtils;
199
198
  // Browser detected
200
199
  if (culture == null) {
201
200
  culture =
202
- (navigator.languages && navigator.languages[0]) ||
203
- navigator.language;
201
+ (navigator.languages && navigator.languages[0]) || navigator.language;
204
202
  }
205
203
  // Return
206
204
  return culture;
@@ -234,7 +232,7 @@ var DomUtils;
234
232
  */
235
233
  async function downloadFile(data, suggestedName, autoDetect = true) {
236
234
  try {
237
- if (autoDetect && 'showSaveFilePicker' in globalThis) {
235
+ if (autoDetect && "showSaveFilePicker" in globalThis) {
238
236
  // AbortError - Use dismisses the window
239
237
  const handle = await globalThis.showSaveFilePicker({
240
238
  suggestedName
@@ -251,11 +249,9 @@ var DomUtils;
251
249
  return true;
252
250
  }
253
251
  else {
254
- const url = window.URL.createObjectURL(data instanceof Blob
255
- ? data
256
- : await new Response(data).blob());
257
- const a = document.createElement('a');
258
- a.style.display = 'none';
252
+ const url = window.URL.createObjectURL(data instanceof Blob ? data : await new Response(data).blob());
253
+ const a = document.createElement("a");
254
+ a.style.display = "none";
259
255
  a.href = url;
260
256
  if (suggestedName)
261
257
  a.download = suggestedName;
@@ -267,7 +263,7 @@ var DomUtils;
267
263
  }
268
264
  }
269
265
  catch (e) {
270
- console.error('DomUtils.downloadFile with error', e);
266
+ console.error("DomUtils.downloadFile with error", e);
271
267
  }
272
268
  return false;
273
269
  }
@@ -316,7 +312,7 @@ var DomUtils;
316
312
  data ?? (data = parseUserAgent());
317
313
  if (!data)
318
314
  return false;
319
- return data.brands.some((item) => item.brand.toLowerCase() === 'micromessenger');
315
+ return data.brands.some((item) => item.brand.toLowerCase() === "micromessenger");
320
316
  }
321
317
  DomUtils.isWechatClient = isWechatClient;
322
318
  /**
@@ -335,8 +331,8 @@ var DomUtils;
335
331
  * @returns Result
336
332
  */
337
333
  DomUtils.en = (resources) => ({
338
- name: 'en',
339
- label: 'English',
334
+ name: "en",
335
+ label: "English",
340
336
  resources
341
337
  });
342
338
  /**
@@ -345,10 +341,10 @@ var DomUtils;
345
341
  * @returns Result
346
342
  */
347
343
  DomUtils.zhHans = (resources) => ({
348
- name: 'zh-Hans',
349
- label: '简体中文',
344
+ name: "zh-Hans",
345
+ label: "简体中文",
350
346
  resources,
351
- compatibleNames: ['zh-CN', 'zh-SG']
347
+ compatibleNames: ["zh-CN", "zh-SG"]
352
348
  });
353
349
  /**
354
350
  * Get traditional Chinese resources definition
@@ -356,10 +352,10 @@ var DomUtils;
356
352
  * @returns Result
357
353
  */
358
354
  DomUtils.zhHant = (resources) => ({
359
- name: 'zh-Hant',
360
- label: '繁體中文',
355
+ name: "zh-Hant",
356
+ label: "繁體中文",
361
357
  resources,
362
- compatibleNames: ['zh-HK', 'zh-TW', 'zh-MO']
358
+ compatibleNames: ["zh-HK", "zh-TW", "zh-MO"]
363
359
  });
364
360
  /**
365
361
  * Get the available culture definition
@@ -376,11 +372,11 @@ var DomUtils;
376
372
  return [exactMatch, CultureMatch.Exact];
377
373
  // Compatible match
378
374
  const compatibleMatch = items.find((item) => item.compatibleNames?.includes(culture) ||
379
- culture.startsWith(item + '-'));
375
+ culture.startsWith(item + "-"));
380
376
  if (compatibleMatch)
381
377
  return [compatibleMatch, CultureMatch.Compatible];
382
378
  // Same part, like zh-CN and zh-HK
383
- const samePart = culture.split('-')[0];
379
+ const samePart = culture.split("-")[0];
384
380
  const samePartMatch = items.find((item) => item.name.startsWith(samePart));
385
381
  if (samePartMatch)
386
382
  return [samePartMatch, CultureMatch.SamePart];
@@ -394,13 +390,13 @@ var DomUtils;
394
390
  */
395
391
  function getInputValue(input) {
396
392
  const type = input.type;
397
- if (type === 'number' || type === 'range') {
393
+ if (type === "number" || type === "range") {
398
394
  const num = input.valueAsNumber;
399
395
  if (isNaN(num))
400
396
  return null;
401
397
  return num;
402
398
  }
403
- else if (type === 'date' || type === 'datetime-local')
399
+ else if (type === "date" || type === "datetime-local")
404
400
  return input.valueAsDate ?? DateUtils_1.DateUtils.parse(input.value);
405
401
  return input.value;
406
402
  }
@@ -421,7 +417,7 @@ var DomUtils;
421
417
  if (Array.isArray(headers)) {
422
418
  return Object.fromEntries(headers);
423
419
  }
424
- if (typeof Headers === 'undefined') {
420
+ if (typeof Headers === "undefined") {
425
421
  return Object.fromEntries(Object.entries(headers));
426
422
  }
427
423
  if (headers instanceof Headers) {
@@ -439,11 +435,11 @@ var DomUtils;
439
435
  * @returns result
440
436
  */
441
437
  function isFormData(input) {
442
- if (typeof input === 'object' &&
438
+ if (typeof input === "object" &&
443
439
  input != null &&
444
- 'entries' in input &&
445
- 'getAll' in input &&
446
- 'keys' in input) {
440
+ "entries" in input &&
441
+ "getAll" in input &&
442
+ "keys" in input) {
447
443
  return true;
448
444
  }
449
445
  return false;
@@ -457,8 +453,8 @@ var DomUtils;
457
453
  if (contentType &&
458
454
  // application/problem+json
459
455
  // application/json
460
- (contentType.includes('json') ||
461
- contentType.startsWith('application/javascript')))
456
+ (contentType.includes("json") ||
457
+ contentType.startsWith("application/javascript")))
462
458
  return true;
463
459
  return false;
464
460
  }
@@ -473,9 +469,7 @@ var DomUtils;
473
469
  for (const newForm of forms) {
474
470
  for (const key of new Set(newForm.keys())) {
475
471
  form.delete(key);
476
- newForm
477
- .getAll(key)
478
- .forEach((value) => form.append(key, value));
472
+ newForm.getAll(key).forEach((value) => form.append(key, value));
479
473
  }
480
474
  }
481
475
  return form;
@@ -509,16 +503,16 @@ var DomUtils;
509
503
  }
510
504
  const parts = ua.split(/(?!\(.*)\s+(?!\()(?![^(]*?\))/g);
511
505
  let mobile = false;
512
- let platform = '';
506
+ let platform = "";
513
507
  let platformVersion;
514
- let device = 'Desktop';
508
+ let device = "Desktop";
515
509
  const brands = [];
516
510
  // with the 'g' will causing failures for multiple calls
517
511
  const platformVersionReg = /^[a-zA-Z0-9-\s]+\s+(0|\d+)(\.(0|\d+)){0,3}(\(|$)/;
518
512
  const versionReg = /^[a-zA-Z0-9]+\/(0|\d+)(\.(0|\d+)){0,3}(\(|$)/;
519
513
  parts.forEach((part) => {
520
514
  const pl = part.toLowerCase();
521
- if (pl.startsWith('mozilla/')) {
515
+ if (pl.startsWith("mozilla/")) {
522
516
  const data = /\((.*)\)$/.exec(part);
523
517
  if (data && data.length > 1) {
524
518
  const pfItems = data[1].split(/;\s*/);
@@ -527,7 +521,7 @@ var DomUtils;
527
521
  if (pfIndex !== -1) {
528
522
  const pfParts = pfItems[pfIndex].split(/\s+/);
529
523
  platformVersion = pfParts.pop();
530
- platform = pfParts.join(' ');
524
+ platform = pfParts.join(" ");
531
525
  }
532
526
  else {
533
527
  const appleVersionReg = /((iPhone|Mac)\s+OS(\s+\w+)?)\s+((0|\d+)(_(0|\d+)){0,3})/i;
@@ -535,46 +529,46 @@ var DomUtils;
535
529
  const match = appleVersionReg.exec(pfItems[i]);
536
530
  if (match && match.length > 4) {
537
531
  platform = match[1];
538
- platformVersion = match[4].replace(/_/g, '.');
532
+ platformVersion = match[4].replace(/_/g, ".");
539
533
  pfItems.splice(i, 1);
540
534
  break;
541
535
  }
542
536
  }
543
537
  }
544
538
  // Device
545
- const deviceIndex = pfItems.findIndex((item) => item.includes(' Build/'));
539
+ const deviceIndex = pfItems.findIndex((item) => item.includes(" Build/"));
546
540
  if (deviceIndex === -1) {
547
541
  const firstItem = pfItems[0];
548
- if (firstItem.toLowerCase() !== 'linux' &&
542
+ if (firstItem.toLowerCase() !== "linux" &&
549
543
  !firstItem.startsWith(platform)) {
550
544
  device = firstItem;
551
545
  pfItems.shift();
552
546
  }
553
547
  }
554
548
  else {
555
- device = pfItems[deviceIndex].split(' Build/')[0];
549
+ device = pfItems[deviceIndex].split(" Build/")[0];
556
550
  pfItems.splice(deviceIndex, 1);
557
551
  }
558
552
  }
559
553
  return;
560
554
  }
561
- if (pl === 'mobile' || pl.startsWith('mobile/')) {
555
+ if (pl === "mobile" || pl.startsWith("mobile/")) {
562
556
  mobile = true;
563
557
  return;
564
558
  }
565
- if (pl === 'version' || pl.startsWith('version/')) {
559
+ if (pl === "version" || pl.startsWith("version/")) {
566
560
  // No process
567
561
  return;
568
562
  }
569
563
  if (versionReg.test(part)) {
570
- let [brand, version] = part.split('/');
571
- const pindex = version.indexOf('(');
564
+ let [brand, version] = part.split("/");
565
+ const pindex = version.indexOf("(");
572
566
  if (pindex > 0) {
573
567
  version = version.substring(0, pindex);
574
568
  }
575
569
  brands.push({
576
570
  brand,
577
- version: Utils_1.Utils.trimEnd(version, '.0')
571
+ version: Utils_1.Utils.trimEnd(version, ".0")
578
572
  });
579
573
  return;
580
574
  }
@@ -588,7 +582,7 @@ var DomUtils;
588
582
  * @param container Container, limits the element range
589
583
  */
590
584
  function setFocus(name, container) {
591
- const elementName = typeof name === 'string' ? name : Object.keys(name)[0];
585
+ const elementName = typeof name === "string" ? name : Object.keys(name)[0];
592
586
  container ?? (container = document.body);
593
587
  const element = container.querySelector(`[name="${elementName}"]`);
594
588
  if (element != null)
@@ -605,13 +599,13 @@ var DomUtils;
605
599
  // Avoid multiple setup, if there is already a handler, please set "window.onunhandledrejection = null" first
606
600
  if (window.onunhandledrejection)
607
601
  return;
608
- const errorType = 'error';
602
+ const errorType = "error";
609
603
  const errorPD = Utils_1.Utils.getResult(preventDefault, errorType) ?? true;
610
604
  window.onerror = (message, source, lineNo, colNo, error) => {
611
605
  // Default source
612
606
  source || (source = window.location.href);
613
607
  let data;
614
- if (typeof message === 'string') {
608
+ if (typeof message === "string") {
615
609
  data = {
616
610
  type: errorType,
617
611
  message, // Share the same message with error
@@ -625,8 +619,7 @@ var DomUtils;
625
619
  data = {
626
620
  type: errorType,
627
621
  subType: message.type,
628
- message: error?.message ??
629
- `${message.currentTarget} event error`,
622
+ message: error?.message ?? `${message.currentTarget} event error`,
630
623
  source,
631
624
  lineNo,
632
625
  colNo,
@@ -637,7 +630,7 @@ var DomUtils;
637
630
  // Return true to suppress error alert
638
631
  return errorPD;
639
632
  };
640
- const rejectionType = 'unhandledrejection';
633
+ const rejectionType = "unhandledrejection";
641
634
  const rejectionPD = Utils_1.Utils.getResult(preventDefault, rejectionType) ?? true;
642
635
  window.onunhandledrejection = (event) => {
643
636
  if (rejectionPD)
@@ -658,9 +651,7 @@ var DomUtils;
658
651
  else {
659
652
  data = {
660
653
  type: rejectionType,
661
- message: typeof reason === 'string'
662
- ? reason
663
- : JSON.stringify(reason),
654
+ message: typeof reason === "string" ? reason : JSON.stringify(reason),
664
655
  source
665
656
  };
666
657
  }
@@ -674,14 +665,14 @@ var DomUtils;
674
665
  orgin(...args);
675
666
  const [first, ...rest] = args;
676
667
  let message;
677
- if (typeof first === 'string') {
668
+ if (typeof first === "string") {
678
669
  message = first;
679
670
  }
680
671
  else {
681
672
  message = JSON.stringify(first);
682
673
  }
683
674
  const stack = rest.length > 0
684
- ? rest.map((item) => JSON.stringify(item)).join(', ')
675
+ ? rest.map((item) => JSON.stringify(item)).join(", ")
685
676
  : undefined;
686
677
  const data = {
687
678
  type,
@@ -692,8 +683,8 @@ var DomUtils;
692
683
  action(data);
693
684
  };
694
685
  };
695
- window.console.warn = localConsole('consoleWarn', window.console.warn);
696
- window.console.error = localConsole('consoleError', window.console.error);
686
+ window.console.warn = localConsole("consoleWarn", window.console.warn);
687
+ window.console.error = localConsole("consoleError", window.console.error);
697
688
  }
698
689
  DomUtils.setupLogging = setupLogging;
699
690
  /**
@@ -704,17 +695,17 @@ var DomUtils;
704
695
  * @returns Result
705
696
  */
706
697
  async function verifyPermission(fileHandle, withWrite = false) {
707
- if (!('queryPermission' in fileHandle) ||
708
- !('requestPermission' in fileHandle))
698
+ if (!("queryPermission" in fileHandle) ||
699
+ !("requestPermission" in fileHandle))
709
700
  return false;
710
701
  // FileSystemHandlePermissionDescriptor
711
- const opts = { mode: withWrite ? 'readwrite' : 'read' };
702
+ const opts = { mode: withWrite ? "readwrite" : "read" };
712
703
  // Check if we already have permission, if so, return true.
713
- if ((await fileHandle.queryPermission(opts)) === 'granted') {
704
+ if ((await fileHandle.queryPermission(opts)) === "granted") {
714
705
  return true;
715
706
  }
716
707
  // Request permission to the file, if the user grants permission, return true.
717
- if ((await fileHandle.requestPermission(opts)) === 'granted') {
708
+ if ((await fileHandle.requestPermission(opts)) === "granted") {
718
709
  return true;
719
710
  }
720
711
  // The user did not grant permission, return false.
@@ -1,4 +1,4 @@
1
- import { DelayedExecutorType } from './types/DelayedExecutorType';
1
+ import { DelayedExecutorType } from "./types/DelayedExecutorType";
2
2
  /**
3
3
  * Extend utilities
4
4
  */
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExtendUtils = void 0;
4
- const hasRequestAnimationFrame = typeof requestAnimationFrame === 'function';
4
+ const hasRequestAnimationFrame = typeof requestAnimationFrame === "function";
5
5
  /**
6
6
  * Extend utilities
7
7
  */
@@ -16,7 +16,7 @@ var ExtendUtils;
16
16
  function applyMixins(derivedCtor, baseCtors) {
17
17
  baseCtors.forEach((baseCtor) => {
18
18
  Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
19
- if (name !== 'constructor') {
19
+ if (name !== "constructor") {
20
20
  // eslint-disable-next-line no-param-reassign
21
21
  derivedCtor.prototype[name] = baseCtor.prototype[name];
22
22
  }
@@ -101,7 +101,7 @@ var ExtendUtils;
101
101
  lastTime = timestamp;
102
102
  }
103
103
  const elapsed = timestamp - lastTime;
104
- const isReady = typeof checkReady === 'number'
104
+ const isReady = typeof checkReady === "number"
105
105
  ? elapsed >= checkReady
106
106
  : checkReady(elapsed);
107
107
  if (isReady) {
@@ -114,7 +114,7 @@ var ExtendUtils;
114
114
  }
115
115
  requestID = requestAnimationFrame(loop);
116
116
  }
117
- else if (typeof checkReady === 'number') {
117
+ else if (typeof checkReady === "number") {
118
118
  requestID = setTimeout(callback, checkReady);
119
119
  }
120
120
  else {
@@ -139,7 +139,7 @@ var ExtendUtils;
139
139
  }
140
140
  return () => {
141
141
  if (requestID) {
142
- if (hasRequestAnimationFrame && typeof requestID === 'number') {
142
+ if (hasRequestAnimationFrame && typeof requestID === "number") {
143
143
  cancelAnimationFrame(requestID);
144
144
  }
145
145
  else {
@@ -184,7 +184,7 @@ var ExtendUtils;
184
184
  }
185
185
  return () => {
186
186
  if (requestID) {
187
- if (hasRequestAnimationFrame && typeof requestID === 'number') {
187
+ if (hasRequestAnimationFrame && typeof requestID === "number") {
188
188
  cancelAnimationFrame(requestID);
189
189
  }
190
190
  else {
@@ -1,4 +1,4 @@
1
- import { IdType } from './DataTypes';
1
+ import { IdType } from "./DataTypes";
2
2
  /**
3
3
  * Result errors
4
4
  * Indexable type
@@ -40,7 +40,7 @@ export declare namespace NumberUtils {
40
40
  * @param locale Locale
41
41
  * @returns Result
42
42
  */
43
- function getCurrencySymbol(code: string, display?: 'symbol' | 'narrowSymbol' | 'name', locale?: string): string | undefined;
43
+ function getCurrencySymbol(code: string, display?: "symbol" | "narrowSymbol" | "name", locale?: string): string | undefined;
44
44
  /**
45
45
  * Parse number
46
46
  * @param rawData Raw data
@@ -36,9 +36,9 @@ var NumberUtils;
36
36
  function formatMoney(input, currency, locale, isInteger = false, options = {}) {
37
37
  if (currency) {
38
38
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
39
- options.style = 'currency';
39
+ options.style = "currency";
40
40
  options.currency = currency;
41
- options.currencyDisplay ?? (options.currencyDisplay = 'narrowSymbol');
41
+ options.currencyDisplay ?? (options.currencyDisplay = "narrowSymbol");
42
42
  }
43
43
  if (isInteger) {
44
44
  options.minimumFractionDigits ?? (options.minimumFractionDigits = 0);
@@ -58,8 +58,8 @@ var NumberUtils;
58
58
  function formatFileSize(size, fractionDigits = 2) {
59
59
  const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
60
60
  return ((size / Math.pow(1024, i)).toFixed(fractionDigits) +
61
- ' ' +
62
- ['B', 'KB', 'MB', 'GB', 'TB', 'PB'][i]);
61
+ " " +
62
+ ["B", "KB", "MB", "GB", "TB", "PB"][i]);
63
63
  }
64
64
  NumberUtils.formatFileSize = formatFileSize;
65
65
  /**
@@ -69,22 +69,22 @@ var NumberUtils;
69
69
  * @param locale Locale
70
70
  * @returns Result
71
71
  */
72
- function getCurrencySymbol(code, display = 'narrowSymbol', locale) {
72
+ function getCurrencySymbol(code, display = "narrowSymbol", locale) {
73
73
  const formatter = new Intl.NumberFormat(locale, {
74
- style: 'currency',
74
+ style: "currency",
75
75
  currency: code,
76
76
  currencyDisplay: display
77
77
  });
78
78
  const parts = formatter.formatToParts();
79
- const symbol = parts.find((part) => part.type === 'currency')?.value;
79
+ const symbol = parts.find((part) => part.type === "currency")?.value;
80
80
  return symbol;
81
81
  }
82
82
  NumberUtils.getCurrencySymbol = getCurrencySymbol;
83
83
  function parse(rawData, defaultValue) {
84
- if (rawData == null || rawData === '') {
84
+ if (rawData == null || rawData === "") {
85
85
  return defaultValue;
86
86
  }
87
- if (typeof rawData === 'number') {
87
+ if (typeof rawData === "number") {
88
88
  if (isNaN(rawData))
89
89
  return defaultValue;
90
90
  return rawData;
@@ -22,7 +22,7 @@ var StorageUtils;
22
22
  localStorage.removeItem(key);
23
23
  return;
24
24
  }
25
- localStorage.setItem(key, typeof data === 'string' ? data : JSON.stringify(data));
25
+ localStorage.setItem(key, typeof data === "string" ? data : JSON.stringify(data));
26
26
  }
27
27
  StorageUtils.setLocalData = setLocalData;
28
28
  /**
@@ -35,7 +35,7 @@ var StorageUtils;
35
35
  sessionStorage.removeItem(key);
36
36
  return;
37
37
  }
38
- sessionStorage.setItem(key, typeof data === 'string' ? data : JSON.stringify(data));
38
+ sessionStorage.setItem(key, typeof data === "string" ? data : JSON.stringify(data));
39
39
  }
40
40
  StorageUtils.setSessionData = setSessionData;
41
41
  /**
@@ -1,5 +1,5 @@
1
- import { DataTypes, IdType } from './DataTypes';
2
- import { ParsedPath } from './types/ParsedPath';
1
+ import { DataTypes, IdType } from "./DataTypes";
2
+ import { ParsedPath } from "./types/ParsedPath";
3
3
  declare global {
4
4
  interface String {
5
5
  /**
@@ -127,7 +127,7 @@ export declare namespace Utils {
127
127
  */
128
128
  function exclude<T extends {
129
129
  [P in D]: IdType;
130
- }, D extends string = 'id'>(items: T[], field: D, ...excludedValues: T[D][]): T[];
130
+ }, D extends string = "id">(items: T[], field: D, ...excludedValues: T[D][]): T[];
131
131
  /**
132
132
  * Async exclude specific items
133
133
  * @param items Items
@@ -137,7 +137,7 @@ export declare namespace Utils {
137
137
  */
138
138
  function excludeAsync<T extends {
139
139
  [P in D]: IdType;
140
- }, D extends string = 'id'>(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]): Promise<T[] | undefined>;
140
+ }, D extends string = "id">(items: Promise<T[] | undefined>, field: D, ...excludedValues: T[D][]): Promise<T[] | undefined>;
141
141
  /**
142
142
  * Format inital character to lower case or upper case
143
143
  * @param input Input string