@etsoo/shared 1.2.51 → 1.2.54

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 (94) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/README.md +1 -1
  3. package/lib/cjs/ActionResult.d.ts +1 -1
  4. package/lib/cjs/ActionResult.js +3 -3
  5. package/lib/cjs/ArrayUtils.d.ts +1 -1
  6. package/lib/cjs/ArrayUtils.js +4 -4
  7. package/lib/cjs/ColorUtils.d.ts +1 -1
  8. package/lib/cjs/ColorUtils.js +2 -2
  9. package/lib/cjs/DataTypes.d.ts +6 -6
  10. package/lib/cjs/DataTypes.js +50 -51
  11. package/lib/cjs/DateUtils.d.ts +1 -1
  12. package/lib/cjs/DateUtils.js +27 -28
  13. package/lib/cjs/DomUtils.d.ts +3 -3
  14. package/lib/cjs/DomUtils.js +64 -73
  15. package/lib/cjs/ExtendUtils.d.ts +1 -1
  16. package/lib/cjs/ExtendUtils.js +6 -6
  17. package/lib/cjs/IActionResult.d.ts +15 -2
  18. package/lib/cjs/NumberUtils.d.ts +1 -1
  19. package/lib/cjs/NumberUtils.js +9 -9
  20. package/lib/cjs/StorageUtils.js +2 -2
  21. package/lib/cjs/Utils.d.ts +4 -4
  22. package/lib/cjs/Utils.js +58 -62
  23. package/lib/cjs/index.d.ts +22 -22
  24. package/lib/cjs/storage/WindowStorage.d.ts +1 -1
  25. package/lib/cjs/types/ContentDisposition.d.ts +2 -2
  26. package/lib/cjs/types/ContentDisposition.js +11 -13
  27. package/lib/cjs/types/EColor.js +5 -7
  28. package/lib/cjs/types/EHistory.d.ts +3 -3
  29. package/lib/cjs/types/EHistory.js +4 -4
  30. package/lib/cjs/types/ErrorData.d.ts +1 -1
  31. package/lib/cjs/types/EventClass.js +1 -1
  32. package/lib/mjs/ActionResult.d.ts +1 -1
  33. package/lib/mjs/ActionResult.js +3 -3
  34. package/lib/mjs/ArrayUtils.d.ts +1 -1
  35. package/lib/mjs/ArrayUtils.js +5 -5
  36. package/lib/mjs/ColorUtils.d.ts +1 -1
  37. package/lib/mjs/ColorUtils.js +3 -3
  38. package/lib/mjs/DataTypes.d.ts +6 -6
  39. package/lib/mjs/DataTypes.js +50 -51
  40. package/lib/mjs/DateUtils.d.ts +1 -1
  41. package/lib/mjs/DateUtils.js +27 -28
  42. package/lib/mjs/DomUtils.d.ts +3 -3
  43. package/lib/mjs/DomUtils.js +67 -76
  44. package/lib/mjs/ExtendUtils.d.ts +1 -1
  45. package/lib/mjs/ExtendUtils.js +6 -6
  46. package/lib/mjs/IActionResult.d.ts +15 -2
  47. package/lib/mjs/NumberUtils.d.ts +1 -1
  48. package/lib/mjs/NumberUtils.js +9 -9
  49. package/lib/mjs/StorageUtils.js +4 -4
  50. package/lib/mjs/Utils.d.ts +4 -4
  51. package/lib/mjs/Utils.js +61 -65
  52. package/lib/mjs/index.d.ts +22 -22
  53. package/lib/mjs/index.js +22 -22
  54. package/lib/mjs/storage/WindowStorage.d.ts +1 -1
  55. package/lib/mjs/storage/WindowStorage.js +2 -2
  56. package/lib/mjs/types/ContentDisposition.d.ts +2 -2
  57. package/lib/mjs/types/ContentDisposition.js +12 -14
  58. package/lib/mjs/types/EColor.js +5 -7
  59. package/lib/mjs/types/EHistory.d.ts +3 -3
  60. package/lib/mjs/types/EHistory.js +5 -5
  61. package/lib/mjs/types/ErrorData.d.ts +1 -1
  62. package/lib/mjs/types/EventClass.js +1 -1
  63. package/package.json +61 -63
  64. package/src/ActionResult.ts +23 -23
  65. package/src/ArrayUtils.ts +164 -172
  66. package/src/ColorUtils.ts +80 -82
  67. package/src/DataTypes.ts +745 -754
  68. package/src/DateUtils.ts +266 -268
  69. package/src/DomUtils.ts +806 -831
  70. package/src/ExtendUtils.ts +191 -191
  71. package/src/IActionResult.ts +55 -40
  72. package/src/Keyboard.ts +258 -258
  73. package/src/NumberUtils.ts +135 -135
  74. package/src/StorageUtils.ts +117 -117
  75. package/src/Utils.ts +908 -930
  76. package/src/index.ts +22 -22
  77. package/src/node/Storage.ts +53 -53
  78. package/src/storage/IStorage.ts +62 -62
  79. package/src/storage/WindowStorage.ts +140 -140
  80. package/src/types/ContentDisposition.ts +59 -63
  81. package/src/types/DataError.ts +15 -15
  82. package/src/types/DelayedExecutorType.ts +15 -15
  83. package/src/types/EColor.ts +241 -248
  84. package/src/types/EHistory.ts +151 -151
  85. package/src/types/ErrorData.ts +11 -11
  86. package/src/types/EventClass.ts +220 -220
  87. package/src/types/FormData.ts +25 -25
  88. package/src/types/ParsedPath.ts +5 -5
  89. package/tsconfig.cjs.json +16 -16
  90. package/tsconfig.json +16 -16
  91. package/.eslintignore +0 -3
  92. package/.eslintrc.json +0 -29
  93. package/.prettierignore +0 -5
  94. package/.prettierrc +0 -6
