@develia/commons 0.4.14 → 0.4.16
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/cjs/array.js +43 -1
- package/dist/cjs/array.js.map +1 -1
- package/dist/cjs/async-pool-executor.js +15 -0
- package/dist/cjs/async-pool-executor.js.map +1 -1
- package/dist/cjs/browser/form-utilities.js +26 -0
- package/dist/cjs/browser/form-utilities.js.map +1 -1
- package/dist/cjs/browser/geo-location.js +5 -0
- package/dist/cjs/browser/geo-location.js.map +1 -1
- package/dist/cjs/browser/index.js.map +1 -1
- package/dist/cjs/browser/native-bridge.js +9 -0
- package/dist/cjs/browser/native-bridge.js.map +1 -1
- package/dist/cjs/cancellable-promise.js.map +1 -1
- package/dist/cjs/clean-url-search-params.js +1 -0
- package/dist/cjs/clean-url-search-params.js.map +1 -1
- package/dist/cjs/collections/cache-dictionary.js +39 -0
- package/dist/cjs/collections/cache-dictionary.js.map +1 -1
- package/dist/cjs/collections/default-map.js +25 -1
- package/dist/cjs/collections/default-map.js.map +1 -1
- package/dist/cjs/collections/default-weak-map.js +23 -3
- package/dist/cjs/collections/default-weak-map.js.map +1 -1
- package/dist/cjs/{from.js → collections/from.js} +278 -4
- package/dist/cjs/collections/from.js.map +1 -0
- package/dist/cjs/collections/index.js +3 -1
- package/dist/cjs/collections/index.js.map +1 -1
- package/dist/cjs/draft.js +37 -0
- package/dist/cjs/draft.js.map +1 -1
- package/dist/cjs/event-bus.js +1 -0
- package/dist/cjs/event-bus.js.map +1 -1
- package/dist/cjs/index.js +16 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/key-value-pair.js +6 -0
- package/dist/cjs/key-value-pair.js.map +1 -1
- package/dist/cjs/lazy.js +4 -0
- package/dist/cjs/lazy.js.map +1 -1
- package/dist/cjs/math.js +19 -0
- package/dist/cjs/math.js.map +1 -1
- package/dist/cjs/order.js.map +1 -1
- package/dist/cjs/parse.js +96 -0
- package/dist/cjs/parse.js.map +1 -1
- package/dist/cjs/patch.js +10 -2
- package/dist/cjs/patch.js.map +1 -1
- package/dist/cjs/range.js +154 -0
- package/dist/cjs/range.js.map +1 -0
- package/dist/cjs/stopwatch.js +10 -0
- package/dist/cjs/stopwatch.js.map +1 -1
- package/dist/cjs/string.js +62 -0
- package/dist/cjs/string.js.map +1 -1
- package/dist/cjs/timer.js +7 -0
- package/dist/cjs/timer.js.map +1 -1
- package/dist/cjs/timespan.js +202 -0
- package/dist/cjs/timespan.js.map +1 -1
- package/dist/cjs/type-code.js.map +1 -1
- package/dist/cjs/type.js +80 -1
- package/dist/cjs/type.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utilities.js +183 -0
- package/dist/cjs/utilities.js.map +1 -1
- package/dist/esm/array.js +42 -1
- package/dist/esm/array.js.map +1 -1
- package/dist/esm/async-pool-executor.js +15 -0
- package/dist/esm/async-pool-executor.js.map +1 -1
- package/dist/esm/browser/form-utilities.js +26 -0
- package/dist/esm/browser/form-utilities.js.map +1 -1
- package/dist/esm/browser/geo-location.js +5 -0
- package/dist/esm/browser/geo-location.js.map +1 -1
- package/dist/esm/browser/index.js.map +1 -1
- package/dist/esm/browser/native-bridge.js +9 -0
- package/dist/esm/browser/native-bridge.js.map +1 -1
- package/dist/esm/cancellable-promise.js.map +1 -1
- package/dist/esm/clean-url-search-params.js +1 -0
- package/dist/esm/clean-url-search-params.js.map +1 -1
- package/dist/esm/collections/cache-dictionary.js +39 -0
- package/dist/esm/collections/cache-dictionary.js.map +1 -1
- package/dist/esm/collections/default-map.js +25 -1
- package/dist/esm/collections/default-map.js.map +1 -1
- package/dist/esm/collections/default-weak-map.js +22 -2
- package/dist/esm/collections/default-weak-map.js.map +1 -1
- package/dist/esm/{from.js → collections/from.js} +278 -4
- package/dist/esm/collections/from.js.map +1 -0
- package/dist/esm/collections/index.js +1 -0
- package/dist/esm/collections/index.js.map +1 -1
- package/dist/esm/draft.js +37 -0
- package/dist/esm/draft.js.map +1 -1
- package/dist/esm/event-bus.js +1 -0
- package/dist/esm/event-bus.js.map +1 -1
- package/dist/esm/index.js +14 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/key-value-pair.js +6 -0
- package/dist/esm/key-value-pair.js.map +1 -1
- package/dist/esm/lazy.js +4 -0
- package/dist/esm/lazy.js.map +1 -1
- package/dist/esm/math.js +19 -0
- package/dist/esm/math.js.map +1 -1
- package/dist/esm/order.js.map +1 -1
- package/dist/esm/parse.js +96 -0
- package/dist/esm/parse.js.map +1 -1
- package/dist/esm/patch.js +10 -2
- package/dist/esm/patch.js.map +1 -1
- package/dist/esm/range.js +151 -0
- package/dist/esm/range.js.map +1 -0
- package/dist/esm/stopwatch.js +10 -0
- package/dist/esm/stopwatch.js.map +1 -1
- package/dist/esm/string.js +62 -0
- package/dist/esm/string.js.map +1 -1
- package/dist/esm/timer.js +7 -0
- package/dist/esm/timer.js.map +1 -1
- package/dist/esm/timespan.js +202 -0
- package/dist/esm/timespan.js.map +1 -1
- package/dist/esm/type-code.js.map +1 -1
- package/dist/esm/type.js +80 -1
- package/dist/esm/type.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utilities.js +183 -0
- package/dist/esm/utilities.js.map +1 -1
- package/dist/types/array.d.ts +35 -0
- package/dist/types/array.d.ts.map +1 -1
- package/dist/types/async-pool-executor.d.ts +15 -0
- package/dist/types/async-pool-executor.d.ts.map +1 -1
- package/dist/types/browser/form-utilities.d.ts +13 -0
- package/dist/types/browser/form-utilities.d.ts.map +1 -1
- package/dist/types/browser/index.d.ts.map +1 -1
- package/dist/types/browser/native-bridge.d.ts +6 -0
- package/dist/types/browser/native-bridge.d.ts.map +1 -1
- package/dist/types/collections/cache-dictionary.d.ts +39 -0
- package/dist/types/collections/cache-dictionary.d.ts.map +1 -1
- package/dist/types/collections/default-map.d.ts +23 -0
- package/dist/types/collections/default-map.d.ts.map +1 -1
- package/dist/types/collections/default-weak-map.d.ts +20 -1
- package/dist/types/collections/default-weak-map.d.ts.map +1 -1
- package/dist/types/collections/from.d.ts +333 -0
- package/dist/types/collections/from.d.ts.map +1 -0
- package/dist/types/collections/index.d.ts +1 -0
- package/dist/types/collections/index.d.ts.map +1 -1
- package/dist/types/draft.d.ts +68 -0
- package/dist/types/draft.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key-value-pair.d.ts +6 -0
- package/dist/types/key-value-pair.d.ts.map +1 -1
- package/dist/types/lazy.d.ts +4 -0
- package/dist/types/lazy.d.ts.map +1 -1
- package/dist/types/math.d.ts +19 -0
- package/dist/types/math.d.ts.map +1 -1
- package/dist/types/parse.d.ts +121 -0
- package/dist/types/parse.d.ts.map +1 -1
- package/dist/types/range.d.ts +72 -0
- package/dist/types/range.d.ts.map +1 -0
- package/dist/types/string.d.ts +51 -0
- package/dist/types/string.d.ts.map +1 -1
- package/dist/types/timer.d.ts +7 -0
- package/dist/types/timer.d.ts.map +1 -1
- package/dist/types/timespan.d.ts +202 -0
- package/dist/types/timespan.d.ts.map +1 -1
- package/dist/types/type.d.ts +40 -0
- package/dist/types/type.d.ts.map +1 -1
- package/dist/types/utilities.d.ts +171 -0
- package/dist/types/utilities.d.ts.map +1 -1
- package/dist/web/array.js +42 -1
- package/dist/web/array.js.map +1 -1
- package/dist/web/async-pool-executor.js +15 -0
- package/dist/web/async-pool-executor.js.map +1 -1
- package/dist/web/browser/form-utilities.js +26 -0
- package/dist/web/browser/form-utilities.js.map +1 -1
- package/dist/web/browser/geo-location.js +5 -0
- package/dist/web/browser/geo-location.js.map +1 -1
- package/dist/web/browser/index.js.map +1 -1
- package/dist/web/browser/native-bridge.js +9 -0
- package/dist/web/browser/native-bridge.js.map +1 -1
- package/dist/web/cancellable-promise.js.map +1 -1
- package/dist/web/clean-url-search-params.js +1 -0
- package/dist/web/clean-url-search-params.js.map +1 -1
- package/dist/web/collections/cache-dictionary.js +39 -0
- package/dist/web/collections/cache-dictionary.js.map +1 -1
- package/dist/web/collections/default-map.js +25 -1
- package/dist/web/collections/default-map.js.map +1 -1
- package/dist/web/collections/default-weak-map.js +22 -2
- package/dist/web/collections/default-weak-map.js.map +1 -1
- package/dist/web/{from.js → collections/from.js} +279 -5
- package/dist/web/collections/from.js.map +1 -0
- package/dist/web/collections/index.js +1 -0
- package/dist/web/collections/index.js.map +1 -1
- package/dist/web/draft.js +37 -0
- package/dist/web/draft.js.map +1 -1
- package/dist/web/event-bus.js +1 -0
- package/dist/web/event-bus.js.map +1 -1
- package/dist/web/index.js +14 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/key-value-pair.js +6 -0
- package/dist/web/key-value-pair.js.map +1 -1
- package/dist/web/lazy.js +4 -0
- package/dist/web/lazy.js.map +1 -1
- package/dist/web/math.js +19 -0
- package/dist/web/math.js.map +1 -1
- package/dist/web/order.js.map +1 -1
- package/dist/web/parse.js +96 -0
- package/dist/web/parse.js.map +1 -1
- package/dist/web/patch.js +10 -2
- package/dist/web/patch.js.map +1 -1
- package/dist/web/range.js +151 -0
- package/dist/web/range.js.map +1 -0
- package/dist/web/stopwatch.js +10 -0
- package/dist/web/stopwatch.js.map +1 -1
- package/dist/web/string.js +62 -0
- package/dist/web/string.js.map +1 -1
- package/dist/web/timer.js +7 -0
- package/dist/web/timer.js.map +1 -1
- package/dist/web/timespan.js +202 -0
- package/dist/web/timespan.js.map +1 -1
- package/dist/web/type-code.js.map +1 -1
- package/dist/web/type.js +80 -1
- package/dist/web/type.js.map +1 -1
- package/dist/web/types.js.map +1 -1
- package/dist/web/utilities.js +183 -0
- package/dist/web/utilities.js.map +1 -1
- package/package.json +1 -1
- package/src/array.ts +16 -0
- package/src/browser/index.ts +2 -2
- package/src/collections/cache-dictionary.ts +39 -1
- package/src/collections/default-map.ts +15 -9
- package/src/collections/default-weak-map.ts +14 -12
- package/src/{from.ts → collections/from.ts} +285 -15
- package/src/collections/index.ts +4 -3
- package/src/index.ts +43 -42
- package/src/range.ts +165 -0
- package/src/timespan.ts +199 -20
- package/dist/cjs/from.js.map +0 -1
- package/dist/esm/from.js.map +0 -1
- package/dist/types/from.d.ts +0 -59
- package/dist/types/from.d.ts.map +0 -1
- package/dist/web/from.js.map +0 -1
package/dist/web/utilities.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
1
2
|
import KeyValuePair from "./key-value-pair.js";
|
|
2
3
|
import Type from "./type.js";
|
|
3
4
|
export function lazy(factory) {
|
|
@@ -32,30 +33,89 @@ export function lazy(factory) {
|
|
|
32
33
|
},
|
|
33
34
|
});
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks if an object is iterable.
|
|
38
|
+
*
|
|
39
|
+
* @param {any} obj - The object to check.
|
|
40
|
+
* @return {boolean} - Returns true if the object is iterable, otherwise false.
|
|
41
|
+
*/
|
|
35
42
|
export function isIterable(obj) {
|
|
36
43
|
return obj[Symbol.iterator] === 'function';
|
|
37
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a given value is a string.
|
|
47
|
+
*
|
|
48
|
+
* @param {*} value - The value to check.
|
|
49
|
+
* @return {boolean} - Returns true if the value is a string, otherwise returns false.
|
|
50
|
+
*/
|
|
38
51
|
export function isString(value) {
|
|
39
52
|
return typeof value === 'string';
|
|
40
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Checks if a value is a number.
|
|
56
|
+
*
|
|
57
|
+
* @param {any} value - The value to check.
|
|
58
|
+
* @return {boolean} - Returns true if the value is a number, otherwise false.
|
|
59
|
+
*/
|
|
41
60
|
export function isNumber(value) {
|
|
42
61
|
return typeof value === 'number';
|
|
43
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Checks if a given value is a boolean.
|
|
65
|
+
*
|
|
66
|
+
* @param {any} value - The value to be checked.
|
|
67
|
+
*
|
|
68
|
+
* @return {boolean} - Returns true if the value is a boolean, otherwise false.
|
|
69
|
+
*/
|
|
44
70
|
export function isBoolean(value) {
|
|
45
71
|
return typeof value === 'boolean';
|
|
46
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a value is an object.
|
|
75
|
+
* @param {any} value - The value to be checked.
|
|
76
|
+
* @returns {boolean} - Returns true if the value is an object, otherwise returns false.
|
|
77
|
+
*/
|
|
47
78
|
export function isObject(value) {
|
|
48
79
|
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
49
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Determines if a value is an array.
|
|
83
|
+
*
|
|
84
|
+
* @param value - The value to be checked.
|
|
85
|
+
*
|
|
86
|
+
* @return Whether the value is an array.
|
|
87
|
+
*/
|
|
50
88
|
export function isArray(value) {
|
|
51
89
|
return Array.isArray(value);
|
|
52
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Checks if a value is a function.
|
|
93
|
+
*
|
|
94
|
+
* @param {any} value - The value to be checked.
|
|
95
|
+
* @return {boolean} - Returns true if the value is a function, otherwise returns false.
|
|
96
|
+
*/
|
|
53
97
|
export function isFunction(value) {
|
|
54
98
|
return typeof value === 'function';
|
|
55
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Structural deep equality check.
|
|
102
|
+
*
|
|
103
|
+
* Compares primitives by value, and objects/arrays/Maps/Sets/Dates/RegExps
|
|
104
|
+
* by structure. Handles circular references.
|
|
105
|
+
*
|
|
106
|
+
* @param a - First value.
|
|
107
|
+
* @param b - Second value.
|
|
108
|
+
* @returns `true` if `a` and `b` are structurally equal.
|
|
109
|
+
*/
|
|
56
110
|
export function deepEqual(a, b) {
|
|
57
111
|
return _deepEqual(a, b);
|
|
58
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Internal implementation of deep equality check.
|
|
115
|
+
* @param a - First value.
|
|
116
|
+
* @param b - Second value.
|
|
117
|
+
* @param seen - Internal map used to handle circular references.
|
|
118
|
+
*/
|
|
59
119
|
function _deepEqual(a, b, seen = new WeakMap()) {
|
|
60
120
|
if (a === b)
|
|
61
121
|
return true;
|
|
@@ -104,6 +164,23 @@ function _deepEqual(a, b, seen = new WeakMap()) {
|
|
|
104
164
|
}
|
|
105
165
|
return true;
|
|
106
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Submits an HTML form programmatically using the specified HTTP method (default is POST),
|
|
169
|
+
* without using AJAX. Supports nested objects and arrays using bracket notation (e.g., `user[name]`, `tags[]`).
|
|
170
|
+
*
|
|
171
|
+
* @param url - The destination URL where the form will be submitted.
|
|
172
|
+
* @param data - An object containing key-value pairs. Supports nested structures and arrays.
|
|
173
|
+
* @param method - HTTP method to use: 'POST' or 'GET' (default: 'POST').
|
|
174
|
+
* @param target - Optional parameter specifying the target for the form submission (e.g., '_blank', '_self', '_parent', '_top').
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* Compares two objects or arrays to check if they have the same immediate fields and values,
|
|
178
|
+
* or the same immediate elements if they are arrays (shallow equality check).
|
|
179
|
+
*
|
|
180
|
+
* @param {any} a - The first object or array.
|
|
181
|
+
* @param {any} b - The second object or array.
|
|
182
|
+
* @return {boolean} - Returns true if the objects/arrays are shallowly equal, otherwise false.
|
|
183
|
+
*/
|
|
107
184
|
export function shallowEqual(a, b) {
|
|
108
185
|
if (a === b) {
|
|
109
186
|
return true;
|
|
@@ -127,40 +204,108 @@ export function shallowEqual(a, b) {
|
|
|
127
204
|
}
|
|
128
205
|
return false;
|
|
129
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Pauses the execution of an asynchronous function for a specified duration.
|
|
209
|
+
*
|
|
210
|
+
* @param {number} ms - The delay duration in milliseconds.
|
|
211
|
+
* @return {Promise<void>} A promise that resolves after the specified delay.
|
|
212
|
+
*/
|
|
130
213
|
export async function delay(ms) {
|
|
131
214
|
await new Promise(resolve => setTimeout(resolve, ms));
|
|
132
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Checks if a value is undefined.
|
|
218
|
+
*
|
|
219
|
+
* @param {any} value - The value to check.
|
|
220
|
+
* @returns {boolean} - True if the value is undefined, false otherwise.
|
|
221
|
+
*/
|
|
133
222
|
export function isUndefined(value) {
|
|
134
223
|
return typeof value === 'undefined';
|
|
135
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Checks if a value is defined or not.
|
|
227
|
+
*
|
|
228
|
+
* @param {any} value - The value to be checked.
|
|
229
|
+
*
|
|
230
|
+
* @return {boolean} - True if the value is defined, false otherwise.
|
|
231
|
+
*/
|
|
136
232
|
export function isDefined(value) {
|
|
137
233
|
return typeof value !== 'undefined';
|
|
138
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Checks if a given value is null.
|
|
237
|
+
*
|
|
238
|
+
* @param {any} value - The value to check for null.
|
|
239
|
+
* @return {boolean} - Returns true if the value is null, otherwise returns false.
|
|
240
|
+
*/
|
|
139
241
|
export function isNull(value) {
|
|
140
242
|
return value === null;
|
|
141
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Determines whether the given value is of type bigint.
|
|
246
|
+
* @param {any} value - The value to be checked.
|
|
247
|
+
* @return {boolean} - Returns true if the value is of type bigint, false otherwise.
|
|
248
|
+
*/
|
|
142
249
|
export function isBigInt(value) {
|
|
143
250
|
return typeof value === 'bigint';
|
|
144
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Checks if a given value is a symbol.
|
|
254
|
+
*
|
|
255
|
+
* @param {any} value - The value to be checked.
|
|
256
|
+
* @return {boolean} - Returns true if the value is a symbol, false otherwise.
|
|
257
|
+
*/
|
|
145
258
|
export function isSymbol(value) {
|
|
146
259
|
return typeof value === 'symbol';
|
|
147
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Checks if a value is null or undefined.
|
|
263
|
+
*
|
|
264
|
+
* @param {any} value - The value to check.
|
|
265
|
+
* @return {boolean} - Returns true if the value is null or undefined, false otherwise.
|
|
266
|
+
* @deprecated
|
|
267
|
+
*/
|
|
148
268
|
export function isNullOrUndefined(value) {
|
|
149
269
|
return value === null || typeof value === 'undefined';
|
|
150
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Checks if a value is null or undefined.
|
|
273
|
+
*
|
|
274
|
+
* @param {any} value - The value to check.
|
|
275
|
+
* @return {boolean} - Returns true if the value is null or undefined, false otherwise.
|
|
276
|
+
|
|
277
|
+
*/
|
|
151
278
|
export function isNullish(value) {
|
|
152
279
|
return value === null || typeof value === 'undefined';
|
|
153
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Checks if a given value is empty.
|
|
283
|
+
*
|
|
284
|
+
* @param {any} value - The value to check.
|
|
285
|
+
* @return {boolean} - Returns true if the value is empty, otherwise returns false.
|
|
286
|
+
*/
|
|
154
287
|
export function isEmpty(value) {
|
|
155
288
|
return (Array.isArray(value) && value.length === 0) ||
|
|
156
289
|
(typeof value === 'string' && value === '') ||
|
|
157
290
|
value === null || typeof value === 'undefined';
|
|
158
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Check if a value is empty or contains only whitespace characters.
|
|
294
|
+
*
|
|
295
|
+
* @param {any} value - The value to check.
|
|
296
|
+
* @return {boolean} Returns true if the value is empty or contains only whitespace characters, otherwise returns false.
|
|
297
|
+
*/
|
|
159
298
|
export function isEmptyOrWhitespace(value) {
|
|
160
299
|
return (Array.isArray(value) && value.length === 0) ||
|
|
161
300
|
(typeof value === 'string' && value.trim() === '') ||
|
|
162
301
|
value === null || typeof value === 'undefined';
|
|
163
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Converts an object into an array of key-value pairs.
|
|
305
|
+
*
|
|
306
|
+
* @param {Record<string, any>} obj - The object to convert.
|
|
307
|
+
* @return {KeyValuePair<string, any>[]} - The array of key-value pairs.
|
|
308
|
+
*/
|
|
164
309
|
export function toPairs(obj) {
|
|
165
310
|
let output = [];
|
|
166
311
|
for (const key in obj) {
|
|
@@ -168,6 +313,15 @@ export function toPairs(obj) {
|
|
|
168
313
|
}
|
|
169
314
|
return output;
|
|
170
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Creates an object composed of the picked object properties.
|
|
318
|
+
*
|
|
319
|
+
* @template T - The type of the source object.
|
|
320
|
+
* @template K - The type of the keys to pick.
|
|
321
|
+
* @param obj - The source object.
|
|
322
|
+
* @param props - The property names to pick.
|
|
323
|
+
* @returns A new object with the picked properties.
|
|
324
|
+
*/
|
|
171
325
|
export function pick(obj, props) {
|
|
172
326
|
const result = {};
|
|
173
327
|
if (obj === null || typeof obj !== 'object') {
|
|
@@ -180,6 +334,12 @@ export function pick(obj, props) {
|
|
|
180
334
|
}
|
|
181
335
|
return result;
|
|
182
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Converts a given thing into a Promise.
|
|
339
|
+
* @template T
|
|
340
|
+
* @param {any} thing - The thing to be converted into a Promise.
|
|
341
|
+
* @returns {Promise<T>} - A Promise representing the given thing.
|
|
342
|
+
*/
|
|
183
343
|
export function promisify(thing) {
|
|
184
344
|
if (thing instanceof Promise)
|
|
185
345
|
return thing;
|
|
@@ -196,9 +356,25 @@ export function promisify(thing) {
|
|
|
196
356
|
}
|
|
197
357
|
return Promise.resolve(thing);
|
|
198
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Create a deep, independent copy of a value.
|
|
361
|
+
*
|
|
362
|
+
* Supports primitives, plain objects, arrays, `Date`, `RegExp`, `Map`, `Set`,
|
|
363
|
+
* symbol-keyed properties and circular references. Functions are copied by
|
|
364
|
+
* reference. Class instances preserve their prototype.
|
|
365
|
+
*
|
|
366
|
+
* @template T - The value's type.
|
|
367
|
+
* @param value - The value to clone.
|
|
368
|
+
* @returns A deep clone of `value`.
|
|
369
|
+
*/
|
|
199
370
|
export function deepClone(value) {
|
|
200
371
|
return _deepClone(value);
|
|
201
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Internal implementation of deep clone.
|
|
375
|
+
* @param value - The value to clone.
|
|
376
|
+
* @param seen - Internal map used to handle circular references.
|
|
377
|
+
*/
|
|
202
378
|
function _deepClone(value, seen = new WeakMap()) {
|
|
203
379
|
if (value === null || typeof value !== "object")
|
|
204
380
|
return value;
|
|
@@ -234,6 +410,13 @@ function _deepClone(value, seen = new WeakMap()) {
|
|
|
234
410
|
}
|
|
235
411
|
return copy;
|
|
236
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Returns the type of the given value.
|
|
415
|
+
*
|
|
416
|
+
* @param {any} value - The value to determine the type of.
|
|
417
|
+
* @return {Type} - The type of the given value.
|
|
418
|
+
* @deprecated use Type.of(...)
|
|
419
|
+
*/
|
|
237
420
|
export function getType(value) {
|
|
238
421
|
return Type.of(value);
|
|
239
422
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/utilities.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAE/C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,IAAI,CAAmB,OAAgB;IACnD,IAAI,QAAQ,GAAa,IAAI,CAAC;IAE9B,MAAM,WAAW,GAAG,GAAM,EAAE;QACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,QAAQ,GAAG,OAAO,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,EAAO,EAAE;QACtB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ;YACjB,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACtD,CAAC;QACD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YACxB,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;QACD,GAAG,CAAC,CAAC,EAAE,IAAI;YACP,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,c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AE,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAS,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,IAAS,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,GAAQ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAClC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAElD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAE,KAAa,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,IAAS,CAAC;AACrB,CAAC;AAGD;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,KAAU;IAE9B,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["// noinspection JSUnusedGlobalSymbols\r\n\r\n\r\nimport KeyValuePair from \"./key-value-pair.js\";\r\nimport type {Resolvable} from \"./types.js\";\r\nimport Type from \"./type.js\";\r\n\r\nexport function lazy<T extends object>(factory: () => T): T {\r\n let instance: T | null = null;\r\n\r\n const getInstance = (): T => {\r\n if (!instance) {\r\n instance = factory();\r\n }\r\n return instance;\r\n };\r\n\r\n return new Proxy({} as T, {\r\n get(_, prop, receiver) {\r\n return Reflect.get(getInstance(), prop, receiver);\r\n },\r\n set(_, prop, value, receiver) {\r\n return Reflect.set(getInstance(), prop, value, receiver);\r\n },\r\n has(_, prop) {\r\n return Reflect.has(getInstance(), prop);\r\n },\r\n deleteProperty(_, prop) {\r\n return Reflect.deleteProperty(getInstance(), prop);\r\n },\r\n ownKeys() {\r\n return Reflect.ownKeys(getInstance());\r\n },\r\n getOwnPropertyDescriptor(_, prop) {\r\n return Reflect.getOwnPropertyDescriptor(getInstance(), prop);\r\n },\r\n getPrototypeOf() {\r\n return Reflect.getPrototypeOf(getInstance());\r\n },\r\n });\r\n}\r\n\r\n/**\r\n * Checks if an object is iterable.\r\n *\r\n * @param {any} obj - The object to check.\r\n * @return {boolean} - Returns true if the object is iterable, otherwise false.\r\n */\r\nexport function isIterable(obj: any): boolean {\r\n return obj[Symbol.iterator] === 'function';\r\n}\r\n\r\n/**\r\n * Checks if a given value is a string.\r\n *\r\n * @param {*} value - The value to check.\r\n * @return {boolean} - Returns true if the value is a string, otherwise returns false.\r\n */\r\nexport function isString(value: any): value is string {\r\n return typeof value === 'string';\r\n}\r\n\r\n/**\r\n * Checks if a value is a number.\r\n *\r\n * @param {any} value - The value to check.\r\n * @return {boolean} - Returns true if the value is a number, otherwise false.\r\n */\r\nexport function isNumber(value: any): value is number {\r\n return typeof value === 'number';\r\n}\r\n\r\n/**\r\n * Checks if a given value is a boolean.\r\n *\r\n * @param {any} value - The value to be checked.\r\n *\r\n * @return {boolean} - Returns true if the value is a boolean, otherwise false.\r\n */\r\nexport function isBoolean(value: any): value is boolean {\r\n return typeof value === 'boolean';\r\n}\r\n\r\n/**\r\n * Checks if a value is an object.\r\n * @param {any} value - The value to be checked.\r\n * @returns {boolean} - Returns true if the value is an object, otherwise returns false.\r\n */\r\nexport function isObject(value: any): value is object {\r\n return value != null && typeof value === 'object' && !Array.isArray(value);\r\n}\r\n\r\n/**\r\n * Determines if a value is an array.\r\n *\r\n * @param value - The value to be checked.\r\n *\r\n * @return Whether the value is an array.\r\n */\r\nexport function isArray(value: any): value is any[] {\r\n return Array.isArray(value);\r\n}\r\n\r\n/**\r\n * Checks if a value is a function.\r\n *\r\n * @param {any} value - The value to be checked.\r\n * @return {boolean} - Returns true if the value is a function, otherwise returns false.\r\n */\r\nexport function isFunction(value: any): value is Function {\r\n return typeof value === 'function';\r\n}\r\n\r\n\r\n/**\r\n * Structural deep equality check.\r\n *\r\n * Compares primitives by value, and objects/arrays/Maps/Sets/Dates/RegExps\r\n * by structure. Handles circular references.\r\n *\r\n * @param a - First value.\r\n * @param b - Second value.\r\n * @returns `true` if `a` and `b` are structurally equal.\r\n */\r\nexport function deepEqual(a: unknown, b: unknown): boolean {\r\n return _deepEqual(a, b);\r\n}\r\n\r\n/**\r\n * Internal implementation of deep equality check.\r\n * @param a - First value.\r\n * @param b - Second value.\r\n * @param seen - Internal map used to handle circular references.\r\n */\r\nfunction _deepEqual(\r\n a: unknown,\r\n b: unknown,\r\n seen: WeakMap<object, unknown> = new WeakMap()\r\n): boolean {\r\n if (a === b) return true;\r\n if (a === null || b === null) return false;\r\n if (typeof a !== typeof b) return false;\r\n if (typeof a !== \"object\") return false;\r\n\r\n const objA = a as object;\r\n if (seen.has(objA)) return seen.get(objA) === b;\r\n seen.set(objA, b);\r\n\r\n if (a instanceof Date) return b instanceof Date && a.getTime() === b.getTime();\r\n if (a instanceof RegExp) return b instanceof RegExp && a.toString() === b.toString();\r\n if (Array.isArray(a) !== Array.isArray(b)) return false;\r\n\r\n if (a instanceof Map) {\r\n if (!(b instanceof Map) || a.size !== b.size) return false;\r\n for (const [k, v] of a) {\r\n if (!b.has(k) || !_deepEqual(v, b.get(k), seen)) return false;\r\n }\r\n return true;\r\n }\r\n\r\n if (a instanceof Set) {\r\n if (!(b instanceof Set) || a.size !== b.size) return false;\r\n for (const v of a) if (!b.has(v)) return false;\r\n return true;\r\n }\r\n\r\n const keysA = Reflect.ownKeys(a as object);\r\n const keysB = Reflect.ownKeys(b as object);\r\n if (keysA.length !== keysB.length) return false;\r\n\r\n for (const key of keysA) {\r\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\r\n if (!_deepEqual((a as any)[key], (b as any)[key], seen)) return false;\r\n }\r\n\r\n return true;\r\n}\r\n\r\n\r\n/**\r\n * Submits an HTML form programmatically using the specified HTTP method (default is POST),\r\n * without using AJAX. Supports nested objects and arrays using bracket notation (e.g., `user[name]`, `tags[]`).\r\n *\r\n * @param url - The destination URL where the form will be submitted.\r\n * @param data - An object containing key-value pairs. Supports nested structures and arrays.\r\n * @param method - HTTP method to use: 'POST' or 'GET' (default: 'POST').\r\n * @param target - Optional parameter specifying the target for the form submission (e.g., '_blank', '_self', '_parent', '_top').\r\n */\r\n\r\n\r\n/**\r\n * Compares two objects or arrays to check if they have the same immediate fields and values,\r\n * or the same immediate elements if they are arrays (shallow equality check).\r\n *\r\n * @param {any} a - The first object or array.\r\n * @param {any} b - The second object or array.\r\n * @return {boolean} - Returns true if the objects/arrays are shallowly equal, otherwise false.\r\n */\r\nexport function shallowEqual(a: any, b: any): boolean {\r\n if (a === b) {\r\n return true;\r\n }\r\n\r\n if (a === null || b === null || typeof a !== typeof b) {\r\n return false;\r\n }\r\n\r\n if (Array.isArray(a) && Array.isArray(b)) {\r\n if (a.length !== b.length) {\r\n return false;\r\n }\r\n return a.every((value, index) => value === b[index]);\r\n }\r\n\r\n if (typeof a === \"object\" && typeof b === \"object\") {\r\n const keysA = Object.keys(a);\r\n const keysB = Object.keys(b);\r\n\r\n if (keysA.length !== keysB.length) {\r\n return false;\r\n }\r\n return keysA.every(key => b.hasOwnProperty(key) && a[key] === b[key]);\r\n }\r\n\r\n return false;\r\n}\r\n\r\n\r\n/**\r\n * Pauses the execution of an asynchronous function for a specified duration.\r\n *\r\n * @param {number} ms - The delay duration in milliseconds.\r\n * @return {Promise<void>} A promise that resolves after the specified delay.\r\n */\r\nexport async function delay(ms: number): Promise<void> {\r\n await new Promise(resolve => setTimeout(resolve, ms));\r\n}\r\n\r\n/**\r\n * Checks if a value is undefined.\r\n *\r\n * @param {any} value - The value to check.\r\n * @returns {boolean} - True if the value is undefined, false otherwise.\r\n */\r\nexport function isUndefined(value: any): value is undefined {\r\n return typeof value === 'undefined';\r\n}\r\n\r\n/**\r\n * Checks if a value is defined or not.\r\n *\r\n * @param {any} value - The value to be checked.\r\n *\r\n * @return {boolean} - True if the value is defined, false otherwise.\r\n */\r\nexport function isDefined(value: any): value is undefined {\r\n return typeof value !== 'undefined';\r\n}\r\n\r\n/**\r\n * Checks if a given value is null.\r\n *\r\n * @param {any} value - The value to check for null.\r\n * @return {boolean} - Returns true if the value is null, otherwise returns false.\r\n */\r\nexport function isNull(value: any): value is null {\r\n return value === null;\r\n}\r\n\r\n\r\n/**\r\n * Determines whether the given value is of type bigint.\r\n * @param {any} value - The value to be checked.\r\n * @return {boolean} - Returns true if the value is of type bigint, false otherwise.\r\n */\r\nexport function isBigInt(value: any): value is bigint {\r\n return typeof value === 'bigint';\r\n}\r\n\r\n/**\r\n * Checks if a given value is a symbol.\r\n *\r\n * @param {any} value - The value to be checked.\r\n * @return {boolean} - Returns true if the value is a symbol, false otherwise.\r\n */\r\nexport function isSymbol(value: any): value is symbol {\r\n return typeof value === 'symbol';\r\n}\r\n\r\n/**\r\n * Checks if a value is null or undefined.\r\n *\r\n * @param {any} value - The value to check.\r\n * @return {boolean} - Returns true if the value is null or undefined, false otherwise.\r\n * @deprecated\r\n */\r\nexport function isNullOrUndefined(value: any): boolean {\r\n return value === null || typeof value === 'undefined';\r\n}\r\n\r\n/**\r\n * Checks if a value is null or undefined.\r\n *\r\n * @param {any} value - The value to check.\r\n * @return {boolean} - Returns true if the value is null or undefined, false otherwise.\r\n\r\n */\r\nexport function isNullish(value: any): boolean {\r\n return value === null || typeof value === 'undefined';\r\n}\r\n\r\n/**\r\n * Checks if a given value is empty.\r\n *\r\n * @param {any} value - The value to check.\r\n * @return {boolean} - Returns true if the value is empty, otherwise returns false.\r\n */\r\nexport function isEmpty(value: any): boolean {\r\n return (Array.isArray(value) && value.length === 0) ||\r\n (typeof value === 'string' && value === '') ||\r\n value === null || typeof value === 'undefined';\r\n}\r\n\r\n/**\r\n * Check if a value is empty or contains only whitespace characters.\r\n *\r\n * @param {any} value - The value to check.\r\n * @return {boolean} Returns true if the value is empty or contains only whitespace characters, otherwise returns false.\r\n */\r\nexport function isEmptyOrWhitespace(value: any): boolean {\r\n return (Array.isArray(value) && value.length === 0) ||\r\n (typeof value === 'string' && value.trim() === '') ||\r\n value === null || typeof value === 'undefined';\r\n}\r\n\r\n\r\n/**\r\n * Converts an object into an array of key-value pairs.\r\n *\r\n * @param {Record<string, any>} obj - The object to convert.\r\n * @return {KeyValuePair<string, any>[]} - The array of key-value pairs.\r\n */\r\nexport function toPairs(obj: Record<string, any>): KeyValuePair<string, any>[] {\r\n\r\n let output = [];\r\n for (const key in obj) {\r\n output.push(new KeyValuePair(key, obj[key]));\r\n }\r\n return output;\r\n\r\n}\r\n\r\n/**\r\n * Creates an object composed of the picked object properties.\r\n *\r\n * @template T - The type of the source object.\r\n * @template K - The type of the keys to pick.\r\n * @param obj - The source object.\r\n * @param props - The property names to pick.\r\n * @returns A new object with the picked properties.\r\n */\r\nexport function pick<T extends object, K extends keyof T>(obj: T, props: K[]): Pick<T, K> {\r\n const result = {} as Pick<T, K>;\r\n if (obj === null || typeof obj !== 'object') {\r\n return result;\r\n }\r\n\r\n for (const key of props) {\r\n if (key in obj) {\r\n result[key] = obj[key];\r\n }\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Converts a given thing into a Promise.\r\n * @template T\r\n * @param {any} thing - The thing to be converted into a Promise.\r\n * @returns {Promise<T>} - A Promise representing the given thing.\r\n */\r\nexport function promisify<T>(thing: Resolvable<T>): Promise<T> {\r\n\r\n if (thing instanceof Promise)\r\n return thing;\r\n\r\n\r\n if (isFunction(thing)) {\r\n return new Promise<T>((resolve, reject) => {\r\n try {\r\n const result = thing();\r\n resolve(result);\r\n } catch (error) {\r\n reject(error);\r\n }\r\n });\r\n }\r\n\r\n return Promise.resolve(thing);\r\n}\r\n\r\n\r\n/**\r\n * Create a deep, independent copy of a value.\r\n *\r\n * Supports primitives, plain objects, arrays, `Date`, `RegExp`, `Map`, `Set`,\r\n * symbol-keyed properties and circular references. Functions are copied by\r\n * reference. Class instances preserve their prototype.\r\n *\r\n * @template T - The value's type.\r\n * @param value - The value to clone.\r\n * @returns A deep clone of `value`.\r\n */\r\nexport function deepClone<T>(value: T): T {\r\n return _deepClone(value);\r\n}\r\n\r\n/**\r\n * Internal implementation of deep clone.\r\n * @param value - The value to clone.\r\n * @param seen - Internal map used to handle circular references.\r\n */\r\nfunction _deepClone<T>(\r\n value: T,\r\n seen: WeakMap<object, unknown> = new WeakMap()\r\n): T {\r\n if (value === null || typeof value !== \"object\") return value;\r\n\r\n const obj = value as unknown as object;\r\n if (seen.has(obj)) return seen.get(obj) as T;\r\n\r\n if (value instanceof Date) return new Date(value) as T;\r\n if (value instanceof RegExp) return new RegExp(value) as T;\r\n\r\n if (value instanceof Map) {\r\n const copy = new Map();\r\n seen.set(value, copy);\r\n for (const [k, v] of value) {\r\n copy.set(_deepClone(k, seen), _deepClone(v, seen));\r\n }\r\n return copy as T;\r\n }\r\n\r\n if (value instanceof Set) {\r\n const copy = new Set();\r\n seen.set(value, copy);\r\n for (const v of value) {\r\n copy.add(_deepClone(v, seen));\r\n }\r\n return copy as T;\r\n }\r\n\r\n const copy: any = Array.isArray(value)\r\n ? []\r\n : Object.create(Object.getPrototypeOf(value));\r\n\r\n seen.set(obj, copy);\r\n\r\n for (const key of Reflect.ownKeys(obj)) {\r\n copy[key] = _deepClone((value as any)[key], seen);\r\n }\r\n\r\n return copy as T;\r\n}\r\n\r\n\r\n/**\r\n * Returns the type of the given value.\r\n *\r\n * @param {any} value - The value to determine the type of.\r\n * @return {Type} - The type of the given value.\r\n * @deprecated use Type.of(...)\r\n */\r\nexport function getType(value: any): Type {\r\n\r\n return Type.of(value);\r\n}\r\n\r\n\r\n\r\n"]}
|
package/package.json
CHANGED
package/src/array.ts
CHANGED
|
@@ -66,4 +66,20 @@ export function remove<T>(array: Array<T>,predicate: Predicate<T>): Array<T> {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return removed;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Adds an element to the array if it's not already present.
|
|
73
|
+
* The operation mutates the original array.
|
|
74
|
+
* @template T
|
|
75
|
+
* @param {Array<T>} array - The array to modify.
|
|
76
|
+
* @param {T} element - The element to add if absent.
|
|
77
|
+
* @return {boolean} True if the element was added, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
export function pushIfAbsent<T>(array: Array<T>, element: T): boolean {
|
|
80
|
+
if (!array.includes(element)) {
|
|
81
|
+
array.push(element);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
69
85
|
}
|
package/src/browser/index.ts
CHANGED
|
@@ -109,8 +109,8 @@ export async function fetchInto(
|
|
|
109
109
|
return replacedCount;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export * from './form-utilities.js'
|
|
112
|
+
export * from './form-utilities.js';
|
|
113
113
|
|
|
114
|
-
export {default as NativeBridge} from "./native-bridge.js"
|
|
114
|
+
export {default as NativeBridge} from "./native-bridge.js";
|
|
115
115
|
|
|
116
116
|
export {default as getGeoLocation} from './geo-location.js';
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A dictionary-like structure with caching and expiration capabilities.
|
|
3
|
+
* @template T - The type of the values stored in the cache.
|
|
4
|
+
*/
|
|
1
5
|
export default class CacheDictionary<T> {
|
|
2
6
|
private readonly fallback: ((key: string) => T) | null;
|
|
3
7
|
private readonly cache: { [key: string]: T };
|
|
4
8
|
private readonly defaultDuration: number | null;
|
|
5
9
|
private readonly expiration: { [key: string]: Date | undefined };
|
|
6
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @param {((key: string) => T) | null} fallback - Optional function to call when a key is not found.
|
|
13
|
+
* @param {number | null} defaultDuration - Default duration in seconds for cache items.
|
|
14
|
+
*/
|
|
7
15
|
constructor(fallback: ((key: string) => T) | null = null, defaultDuration: number | null = null) {
|
|
8
16
|
this.fallback = fallback;
|
|
9
17
|
this.cache = {};
|
|
@@ -11,15 +19,29 @@ export default class CacheDictionary<T> {
|
|
|
11
19
|
this.expiration = {};
|
|
12
20
|
}
|
|
13
21
|
|
|
14
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Gets the expiration date for a specific key.
|
|
24
|
+
* @param {string} key - The key.
|
|
25
|
+
* @returns {Date | undefined} The expiration date or undefined.
|
|
26
|
+
*/
|
|
15
27
|
public getExpiration(key: string): Date | undefined {
|
|
16
28
|
return this.expiration[key];
|
|
17
29
|
}
|
|
18
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Sets a specific expiration date for a key.
|
|
33
|
+
* @param {string} key - The key.
|
|
34
|
+
* @param {Date | undefined} expiration - The expiration date.
|
|
35
|
+
*/
|
|
19
36
|
public setExpiration(key: string, expiration: Date | undefined): void {
|
|
20
37
|
this.expiration[key] = expiration;
|
|
21
38
|
}
|
|
22
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Sets a duration in seconds for a key's expiration.
|
|
42
|
+
* @param {string} key - The key.
|
|
43
|
+
* @param {number | null} duration - Duration in seconds. If null, expiration is removed.
|
|
44
|
+
*/
|
|
23
45
|
public setDuration(key: string, duration: number | null): void {
|
|
24
46
|
if (duration === null) {
|
|
25
47
|
delete this.expiration[key];
|
|
@@ -30,6 +52,12 @@ export default class CacheDictionary<T> {
|
|
|
30
52
|
}
|
|
31
53
|
}
|
|
32
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Gets a value from the cache. If not found and a fallback exists, it uses the fallback.
|
|
57
|
+
* If the item is expired, it's removed and null is returned.
|
|
58
|
+
* @param {string} key - The key to retrieve.
|
|
59
|
+
* @returns {T | null} The value or null if not found/expired.
|
|
60
|
+
*/
|
|
33
61
|
public get(key: string): T | null {
|
|
34
62
|
if (!this.cache.hasOwnProperty(key)) {
|
|
35
63
|
if (this.fallback) {
|
|
@@ -48,11 +76,21 @@ export default class CacheDictionary<T> {
|
|
|
48
76
|
return this.cache[key];
|
|
49
77
|
}
|
|
50
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Sets a value in the cache with an optional duration.
|
|
81
|
+
* @param {string} key - The key.
|
|
82
|
+
* @param {T} value - The value to store.
|
|
83
|
+
* @param {number | null} duration - Duration in seconds.
|
|
84
|
+
*/
|
|
51
85
|
public set(key: string, value: T, duration: number | null = null): void {
|
|
52
86
|
this.cache[key] = value;
|
|
53
87
|
this.expiration[key] = this.calculateExpiration(duration);
|
|
54
88
|
}
|
|
55
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Removes an item from the cache.
|
|
92
|
+
* @param {string} key - The key to remove.
|
|
93
|
+
*/
|
|
56
94
|
public remove(key: string): void {
|
|
57
95
|
delete this.cache[key];
|
|
58
96
|
delete this.expiration[key];
|
|
@@ -2,31 +2,37 @@ import type {Optional, UnaryFunction} from "../types.js";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* DefaultMap<K, V>
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* A Map that automatically creates and saves a default value
|
|
6
|
+
* when accessing a non-existent key with get(key).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* @template K - The type of the keys.
|
|
9
|
+
* @template V - The type of the values.
|
|
10
|
+
* @example
|
|
9
11
|
* const m = new DefaultMap<string, number>(() => 0);
|
|
10
|
-
* m.get("a")
|
|
12
|
+
* m.get("a"); // 0
|
|
13
|
+
* m.set("a", m.get("a") + 1); // 1
|
|
11
14
|
*/
|
|
12
15
|
export default class DefaultMap<K, V> extends Map<K, V> {
|
|
13
16
|
private readonly _factoryMethod: (key: K) => V;
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
|
-
* @param factoryMethod
|
|
17
|
-
* @param entries
|
|
19
|
+
* @param {UnaryFunction<K, V>} factoryMethod - Function that produces the default value for a key.
|
|
20
|
+
* @param {Optional<Iterable<[K, V]>>} entries - Initial entries.
|
|
18
21
|
*/
|
|
19
22
|
constructor(factoryMethod: UnaryFunction<K, V>, entries: Optional<Iterable<[K, V]>> = undefined) {
|
|
20
23
|
super(entries);
|
|
21
24
|
if (typeof factoryMethod !== "function") {
|
|
22
|
-
throw new TypeError("DefaultMap
|
|
25
|
+
throw new TypeError("DefaultMap needs a factory (key => defaultValue).");
|
|
23
26
|
}
|
|
24
27
|
this._factoryMethod = factoryMethod;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
31
|
+
* Gets the value for the key. If it does not exist, it creates it using the factory,
|
|
32
|
+
* saves it, and returns it.
|
|
33
|
+
*
|
|
34
|
+
* @param {K} key - The key to get.
|
|
35
|
+
* @returns {V} The value associated with the key.
|
|
30
36
|
*/
|
|
31
37
|
override get(key: K): V {
|
|
32
38
|
if (!super.has(key)) {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type {Optional, UnaryFunction} from "../types.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* DefaultWeakMap<K, V>
|
|
5
|
+
* A WeakMap that automatically creates and saves a default value
|
|
6
|
+
* when accessing a non-existent key with get(key).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* m.get("a") += 1; // ahora m.get("a") === 1
|
|
8
|
+
* @template K - The type of the keys. Must be an object.
|
|
9
|
+
* @template V - The type of the values.
|
|
11
10
|
*/
|
|
12
|
-
export default class
|
|
11
|
+
export default class DefaultWeakMap<K extends object, V> extends WeakMap<K, V> {
|
|
13
12
|
private readonly _factoryMethod: (key: K) => V;
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* @param factoryMethod
|
|
17
|
-
* @param entries
|
|
15
|
+
* @param {UnaryFunction<K, V>} factoryMethod - Function that produces the default value for a key.
|
|
16
|
+
* @param {Optional<Iterable<[K, V]>>} entries - Initial entries.
|
|
18
17
|
*/
|
|
19
18
|
constructor(factoryMethod: UnaryFunction<K, V>, entries: Optional<Iterable<[K, V]>> = undefined) {
|
|
20
19
|
super();
|
|
@@ -26,14 +25,17 @@ export default class DefaultMap<K extends object, V> extends WeakMap<K, V> {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
if (typeof factoryMethod !== "function") {
|
|
29
|
-
throw new TypeError("
|
|
28
|
+
throw new TypeError("DefaultWeakMap needs a factory (key => defaultValue).");
|
|
30
29
|
}
|
|
31
30
|
this._factoryMethod = factoryMethod;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Gets the value for the key. If it does not exist, it creates it using the factory,
|
|
35
|
+
* saves it, and returns it.
|
|
36
|
+
*
|
|
37
|
+
* @param {K} key - The key to get.
|
|
38
|
+
* @returns {V} The value associated with the key.
|
|
37
39
|
*/
|
|
38
40
|
override get(key: K): V {
|
|
39
41
|
if (!super.has(key)) {
|