package/src/index.ts CHANGED
@@ -1,24 +1,24 @@
1
- export * from './types/ContentDisposition';
2
- export * from './types/DataError';
3
- export * from './types/DelayedExecutorType';
4
- export * from './types/EColor';
5
- export * from './types/EHistory';
6
- export * from './types/ErrorData';
7
- export * from './types/EventClass';
8
- export * from './types/FormData';
1
+ export * from "./types/ContentDisposition";
2
+ export * from "./types/DataError";
3
+ export * from "./types/DelayedExecutorType";
4
+ export * from "./types/EColor";
5
+ export * from "./types/EHistory";
6
+ export * from "./types/ErrorData";
7
+ export * from "./types/EventClass";
8
+ export * from "./types/FormData";
9
9
 
10
- export * from './storage/IStorage';
11
- export * from './storage/WindowStorage';
10
+ export * from "./storage/IStorage";
11
+ export * from "./storage/WindowStorage";
12
12
 
13
- export * from './ActionResult';
14
- export * from './ArrayUtils';
15
- export * from './DataTypes';
16
- export * from './ColorUtils';
17
- export * from './DateUtils';
18
- export * from './DomUtils';
19
- export * from './ExtendUtils';
20
- export * from './IActionResult';
21
- export * from './Keyboard';
22
- export * from './NumberUtils';
23
- export * from './StorageUtils';
24
- export * from './Utils';
13
+ export * from "./ActionResult";
14
+ export * from "./ArrayUtils";
15
+ export * from "./DataTypes";
16
+ export * from "./ColorUtils";
17
+ export * from "./DateUtils";
18
+ export * from "./DomUtils";
19
+ export * from "./ExtendUtils";
20
+ export * from "./IActionResult";
21
+ export * from "./Keyboard";
22
+ export * from "./NumberUtils";
23
+ export * from "./StorageUtils";
24
+ export * from "./Utils";
@@ -3,65 +3,65 @@
3
3
  * Please take care of the persistence with source property
4
4
  */
5
5
  export class NodeStorage {
6
- /**
7
- * Storage source
8
- */
9
- source: [string, string][] = [];
6
+ /**
7
+ * Storage source
8
+ */
9
+ source: [string, string][] = [];
10
10
 
11
- /**
12
- * Constructor
13
- */
14
- constructor() {}
11
+ /**
12
+ * Constructor
13
+ */
14
+ constructor() {}
15
15
 
16
- /**
17
- * Returns the number of key/value pairs currently present in the list
18
- */
19
- get length(): number {
20
- return this.source.length;
21
- }
16
+ /**
17
+ * Returns the number of key/value pairs currently present in the list
18
+ */
19
+ get length(): number {
20
+ return this.source.length;
21
+ }
22
22
 
23
- /**
24
- * Empties the list associated with the object of all key/value pairs, if there are any.
25
- */
26
- clear(): void {
27
- this.source = [];
28
- }
23
+ /**
24
+ * Empties the list associated with the object of all key/value pairs, if there are any.
25
+ */
26
+ clear(): void {
27
+ this.source = [];
28
+ }
29
29
 
30
- /**
31
- * Returns the current value associated with the given key, or null if the given key does not exist in the list
32
- * @param key Key
33
- */
34
- getItem(key: string): string | null {
35
- const item = this.source.find((p) => p[0] === key);
36
- return item == null ? null : item[1];
37
- }
30
+ /**
31
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list
32
+ * @param key Key
33
+ */
34
+ getItem(key: string): string | null {
35
+ const item = this.source.find((p) => p[0] === key);
36
+ return item == null ? null : item[1];
37
+ }
38
38
 
39
- /**
40
- * Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
41
- */
42
- key(index: number): string | null {
43
- if (index < 0 || index >= this.source.length) return null;
44
- return this.source[index][0];
45
- }
39
+ /**
40
+ * Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
41
+ */
42
+ key(index: number): string | null {
43
+ if (index < 0 || index >= this.source.length) return null;
44
+ return this.source[index][0];
45
+ }
46
46
 
47
- /**
48
- * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
49
- */
50
- removeItem(key: string): void {
51
- this.source.remove((p) => p[0] === key);
52
- }
47
+ /**
48
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
49
+ */
50
+ removeItem(key: string): void {
51
+ this.source.remove((p) => p[0] === key);
52
+ }
53
53
 
54
- /**
55
- * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
56
- *
57
- * Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
58
- */
59
- setItem(key: string, value: string): void {
60
- const item = this.source.find((p) => p[0] === key);
61
- if (item) {
62
- item[1] = value;
63
- } else {
64
- this.source.push([key, value]);
65
- }
54
+ /**
55
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
56
+ *
57
+ * Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
58
+ */
59
+ setItem(key: string, value: string): void {
60
+ const item = this.source.find((p) => p[0] === key);
61
+ if (item) {
62
+ item[1] = value;
63
+ } else {
64
+ this.source.push([key, value]);
66
65
  }
66
+ }
67
67
  }
@@ -2,76 +2,76 @@
2
2
  * Storage interface
3
3
  */
4
4
  export interface IStorage {
5
- /**
6
- * Clear keys
7
- * @param keys Keys
8
- * @param persisted Persisted or session data
9
- */
10
- clear(keys: string[], persisted?: boolean): void;
5
+ /**
6
+ * Clear keys
7
+ * @param keys Keys
8
+ * @param persisted Persisted or session data
9
+ */
10
+ clear(keys: string[], persisted?: boolean): void;
11
11
 
12
- /**
13
- * Copy keys to session from persisted source
14
- * @param keys Keys
15
- * @param removeSource Remove from the source
16
- */
17
- copyFrom(keys: string[], removeSource?: boolean): void;
12
+ /**
13
+ * Copy keys to session from persisted source
14
+ * @param keys Keys
15
+ * @param removeSource Remove from the source
16
+ */
17
+ copyFrom(keys: string[], removeSource?: boolean): void;
18
18
 
19
- /**
20
- * Copy keys to persisted source
21
- * @param keys Keys
22
- * @param removeSource Remove from the source
23
- */
24
- copyTo(keys: string[], removeSource?: boolean): void;
19
+ /**
20
+ * Copy keys to persisted source
21
+ * @param keys Keys
22
+ * @param removeSource Remove from the source
23
+ */
24
+ copyTo(keys: string[], removeSource?: boolean): void;
25
25
 
26
- /**
27
- * Get data
28
- * @param key Key name
29
- */
30
- getData<T>(key: string): T | undefined;
26
+ /**
27
+ * Get data
28
+ * @param key Key name
29
+ */
30
+ getData<T>(key: string): T | undefined;
31
31
 
32
- /**
33
- * Get data with default value
34
- * @param key Key name
35
- * @param defaultValue Default value
36
- */
37
- getData<T>(key: string, defaultValue: T): T;
32
+ /**
33
+ * Get data with default value
34
+ * @param key Key name
35
+ * @param defaultValue Default value
36
+ */
37
+ getData<T>(key: string, defaultValue: T): T;
38
38
 
39
- /**
40
- * Get persisted data
41
- * @param key Key name
42
- */
43
- getPersistedData<T>(key: string): T | undefined;
39
+ /**
40
+ * Get persisted data
41
+ * @param key Key name
42
+ */
43
+ getPersistedData<T>(key: string): T | undefined;
44
44
 
45
- /**
46
- * Get persisted data with default value
47
- * @param key Key name
48
- * @param defaultValue Default value
49
- */
50
- getPersistedData<T>(key: string, defaultValue: T): T;
45
+ /**
46
+ * Get persisted data with default value
47
+ * @param key Key name
48
+ * @param defaultValue Default value
49
+ */
50
+ getPersistedData<T>(key: string, defaultValue: T): T;
51
51
 
52
- /**
53
- * Get object data
54
- * @param key Key name
55
- */
56
- getObject<T extends object>(key: string): T | undefined;
52
+ /**
53
+ * Get object data
54
+ * @param key Key name
55
+ */
56
+ getObject<T extends object>(key: string): T | undefined;
57
57
 
58
- /**
59
- * Get persisted object data
60
- * @param key Key name
61
- */
62
- getPersistedObject<T extends object>(key: string): T | undefined;
58
+ /**
59
+ * Get persisted object data
60
+ * @param key Key name
61
+ */
62
+ getPersistedObject<T extends object>(key: string): T | undefined;
63
63
 
64
- /**
65
- * Set data
66
- * @param key Key name
67
- * @param data Data, null for removal
68
- */
69
- setData(key: string, data: unknown): void;
64
+ /**
65
+ * Set data
66
+ * @param key Key name
67
+ * @param data Data, null for removal
68
+ */
69
+ setData(key: string, data: unknown): void;
70
70
 
71
- /**
72
- * Set persisted data
73
- * @param key Key name
74
- * @param data Data, null for removal
75
- */
76
- setPersistedData(key: string, data: unknown): void;
71
+ /**
72
+ * Set persisted data
73
+ * @param key Key name
74
+ * @param data Data, null for removal
75
+ */
76
+ setPersistedData(key: string, data: unknown): void;
77
77
  }
@@ -1,147 +1,147 @@
1
- import { StorageUtils } from '../StorageUtils';
2
- import { Utils } from '../Utils';
3
- import { IStorage } from './IStorage';
1
+ import { StorageUtils } from "../StorageUtils";
2
+ import { Utils } from "../Utils";
3
+ import { IStorage } from "./IStorage";
4
4
 
5
5
  /**
6
6
  * Window storage
7
7
  * https://developer.mozilla.org/en-US/docs/Web/API/Storage
8
8
  */
9
9
  export class WindowStorage implements IStorage {
10
- /**
11
- * Clear keys
12
- * @param keys Keys
13
- * @param persisted Persisted or session data
14
- */
15
- clear(keys: string[], persisted?: boolean) {
16
- keys.forEach((key) => {
17
- if (persisted) this.setPersistedData(key, undefined);
18
- else this.setData(key, undefined);
19
- });
20
- }
21
-
22
- /**
23
- * Copy keys to session from persisted source
24
- * @param keys Keys
25
- * @param removeSource Remove from the source
26
- */
27
- copyFrom(keys: string[], removeSource?: boolean) {
28
- keys.forEach((key) => {
29
- this.setData(key, this.getPersistedData(key));
30
- if (removeSource) this.setPersistedData(key, undefined);
31
- });
32
- }
33
-
34
- /**
35
- * Copy keys to persisted source
36
- * @param keys Keys
37
- * @param removeSource Remove from the source
38
- */
39
- copyTo(keys: string[], removeSource?: boolean) {
40
- keys.forEach((key) => {
41
- this.setPersistedData(key, this.getData(key));
42
- if (removeSource) this.setData(key, undefined);
43
- });
44
- }
45
-
46
- /**
47
- * Get data
48
- * @param key Key name
49
- */
50
- getData<T>(key: string): T | undefined;
51
-
52
- /**
53
- * Get data with default value
54
- * @param key Key name
55
- * @param defaultValue Default value
56
- */
57
- getData<T>(key: string, defaultValue: T): T;
58
-
59
- /**
60
- * Get data
61
- * @param key Key name
62
- * @param defaultValue Default value
63
- */
64
- getData<T>(key: string, defaultValue?: T): T | undefined {
65
- // Get storage
66
- const data = sessionStorage.getItem(key);
67
-
68
- // No default value
69
- if (defaultValue == null) return Utils.parseString<T>(data);
70
-
71
- // Return
72
- return Utils.parseString<T>(data, defaultValue);
73
- }
74
-
75
- /**
76
- * Get persisted data
77
- * @param key Key name
78
- */
79
- getPersistedData<T>(key: string): T | undefined;
80
-
81
- /**
82
- * Get persisted data with default value
83
- * @param key Key name
84
- * @param defaultValue Default value
85
- */
86
- getPersistedData<T>(key: string, defaultValue: T): T;
87
-
88
- /**
89
- * Get persisted data
90
- * @param key Key name
91
- * @param defaultValue Default value
92
- */
93
- getPersistedData<T>(key: string, defaultValue?: T): T | undefined {
94
- // Get storage
95
- const data = localStorage.getItem(key);
96
-
97
- // No default value
98
- if (defaultValue == null) return Utils.parseString<T>(data);
99
-
100
- // Return
101
- return Utils.parseString<T>(data, defaultValue);
102
- }
103
-
104
- /**
105
- * Get object data
106
- * @param key Key name
107
- */
108
- getObject<T extends object>(key: string) {
109
- // Get storage
110
- const data = sessionStorage.getItem(key);
111
-
112
- if (data == null) return undefined;
113
-
114
- return <T>JSON.parse(data);
115
- }
116
-
117
- /**
118
- * Get persisted object data
119
- * @param key Key name
120
- */
121
- getPersistedObject<T extends object>(key: string) {
122
- // Get storage
123
- const data = localStorage.getItem(key);
124
-
125
- if (data == null) return undefined;
126
-
127
- return <T>JSON.parse(data);
128
- }
129
-
130
- /**
131
- * Set data
132
- * @param key Key name
133
- * @param data Data, null for removal
134
- */
135
- setData(key: string, data: unknown) {
136
- StorageUtils.setSessionData(key, data);
137
- }
138
-
139
- /**
140
- * Set persisted data
141
- * @param key Key name
142
- * @param data Data, null for removal
143
- */
144
- setPersistedData(key: string, data: unknown) {
145
- StorageUtils.setLocalData(key, data);
146
- }
10
+ /**
11
+ * Clear keys
12
+ * @param keys Keys
13
+ * @param persisted Persisted or session data
14
+ */
15
+ clear(keys: string[], persisted?: boolean) {
16
+ keys.forEach((key) => {
17
+ if (persisted) this.setPersistedData(key, undefined);
18
+ else this.setData(key, undefined);
19
+ });
20
+ }
21
+
22
+ /**
23
+ * Copy keys to session from persisted source
24
+ * @param keys Keys
25
+ * @param removeSource Remove from the source
26
+ */
27
+ copyFrom(keys: string[], removeSource?: boolean) {
28
+ keys.forEach((key) => {
29
+ this.setData(key, this.getPersistedData(key));
30
+ if (removeSource) this.setPersistedData(key, undefined);
31
+ });
32
+ }
33
+
34
+ /**
35
+ * Copy keys to persisted source
36
+ * @param keys Keys
37
+ * @param removeSource Remove from the source
38
+ */
39
+ copyTo(keys: string[], removeSource?: boolean) {
40
+ keys.forEach((key) => {
41
+ this.setPersistedData(key, this.getData(key));
42
+ if (removeSource) this.setData(key, undefined);
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Get data
48
+ * @param key Key name
49
+ */
50
+ getData<T>(key: string): T | undefined;
51
+
52
+ /**
53
+ * Get data with default value
54
+ * @param key Key name
55
+ * @param defaultValue Default value
56
+ */
57
+ getData<T>(key: string, defaultValue: T): T;
58
+
59
+ /**
60
+ * Get data
61
+ * @param key Key name
62
+ * @param defaultValue Default value
63
+ */
64
+ getData<T>(key: string, defaultValue?: T): T | undefined {
65
+ // Get storage
66
+ const data = sessionStorage.getItem(key);
67
+
68
+ // No default value
69
+ if (defaultValue == null) return Utils.parseString<T>(data);
70
+
71
+ // Return
72
+ return Utils.parseString<T>(data, defaultValue);
73
+ }
74
+
75
+ /**
76
+ * Get persisted data
77
+ * @param key Key name
78
+ */
79
+ getPersistedData<T>(key: string): T | undefined;
80
+
81
+ /**
82
+ * Get persisted data with default value
83
+ * @param key Key name
84
+ * @param defaultValue Default value
85
+ */
86
+ getPersistedData<T>(key: string, defaultValue: T): T;
87
+
88
+ /**
89
+ * Get persisted data
90
+ * @param key Key name
91
+ * @param defaultValue Default value
92
+ */
93
+ getPersistedData<T>(key: string, defaultValue?: T): T | undefined {
94
+ // Get storage
95
+ const data = localStorage.getItem(key);
96
+
97
+ // No default value
98
+ if (defaultValue == null) return Utils.parseString<T>(data);
99
+
100
+ // Return
101
+ return Utils.parseString<T>(data, defaultValue);
102
+ }
103
+
104
+ /**
105
+ * Get object data
106
+ * @param key Key name
107
+ */
108
+ getObject<T extends object>(key: string) {
109
+ // Get storage
110
+ const data = sessionStorage.getItem(key);
111
+
112
+ if (data == null) return undefined;
113
+
114
+ return <T>JSON.parse(data);
115
+ }
116
+
117
+ /**
118
+ * Get persisted object data
119
+ * @param key Key name
120
+ */
121
+ getPersistedObject<T extends object>(key: string) {
122
+ // Get storage
123
+ const data = localStorage.getItem(key);
124
+
125
+ if (data == null) return undefined;
126
+
127
+ return <T>JSON.parse(data);
128
+ }
129
+
130
+ /**
131
+ * Set data
132
+ * @param key Key name
133
+ * @param data Data, null for removal
134
+ */
135
+ setData(key: string, data: unknown) {
136
+ StorageUtils.setSessionData(key, data);
137
+ }
138
+
139
+ /**
140
+ * Set persisted data
141
+ * @param key Key name
142
+ * @param data Data, null for removal
143
+ */
144
+ setPersistedData(key: string, data: unknown) {
145
+ StorageUtils.setLocalData(key, data);
146
+ }
147
147
  }