@superutils/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/dist/index.d.ts +1320 -0
- package/dist/index.js +931 -0
- package/package.json +39 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,931 @@
|
|
|
1
|
+
// src/forceCast.ts
|
|
2
|
+
var asAny = (x) => x;
|
|
3
|
+
var forceCast = (x) => x;
|
|
4
|
+
var forceCast_default = forceCast;
|
|
5
|
+
|
|
6
|
+
// src/curry.ts
|
|
7
|
+
function curry(func, ...[arity = func.length]) {
|
|
8
|
+
const curriedFn = (...args) => {
|
|
9
|
+
const _args = args;
|
|
10
|
+
if (_args.length >= arity) return func(...forceCast_default(args));
|
|
11
|
+
return (...nextArgs) => asAny(curriedFn)(
|
|
12
|
+
..._args,
|
|
13
|
+
...nextArgs
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
return curriedFn;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/is/isObj.ts
|
|
20
|
+
var isObj = (x, strict = true) => !!x && typeof x === "object" && (!strict || [
|
|
21
|
+
Object.prototype,
|
|
22
|
+
null
|
|
23
|
+
// when an object is created using `Object.create(null)`
|
|
24
|
+
].includes(Object.getPrototypeOf(x)));
|
|
25
|
+
var isObj_default = isObj;
|
|
26
|
+
|
|
27
|
+
// src/is/isArr.ts
|
|
28
|
+
var isArr = (x) => Array.isArray(x);
|
|
29
|
+
var isArrObj = (x, strict = true) => isArr(x) && x.every((x2) => isObj(x2, strict));
|
|
30
|
+
var isArr2D = (x) => isArr(x) && x.every(isArr);
|
|
31
|
+
var isArrLike = (x) => isArr(x) || x instanceof Set || x instanceof Map;
|
|
32
|
+
var isArrLikeSafe = (x) => ["[object Array]", "[object Map]", "[object Set]"].includes(
|
|
33
|
+
Object.prototype.toString.call(x)
|
|
34
|
+
);
|
|
35
|
+
var isArrUnique = (arr) => isArr(arr) && new Set(arr).size === arr.length;
|
|
36
|
+
var isUint8Arr = (arr) => arr instanceof Uint8Array;
|
|
37
|
+
var isArr_default = isArr;
|
|
38
|
+
|
|
39
|
+
// src/is/isDate.ts
|
|
40
|
+
var isDate = (x) => x instanceof Date;
|
|
41
|
+
var isDateValid = (date) => {
|
|
42
|
+
const dateIsStr = typeof date === "string";
|
|
43
|
+
if (!dateIsStr && !isDate(date)) return false;
|
|
44
|
+
const dateObj = new Date(date);
|
|
45
|
+
if (Number.isNaN(dateObj.getTime())) return false;
|
|
46
|
+
if (!dateIsStr) return true;
|
|
47
|
+
const [original, converted] = [date, dateObj.toISOString()].map(
|
|
48
|
+
(y) => y.replace(/[TZ]/g, "").substring(0, 10)
|
|
49
|
+
);
|
|
50
|
+
return original === converted;
|
|
51
|
+
};
|
|
52
|
+
var isDate_default = isDate;
|
|
53
|
+
|
|
54
|
+
// src/is/isNumber.ts
|
|
55
|
+
var isInteger = (x) => Number.isInteger(x);
|
|
56
|
+
var isPositiveInteger = (x) => isInteger(x) && x > 0;
|
|
57
|
+
var isPositiveNumber = (x) => isNumber(x) && x > 0;
|
|
58
|
+
var isNumber = (x) => typeof x == "number" && !Number.isNaN(x) && Number.isFinite(x);
|
|
59
|
+
|
|
60
|
+
// src/is/isEmpty.ts
|
|
61
|
+
var isEmpty = (x, nonNumerable = false, fallback = false) => {
|
|
62
|
+
if (x === null || x === void 0) return true;
|
|
63
|
+
switch (typeof x) {
|
|
64
|
+
case "number":
|
|
65
|
+
return !isNumber(x);
|
|
66
|
+
case "string":
|
|
67
|
+
return !x.replaceAll(" ", "").trim().length;
|
|
68
|
+
case "boolean":
|
|
69
|
+
case "bigint":
|
|
70
|
+
case "symbol":
|
|
71
|
+
case "function":
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (x instanceof Date) return Number.isNaN(x.getTime());
|
|
75
|
+
if (x instanceof Map || x instanceof Set) return !x.size;
|
|
76
|
+
if (Array.isArray(x) || x instanceof Uint8Array) return !x.length;
|
|
77
|
+
if (x instanceof Error) return !x.message.length;
|
|
78
|
+
const proto = typeof x === "object" && Object.getPrototypeOf(x);
|
|
79
|
+
if (proto === Object.prototype || proto === null) {
|
|
80
|
+
return nonNumerable ? !Object.getOwnPropertyNames(x).length : !Object.keys(x).length;
|
|
81
|
+
}
|
|
82
|
+
return fallback;
|
|
83
|
+
};
|
|
84
|
+
var isEmptySafe = (x, numberableOnly = false) => {
|
|
85
|
+
const empty = isEmpty(x, numberableOnly, 0);
|
|
86
|
+
if (empty !== 0) return empty;
|
|
87
|
+
switch (Object.prototype.toString.call(x)) {
|
|
88
|
+
case "[object Uint8Array]":
|
|
89
|
+
return !x.length;
|
|
90
|
+
case "[object Date]":
|
|
91
|
+
return Number.isNaN(x.getTime());
|
|
92
|
+
case "[object Map]":
|
|
93
|
+
return !x.size;
|
|
94
|
+
case "[object Object]":
|
|
95
|
+
return !Object.keys(x).length;
|
|
96
|
+
case "[object Set]":
|
|
97
|
+
return !x.size;
|
|
98
|
+
default:
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var isEmpty_default = isEmpty;
|
|
103
|
+
|
|
104
|
+
// src/is/isEnv.ts
|
|
105
|
+
var isEnvBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
106
|
+
var isEnvNode = () => {
|
|
107
|
+
var _a;
|
|
108
|
+
return typeof process !== "undefined" && ((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node) != null;
|
|
109
|
+
};
|
|
110
|
+
var isEnvTouchable = () => {
|
|
111
|
+
try {
|
|
112
|
+
return "ontouchstart" in window.document.documentElement;
|
|
113
|
+
} catch (_) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/noop.ts
|
|
119
|
+
function noop() {
|
|
120
|
+
}
|
|
121
|
+
async function noopAsync() {
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/is/isFn.ts
|
|
125
|
+
var isFn = (x) => typeof x === "function";
|
|
126
|
+
var isAsyncFn = (x) => x instanceof noopAsync.constructor && x[Symbol.toStringTag] === "AsyncFunction";
|
|
127
|
+
var isFn_default = isFn;
|
|
128
|
+
|
|
129
|
+
// src/is/isMap.ts
|
|
130
|
+
var isMap = (x) => x instanceof Map;
|
|
131
|
+
var isMapObj = (x, strict = true) => isMap(x) && [...x.values()].every((value) => isObj_default(value, strict));
|
|
132
|
+
|
|
133
|
+
// src/is/isUrl.ts
|
|
134
|
+
var isUrl = (x) => x instanceof URL;
|
|
135
|
+
var isUrlValid = (x, strict = true, tldExceptions = ["localhost"]) => {
|
|
136
|
+
if (!x) return false;
|
|
137
|
+
try {
|
|
138
|
+
if (typeof x !== "string" && !isUrl(x)) return false;
|
|
139
|
+
const url = isUrl(x) ? x : new URL(x);
|
|
140
|
+
if (!strict) return true;
|
|
141
|
+
const gotTld = tldExceptions.includes(url.hostname) || url.host.split(".").length > 1;
|
|
142
|
+
if (!gotTld) return false;
|
|
143
|
+
let y = `${x}`;
|
|
144
|
+
if (y.endsWith(url.hostname)) y += "/";
|
|
145
|
+
return url.href === y;
|
|
146
|
+
} catch (_) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var isUrl_default = isUrl;
|
|
151
|
+
|
|
152
|
+
// src/is/index.ts
|
|
153
|
+
var isBool = (x) => typeof x === "boolean" || x instanceof Boolean;
|
|
154
|
+
var isDefined = (x) => x !== void 0 && x !== null;
|
|
155
|
+
var isError = (x) => x instanceof Error;
|
|
156
|
+
var isPromise = (x) => x instanceof Promise;
|
|
157
|
+
var isRegExp = (x) => x instanceof RegExp;
|
|
158
|
+
var isSet = (x) => x instanceof Set;
|
|
159
|
+
var isStr = (x) => typeof x === "string";
|
|
160
|
+
var isSymbol = (x) => typeof x === "symbol";
|
|
161
|
+
var is = {
|
|
162
|
+
arr: isArr_default,
|
|
163
|
+
arr2D: isArr2D,
|
|
164
|
+
arrLike: isArrLike,
|
|
165
|
+
arrLikeSafe: isArrLikeSafe,
|
|
166
|
+
arrObj: isArrObj,
|
|
167
|
+
arrUnique: isArrUnique,
|
|
168
|
+
asyncFn: isAsyncFn,
|
|
169
|
+
bool: isBool,
|
|
170
|
+
date: isDate_default,
|
|
171
|
+
dateValid: isDateValid,
|
|
172
|
+
defined: isDefined,
|
|
173
|
+
empty: isEmpty_default,
|
|
174
|
+
emptySafe: isEmptySafe,
|
|
175
|
+
envBrowser: isEnvBrowser,
|
|
176
|
+
envNode: isEnvNode,
|
|
177
|
+
envTouchable: isEnvTouchable,
|
|
178
|
+
error: isError,
|
|
179
|
+
fn: isFn_default,
|
|
180
|
+
integer: isInteger,
|
|
181
|
+
map: isMap,
|
|
182
|
+
mapObj: isMapObj,
|
|
183
|
+
number: isNumber,
|
|
184
|
+
obj: isObj_default,
|
|
185
|
+
positiveInteger: isPositiveInteger,
|
|
186
|
+
positiveNumber: isPositiveNumber,
|
|
187
|
+
promise: isPromise,
|
|
188
|
+
regExp: isRegExp,
|
|
189
|
+
set: isSet,
|
|
190
|
+
str: isStr,
|
|
191
|
+
// subjectLike: isSubjectLike,
|
|
192
|
+
symbol: isSymbol,
|
|
193
|
+
uint8Arr: isUint8Arr,
|
|
194
|
+
url: isUrl_default,
|
|
195
|
+
urlValid: isUrlValid
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/fallbackIfFails.ts
|
|
199
|
+
var fallbackIfFails = (target, args, fallbackValue) => {
|
|
200
|
+
let result;
|
|
201
|
+
try {
|
|
202
|
+
result = !isFn(target) ? target : target(...isFn(args) ? args() : args);
|
|
203
|
+
if (!isPromise(result)) return result;
|
|
204
|
+
result = result.catch(getAltValCb(fallbackValue));
|
|
205
|
+
} catch (error) {
|
|
206
|
+
result = getAltValCb(fallbackValue)(error);
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
};
|
|
210
|
+
var fallbackIfFails_default = fallbackIfFails;
|
|
211
|
+
var getAltValCb = (fallbackValue) => (error) => isFn(fallbackValue) ? fallbackValue(error) : fallbackValue;
|
|
212
|
+
|
|
213
|
+
// src/deferred.ts
|
|
214
|
+
var deferred = (callback, delay = 50, config = {}) => {
|
|
215
|
+
const {
|
|
216
|
+
leading = deferred.defaults.leading,
|
|
217
|
+
onError = deferred.defaults.onError,
|
|
218
|
+
thisArg
|
|
219
|
+
} = config;
|
|
220
|
+
let { tid } = config;
|
|
221
|
+
if (thisArg !== void 0) callback = callback.bind(thisArg);
|
|
222
|
+
const _callback = (...args) => fallbackIfFails_default(callback, args, onError);
|
|
223
|
+
let firstArgs = null;
|
|
224
|
+
const leadingGlobal = leading === "global";
|
|
225
|
+
return (...args) => {
|
|
226
|
+
clearTimeout(tid);
|
|
227
|
+
tid = setTimeout(() => {
|
|
228
|
+
firstArgs !== args && _callback(...args);
|
|
229
|
+
firstArgs = leadingGlobal ? true : null;
|
|
230
|
+
}, delay);
|
|
231
|
+
if (!leading || firstArgs) return;
|
|
232
|
+
firstArgs = args;
|
|
233
|
+
_callback(...args);
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
deferred.defaults = {
|
|
237
|
+
/**
|
|
238
|
+
* Set the default value of argument `leading` for the `deferred` function.
|
|
239
|
+
* This change is applicable application-wide and only applies to any new invocation of `deferred()`.
|
|
240
|
+
*/
|
|
241
|
+
leading: false,
|
|
242
|
+
/**
|
|
243
|
+
* Set the default value of argument `onError` for the `deferred` function.
|
|
244
|
+
* This change is applicable application-wide and only applies to any new invocation of `deferred()`.
|
|
245
|
+
*/
|
|
246
|
+
onError: void 0
|
|
247
|
+
};
|
|
248
|
+
var deferred_default = deferred;
|
|
249
|
+
|
|
250
|
+
// src/debounce.ts
|
|
251
|
+
function debounce(...args) {
|
|
252
|
+
return deferred_default(...args);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/throttled.ts
|
|
256
|
+
var throttled = (callback, delay = 50, config = {}) => {
|
|
257
|
+
const { defaults: d } = throttled;
|
|
258
|
+
const { onError = d.onError, trailing = d.trailing, thisArg } = config;
|
|
259
|
+
let { tid } = config;
|
|
260
|
+
if (thisArg !== void 0) callback = callback.bind(thisArg);
|
|
261
|
+
const _callback = (...args) => fallbackIfFails_default(callback, args, onError);
|
|
262
|
+
let trailArgs = null;
|
|
263
|
+
return (...args) => {
|
|
264
|
+
if (tid) {
|
|
265
|
+
trailArgs = args;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
tid = setTimeout(() => {
|
|
269
|
+
tid = void 0;
|
|
270
|
+
if (!trailing) return;
|
|
271
|
+
const cbArgs = trailArgs;
|
|
272
|
+
trailArgs = null;
|
|
273
|
+
cbArgs && cbArgs !== args && _callback(...cbArgs);
|
|
274
|
+
}, delay);
|
|
275
|
+
_callback(...args);
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
throttled.defaults = {
|
|
279
|
+
onError: void 0,
|
|
280
|
+
trailing: true
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/toDatetimeLocal.ts
|
|
284
|
+
var toDatetimeLocal = (dateStr) => {
|
|
285
|
+
const date = new Date(dateStr);
|
|
286
|
+
if (!isDateValid(date)) return "";
|
|
287
|
+
const year = date.getFullYear();
|
|
288
|
+
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
289
|
+
const day = date.getDate().toString().padStart(2, "0");
|
|
290
|
+
const hours = date.getHours().toString().padStart(2, "0");
|
|
291
|
+
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
292
|
+
const res = `${year}-${month}-${day}T${hours}:${minutes}`;
|
|
293
|
+
return res;
|
|
294
|
+
};
|
|
295
|
+
(/* @__PURE__ */ new Date()).getTime();
|
|
296
|
+
|
|
297
|
+
// src/obj/objClean.ts
|
|
298
|
+
var objClean = (obj, keys, ignoreIfNotExist = true) => {
|
|
299
|
+
const result = {};
|
|
300
|
+
if (!isObj(obj) || !isArr(keys)) return result;
|
|
301
|
+
const uniqKeys = arrUnique(
|
|
302
|
+
keys.map((x) => isStr(x) ? `${x}`.split(".")[0] : x)
|
|
303
|
+
).sort();
|
|
304
|
+
for (const key of uniqKeys) {
|
|
305
|
+
if (ignoreIfNotExist && !obj.hasOwnProperty(key)) continue;
|
|
306
|
+
const value = obj[key];
|
|
307
|
+
if (!isObj(value) || isSymbol(key)) {
|
|
308
|
+
result[key] = value;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const childPrefix = `${key}.`;
|
|
312
|
+
const childKeys = keys.filter((k) => {
|
|
313
|
+
var _a;
|
|
314
|
+
return (_a = k == null ? void 0 : k.startsWith) == null ? void 0 : _a.call(k, childPrefix);
|
|
315
|
+
}).map((k) => k.split(childPrefix)[1]);
|
|
316
|
+
if (!childKeys.length) {
|
|
317
|
+
result[key] = value;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
result[key] = objClean(
|
|
321
|
+
value,
|
|
322
|
+
childKeys
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
return result;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// src/obj/objKeys.ts
|
|
329
|
+
var objKeys = (obj, sorted = true, includeSymbols = true) => fallbackIfFails_default(
|
|
330
|
+
() => [
|
|
331
|
+
...includeSymbols && Object.getOwnPropertySymbols(obj) || [],
|
|
332
|
+
...sorted ? Object.keys(obj).sort() : Object.keys(obj)
|
|
333
|
+
],
|
|
334
|
+
[],
|
|
335
|
+
[]
|
|
336
|
+
);
|
|
337
|
+
var objKeys_default = objKeys;
|
|
338
|
+
|
|
339
|
+
// src/obj/objCopy.ts
|
|
340
|
+
var clone = (value, fallback = "null") => JSON.parse(fallbackIfFails_default(JSON.stringify, [value], fallback));
|
|
341
|
+
var objCopy = (input, output, ignoreKeys, override = false, recursive = true) => {
|
|
342
|
+
if (!isObj(output)) output = {};
|
|
343
|
+
if (!isObj(input)) return output;
|
|
344
|
+
const _ignoreKeys = new Set(ignoreKeys != null ? ignoreKeys : []);
|
|
345
|
+
const inKeys = objKeys_default(input, true, true).filter(
|
|
346
|
+
(x) => !_ignoreKeys.has(x)
|
|
347
|
+
);
|
|
348
|
+
for (const _key of inKeys) {
|
|
349
|
+
const key = _key;
|
|
350
|
+
const value = input[key];
|
|
351
|
+
const skip = output.hasOwnProperty(key) && (!override || override === "empty" && !isEmpty(output[key]));
|
|
352
|
+
if (skip) continue;
|
|
353
|
+
const isPrimitive = [void 0, null, Infinity, NaN].includes(asAny(value)) || !isObj(value, false);
|
|
354
|
+
if (isPrimitive) {
|
|
355
|
+
output[key] = value;
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
output[key] = (() => {
|
|
359
|
+
switch (Object.getPrototypeOf(value)) {
|
|
360
|
+
case Array.prototype:
|
|
361
|
+
return clone(value, "[]");
|
|
362
|
+
case ArrayBuffer.prototype:
|
|
363
|
+
return asAny(value).slice(0);
|
|
364
|
+
case Date.prototype:
|
|
365
|
+
return new Date(asAny(value).getTime());
|
|
366
|
+
case Map.prototype:
|
|
367
|
+
return new Map(
|
|
368
|
+
clone(
|
|
369
|
+
Array.from(asAny(value)),
|
|
370
|
+
"[]"
|
|
371
|
+
)
|
|
372
|
+
);
|
|
373
|
+
case RegExp.prototype:
|
|
374
|
+
return new RegExp(asAny(value));
|
|
375
|
+
case Set.prototype:
|
|
376
|
+
return new Set(
|
|
377
|
+
clone(Array.from(asAny(value)))
|
|
378
|
+
);
|
|
379
|
+
case Uint8Array.prototype:
|
|
380
|
+
return new Uint8Array([...asAny(value)]);
|
|
381
|
+
case URL.prototype:
|
|
382
|
+
return new URL(asAny(value));
|
|
383
|
+
default:
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
if (isSymbol(key) || !recursive) return clone(value);
|
|
387
|
+
const ignoreChildKeys = [..._ignoreKeys].map(
|
|
388
|
+
(x) => !isSymbol(x) && x.startsWith(key.concat(".")) && x.split(key.concat("."))[1]
|
|
389
|
+
).filter(Boolean);
|
|
390
|
+
if (!ignoreChildKeys.length) return clone(value);
|
|
391
|
+
return objCopy(
|
|
392
|
+
value,
|
|
393
|
+
output[key],
|
|
394
|
+
ignoreChildKeys,
|
|
395
|
+
override,
|
|
396
|
+
recursive
|
|
397
|
+
);
|
|
398
|
+
})();
|
|
399
|
+
}
|
|
400
|
+
return output;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// src/obj/objCreate.ts
|
|
404
|
+
var objCreate = (keys = [], values = [], result) => {
|
|
405
|
+
if (!isObj(result)) result = {};
|
|
406
|
+
for (let i = 0; i < (isArr(keys) ? keys : []).length; i++) {
|
|
407
|
+
;
|
|
408
|
+
result[keys[i]] = values == null ? void 0 : values[i];
|
|
409
|
+
}
|
|
410
|
+
return result;
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
// src/obj/objReadOnly.ts
|
|
414
|
+
var objReadOnly = (obj, config) => {
|
|
415
|
+
if (!isObj(obj, false)) obj = {};
|
|
416
|
+
const { add, revocable, silent = true } = config != null ? config : {};
|
|
417
|
+
const [typeTitle, keyTitle] = isArr(obj) ? ["array", "index"] : ["object", "property name"];
|
|
418
|
+
function handleSetProp(obj2, key, value) {
|
|
419
|
+
const isUpdate = obj2[key] !== void 0;
|
|
420
|
+
if (isUpdate && silent) return true;
|
|
421
|
+
const allowAddition = !isUpdate && (!isFn(add) ? add : add(obj2, key, value));
|
|
422
|
+
const shouldThrow = !silent && (isUpdate || !allowAddition);
|
|
423
|
+
if (shouldThrow)
|
|
424
|
+
throw new TypeError(
|
|
425
|
+
`Mutation not allow on read-only ${typeTitle} ${keyTitle}: ${key.toString()}`
|
|
426
|
+
);
|
|
427
|
+
if (!allowAddition) return true;
|
|
428
|
+
obj2[key] = value;
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
const proxyHandler = {
|
|
432
|
+
get: (obj2, key) => obj2[key],
|
|
433
|
+
set: handleSetProp,
|
|
434
|
+
defineProperty: (obj2, key, { value }) => handleSetProp(obj2, key, value),
|
|
435
|
+
// Prevent removal of properties
|
|
436
|
+
deleteProperty: (obj2, key) => {
|
|
437
|
+
if (!silent && obj2.hasOwnProperty(key)) {
|
|
438
|
+
throw new Error(
|
|
439
|
+
`Mutation not allow on read-only ${typeTitle} ${keyTitle}: ${key.toString()}`
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
return revocable ? Proxy.revocable(obj, proxyHandler) : new Proxy(obj, proxyHandler);
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/obj/objSetProp.ts
|
|
449
|
+
var objSetProp = (obj, key, falsyValue, condition, truthyValue) => {
|
|
450
|
+
var _a;
|
|
451
|
+
const result = !isObj(obj, false) ? {} : obj;
|
|
452
|
+
falsyValue != null ? falsyValue : falsyValue = result[key];
|
|
453
|
+
condition = isFn(condition) ? condition((_a = result[key]) != null ? _a : falsyValue, key, obj) : condition;
|
|
454
|
+
result[key] = !condition ? falsyValue : truthyValue;
|
|
455
|
+
return result;
|
|
456
|
+
};
|
|
457
|
+
var objSetPropUndefined = (...[obj, key, ...args]) => (obj == null ? void 0 : obj[key]) === void 0 && objSetProp(obj, key, ...args) || obj;
|
|
458
|
+
|
|
459
|
+
// src/obj/objSort.ts
|
|
460
|
+
var objSort = (obj, recursive = true, _done = /* @__PURE__ */ new Map()) => {
|
|
461
|
+
const sorted = {};
|
|
462
|
+
if (!isObj(obj)) return sorted;
|
|
463
|
+
for (const key of objKeys_default(obj)) {
|
|
464
|
+
const value = obj[key];
|
|
465
|
+
_done.set(value, true);
|
|
466
|
+
sorted[key] = !recursive || !isObj(value) ? value : objSort(
|
|
467
|
+
value,
|
|
468
|
+
recursive,
|
|
469
|
+
_done
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
return sorted;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
// src/obj/objWithoutKeys.ts
|
|
476
|
+
var objWithoutKeys = (input, keys, output) => {
|
|
477
|
+
if (!isObj(input, false)) return {};
|
|
478
|
+
if (!isArr(keys) || !keys.length) return input;
|
|
479
|
+
output = {
|
|
480
|
+
...isObj(output, false) && output,
|
|
481
|
+
...input
|
|
482
|
+
};
|
|
483
|
+
for (const key of keys) delete output[key];
|
|
484
|
+
return output;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/arr/arrReadOnly.ts
|
|
488
|
+
var arrReadOnly = (arr, config = {}) => objReadOnly(new ReadOnlyArrayHelper(config, arr), config);
|
|
489
|
+
var ReadOnlyArrayHelper = class extends Array {
|
|
490
|
+
constructor(config, arr) {
|
|
491
|
+
var _a;
|
|
492
|
+
(_a = config.silent) != null ? _a : config.silent = true;
|
|
493
|
+
super(...arr);
|
|
494
|
+
this.config = config;
|
|
495
|
+
this.ignoreOrThrow = (returnValue) => {
|
|
496
|
+
if (this.config.silent) return returnValue;
|
|
497
|
+
throw new Error("Mutation not allowed on read-only array");
|
|
498
|
+
};
|
|
499
|
+
this.pop = () => this.ignoreOrThrow(this[this.length - 1]);
|
|
500
|
+
this.push = (...items) => !this.config.add ? this.ignoreOrThrow(this.length) : super.push(...items);
|
|
501
|
+
this.reverse = () => this.ignoreOrThrow(this);
|
|
502
|
+
this.shift = () => this.ignoreOrThrow(this[0]);
|
|
503
|
+
this.splice = (..._ignoredArgs) => this.ignoreOrThrow([]);
|
|
504
|
+
this.unshift = (..._ignoredArgs) => this.ignoreOrThrow(this.length);
|
|
505
|
+
// fromAsync = super.fromAsync
|
|
506
|
+
this.reduce = super.reduce;
|
|
507
|
+
this.reduceRight = super.reduceRight;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
// src/arr/arrReverse.ts
|
|
512
|
+
var arrReverse = (arr, reverse2 = true, newArray = false) => {
|
|
513
|
+
if (!isArr(arr)) return [];
|
|
514
|
+
if (newArray) arr = [...arr];
|
|
515
|
+
return reverse2 ? arr.reverse() : arr;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
// src/arr/arrToMap.ts
|
|
519
|
+
function arrToMap(arr, key, flatDepth = 0) {
|
|
520
|
+
;
|
|
521
|
+
[key, flatDepth] = isNumber(key) ? [void 0, key] : [key, flatDepth];
|
|
522
|
+
const flatEntries = (!isArr(arr) ? [] : flatDepth > 0 ? arr.flat(flatDepth) : arr).map((item, i, flatArr) => {
|
|
523
|
+
var _a;
|
|
524
|
+
return [
|
|
525
|
+
(_a = isFn(key) ? key(item, i, flatArr) : isObj(item) && isDefined(key) ? item[key] : i) != null ? _a : i,
|
|
526
|
+
item
|
|
527
|
+
];
|
|
528
|
+
});
|
|
529
|
+
return new Map(flatEntries);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/arr/arrUnique.ts
|
|
533
|
+
var arrUnique = (arr, flatDepth = 0) => !isArr(arr) ? [] : Array.from(new Set(arr.flat(flatDepth)));
|
|
534
|
+
|
|
535
|
+
// src/iterable/filter.ts
|
|
536
|
+
var filter = (data, predicate, limit = Infinity, asArray = false, result = /* @__PURE__ */ new Map()) => {
|
|
537
|
+
var _a;
|
|
538
|
+
if (!isMap(result)) result = /* @__PURE__ */ new Map();
|
|
539
|
+
for (const [key, item] of ((_a = data == null ? void 0 : data.entries) == null ? void 0 : _a.call(data)) || []) {
|
|
540
|
+
if (result.size >= limit) break;
|
|
541
|
+
fallbackIfFails_default(predicate != null ? predicate : item, [item, key, data], false) && result.set(key, item);
|
|
542
|
+
}
|
|
543
|
+
return asArray ? [...result.values()] : result;
|
|
544
|
+
};
|
|
545
|
+
var filter_default = filter;
|
|
546
|
+
|
|
547
|
+
// src/iterable/getSize.ts
|
|
548
|
+
var getSize = (x) => {
|
|
549
|
+
if (!x) return 0;
|
|
550
|
+
try {
|
|
551
|
+
const s = "size" in x ? x.size : "length" in x ? x.length : 0;
|
|
552
|
+
return isNumber(s) ? s : 0;
|
|
553
|
+
} catch (_) {
|
|
554
|
+
return 0;
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
var getSize_default = getSize;
|
|
558
|
+
|
|
559
|
+
// src/iterable/getValues.ts
|
|
560
|
+
var getValues = (data) => {
|
|
561
|
+
var _a;
|
|
562
|
+
return [
|
|
563
|
+
...((_a = data == null ? void 0 : data.values) == null ? void 0 : _a.call(data)) || []
|
|
564
|
+
];
|
|
565
|
+
};
|
|
566
|
+
var getValues_default = getValues;
|
|
567
|
+
|
|
568
|
+
// src/iterable/search.ts
|
|
569
|
+
var search = (data, options) => {
|
|
570
|
+
var _a;
|
|
571
|
+
const ignore = !getSize_default(data) || isEmpty(options == null ? void 0 : options.query);
|
|
572
|
+
const result = isMap(options == null ? void 0 : options.result) ? options.result : /* @__PURE__ */ new Map();
|
|
573
|
+
const asMap = (_a = options == null ? void 0 : options.asMap) != null ? _a : search.defaultOptions.asMap;
|
|
574
|
+
if (ignore) return asMap ? result : getValues_default(result);
|
|
575
|
+
options = objCopy(search.defaultOptions, options, [], "empty");
|
|
576
|
+
const { ignoreCase, limit = Infinity, matchAll, matchExact } = options;
|
|
577
|
+
let { query } = options;
|
|
578
|
+
const qIsStr = isStr(query);
|
|
579
|
+
const qIsRegExp = !qIsStr && isRegExp(query);
|
|
580
|
+
const qKeys = fallbackIfFails_default(Object.keys, [query], []);
|
|
581
|
+
if (ignoreCase && !matchExact && !qIsRegExp) {
|
|
582
|
+
query = qIsStr ? query.toLowerCase() : objCreate(
|
|
583
|
+
qKeys,
|
|
584
|
+
Object.values(query).map(
|
|
585
|
+
(x) => isRegExp(x) ? x : `${x}`.toLowerCase()
|
|
586
|
+
)
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
options.query = query;
|
|
590
|
+
const entries = data.entries();
|
|
591
|
+
for (const [dataKey, dataValue] of entries) {
|
|
592
|
+
if (result.size >= limit) break;
|
|
593
|
+
const matched = qIsStr || qIsRegExp ? matchItemOrProp(options, dataValue, void 0) : qKeys[matchAll ? "every" : "some"](
|
|
594
|
+
(key) => matchItemOrProp(options, dataValue, key)
|
|
595
|
+
// search specific properties
|
|
596
|
+
);
|
|
597
|
+
if (!matched) continue;
|
|
598
|
+
result.set(dataKey, dataValue);
|
|
599
|
+
}
|
|
600
|
+
return asMap ? result : getValues_default(result);
|
|
601
|
+
};
|
|
602
|
+
search.defaultOptions = {
|
|
603
|
+
asMap: true,
|
|
604
|
+
ignoreCase: true,
|
|
605
|
+
limit: Infinity,
|
|
606
|
+
matchAll: false,
|
|
607
|
+
matchExact: false
|
|
608
|
+
};
|
|
609
|
+
function matchItemOrProp({
|
|
610
|
+
query,
|
|
611
|
+
ignoreCase,
|
|
612
|
+
matchExact,
|
|
613
|
+
transform
|
|
614
|
+
}, item, propertyName) {
|
|
615
|
+
var _a, _b;
|
|
616
|
+
const fuzzy = isStr(query) || isRegExp(query) || propertyName === void 0;
|
|
617
|
+
const keyword = fuzzy ? query : query[propertyName];
|
|
618
|
+
const propVal = fuzzy || !isObj(item) ? item : item[propertyName];
|
|
619
|
+
let value = fallbackIfFails_default(
|
|
620
|
+
() => {
|
|
621
|
+
var _a2;
|
|
622
|
+
return isFn(transform) ? transform(
|
|
623
|
+
item,
|
|
624
|
+
fuzzy ? void 0 : propVal,
|
|
625
|
+
propertyName
|
|
626
|
+
) : isObj(propVal, false) ? JSON.stringify(
|
|
627
|
+
isArrLike(propVal) ? [...propVal.values()] : Object.values(propVal)
|
|
628
|
+
) : (_a2 = propVal == null ? void 0 : propVal.toString) == null ? void 0 : _a2.call(propVal);
|
|
629
|
+
},
|
|
630
|
+
[],
|
|
631
|
+
""
|
|
632
|
+
);
|
|
633
|
+
if (!(value == null ? void 0 : value.trim())) return false;
|
|
634
|
+
if (isRegExp(keyword)) return keyword.test(`${value}`);
|
|
635
|
+
if (ignoreCase && !matchExact) value = value.toLowerCase();
|
|
636
|
+
if (value === keyword) return true;
|
|
637
|
+
return !matchExact && `${value}`.includes((_b = (_a = keyword == null ? void 0 : keyword.toString) == null ? void 0 : _a.call(keyword)) != null ? _b : "");
|
|
638
|
+
}
|
|
639
|
+
var search_default = search;
|
|
640
|
+
|
|
641
|
+
// src/iterable/find.ts
|
|
642
|
+
function find(data, optsOrCb) {
|
|
643
|
+
const result = isFn(optsOrCb) ? filter_default(data, optsOrCb, 1) : search_default(data, { ...optsOrCb, asMap: true, limit: 1 });
|
|
644
|
+
return result[
|
|
645
|
+
(optsOrCb == null ? void 0 : optsOrCb.includeKey) ? "entries" : "values"
|
|
646
|
+
// returns: value
|
|
647
|
+
]().next().value;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// src/iterable/getEntries.ts
|
|
651
|
+
var getEntries = (map) => {
|
|
652
|
+
var _a;
|
|
653
|
+
return [
|
|
654
|
+
...((_a = map == null ? void 0 : map.entries) == null ? void 0 : _a.call(map)) || []
|
|
655
|
+
];
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// src/iterable/getKeys.ts
|
|
659
|
+
var getKeys = (data) => {
|
|
660
|
+
var _a;
|
|
661
|
+
return [
|
|
662
|
+
...((_a = data == null ? void 0 : data.keys) == null ? void 0 : _a.call(data)) || []
|
|
663
|
+
];
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// src/iterable/reverse.ts
|
|
667
|
+
var reverse = (data, reverse2 = true, newInstance = false) => {
|
|
668
|
+
var _a, _b, _c;
|
|
669
|
+
const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;
|
|
670
|
+
if (!dataType) return [];
|
|
671
|
+
const arr = dataType === 1 ? !newInstance ? data : [...data] : dataType === 2 ? [...data.entries()] : [...data.values()];
|
|
672
|
+
if (reverse2) arr.reverse();
|
|
673
|
+
if (dataType === 1) return arr;
|
|
674
|
+
if (newInstance || !("clear" in data && isFn(data.clear))) {
|
|
675
|
+
return dataType === 2 ? new Map(arr) : dataType === 3 && new Set(arr) || [];
|
|
676
|
+
}
|
|
677
|
+
(_a = data == null ? void 0 : data.clear) == null ? void 0 : _a.call(data);
|
|
678
|
+
for (const item of arr)
|
|
679
|
+
"set" in data ? (_b = data.set) == null ? void 0 : _b.call(data, ...item) : "add" in data && ((_c = data == null ? void 0 : data.add) == null ? void 0 : _c.call(data, item));
|
|
680
|
+
return data;
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/iterable/sliceMap.ts
|
|
684
|
+
var sliceMap = (data, options) => {
|
|
685
|
+
var _a;
|
|
686
|
+
const {
|
|
687
|
+
asMap = false,
|
|
688
|
+
end,
|
|
689
|
+
start = 0,
|
|
690
|
+
transform,
|
|
691
|
+
ignoreEmpty = true
|
|
692
|
+
} = isFn(options) ? { transform: options } : isObj(options) ? options : {};
|
|
693
|
+
const result = /* @__PURE__ */ new Map();
|
|
694
|
+
const subset = [...((_a = data == null ? void 0 : data.entries) == null ? void 0 : _a.call(data)) || []].slice(start, end);
|
|
695
|
+
for (const [_, [key, value]] of subset.entries()) {
|
|
696
|
+
if (ignoreEmpty && isEmpty(value)) continue;
|
|
697
|
+
const newValue = fallbackIfFails_default(
|
|
698
|
+
transform != null ? transform : value,
|
|
699
|
+
[value, key, data],
|
|
700
|
+
void 0
|
|
701
|
+
);
|
|
702
|
+
newValue !== void 0 && result.set(key, newValue);
|
|
703
|
+
}
|
|
704
|
+
return asMap ? result : [...result.values()];
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
// src/iterable/sort.ts
|
|
708
|
+
function sort(data, keyOrFn, options) {
|
|
709
|
+
const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;
|
|
710
|
+
if (!dataType) return data;
|
|
711
|
+
const { ignoreCase, newInstance, reverse: reverse2, undefinedFirst } = {
|
|
712
|
+
...sort.defaultOptions,
|
|
713
|
+
...isObj(options) ? options : isObj(keyOrFn) ? keyOrFn : {}
|
|
714
|
+
};
|
|
715
|
+
if (dataType === 1 && isFn(keyOrFn)) {
|
|
716
|
+
return arrReverse(
|
|
717
|
+
data.sort(keyOrFn),
|
|
718
|
+
// use provided comparator function
|
|
719
|
+
reverse2,
|
|
720
|
+
newInstance
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
const alt = undefinedFirst ? "" : "Z".repeat(10);
|
|
724
|
+
const sorted = isFn(keyOrFn) ? arrReverse(
|
|
725
|
+
// handle Set with comparator function
|
|
726
|
+
[...data.entries()].sort(keyOrFn),
|
|
727
|
+
reverse2,
|
|
728
|
+
false
|
|
729
|
+
// not required because of entries() & spread
|
|
730
|
+
) : (() => {
|
|
731
|
+
const key = keyOrFn;
|
|
732
|
+
const getVal = (obj) => {
|
|
733
|
+
var _a;
|
|
734
|
+
const value = `${(_a = isObj(obj) && key ? obj[key] : obj) != null ? _a : alt}`;
|
|
735
|
+
return ignoreCase ? value.toLowerCase() : value;
|
|
736
|
+
};
|
|
737
|
+
const index = keyOrFn === true ? 0 : 1;
|
|
738
|
+
const [gt, lt] = reverse2 ? [-1, 1] : [1, -1];
|
|
739
|
+
if ([1, 3].includes(dataType)) {
|
|
740
|
+
return (dataType === 3 || newInstance ? [...data] : data).sort((a, b) => getVal(a) > getVal(b) ? gt : lt);
|
|
741
|
+
}
|
|
742
|
+
return [...data.entries()].sort(
|
|
743
|
+
(a, b) => getVal(a == null ? void 0 : a[index]) > getVal(b == null ? void 0 : b[index]) ? gt : lt
|
|
744
|
+
);
|
|
745
|
+
})();
|
|
746
|
+
if (dataType === 1) return sorted;
|
|
747
|
+
if (newInstance) {
|
|
748
|
+
return dataType === 2 ? new Map(sorted) : new Set(sorted);
|
|
749
|
+
}
|
|
750
|
+
;
|
|
751
|
+
data.clear();
|
|
752
|
+
for (const entry of sorted)
|
|
753
|
+
dataType === 2 ? data.set(...entry) : data.add(entry);
|
|
754
|
+
return data;
|
|
755
|
+
}
|
|
756
|
+
sort.defaultOptions = {
|
|
757
|
+
ignoreCase: true,
|
|
758
|
+
newInstance: false,
|
|
759
|
+
reverse: false,
|
|
760
|
+
undefinedFirst: false
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/map/mapJoin.ts
|
|
764
|
+
var mapJoin = (...inputs) => {
|
|
765
|
+
var _a;
|
|
766
|
+
return new Map(
|
|
767
|
+
(_a = inputs == null ? void 0 : inputs.flatMap) == null ? void 0 : _a.call(
|
|
768
|
+
inputs,
|
|
769
|
+
(input) => isMap(input) ? Array.from(input.entries()) : isArr2D(input) ? input : []
|
|
770
|
+
)
|
|
771
|
+
);
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
// src/number/randomInt.ts
|
|
775
|
+
var randomInt = (min = 0, max = Number.MAX_SAFE_INTEGER) => parseInt(`${Math.random() * (max - min) + min}`);
|
|
776
|
+
|
|
777
|
+
// src/str/clearClutter.ts
|
|
778
|
+
var clearClutter = (text, lineSeparator = " ") => `${text}`.split("\n").map((ln) => ln.trim()).filter(Boolean).join(lineSeparator);
|
|
779
|
+
|
|
780
|
+
// src/str/copyToClipboard.ts
|
|
781
|
+
var copyToClipboard = (str) => fallbackIfFails(
|
|
782
|
+
// First attempt: modern clipboard API
|
|
783
|
+
() => navigator.clipboard.writeText(str).then(() => 1),
|
|
784
|
+
[],
|
|
785
|
+
// If clipboard API is not available or fails, use the fallback method
|
|
786
|
+
() => fallbackIfFails(
|
|
787
|
+
() => {
|
|
788
|
+
const el = document.createElement("textarea");
|
|
789
|
+
el.value = str;
|
|
790
|
+
el.setAttribute("readonly", "");
|
|
791
|
+
el.style.position = "absolute";
|
|
792
|
+
el.style.left = "-9999px";
|
|
793
|
+
document.body.appendChild(el);
|
|
794
|
+
el.select();
|
|
795
|
+
const result = document.execCommand("copy");
|
|
796
|
+
document.body.removeChild(el);
|
|
797
|
+
return Promise.resolve(result ? 2 : 0);
|
|
798
|
+
},
|
|
799
|
+
[],
|
|
800
|
+
() => Promise.resolve(0)
|
|
801
|
+
)
|
|
802
|
+
);
|
|
803
|
+
|
|
804
|
+
// src/str/getUrlParam.ts
|
|
805
|
+
var getUrlParam = (name, url, asArray) => {
|
|
806
|
+
var _a;
|
|
807
|
+
url != null ? url : url = fallbackIfFails_default(() => window.location.href, [], "");
|
|
808
|
+
const _asArray = isArr(asArray) ? asArray : asArray === true && isStr(name) ? [name] : [];
|
|
809
|
+
const prepareResult = (value = "", values = {}) => name ? isArr(value) || !_asArray.includes(name) ? value : [value].filter(Boolean) : values;
|
|
810
|
+
if (!url) return prepareResult();
|
|
811
|
+
if (typeof URLSearchParams === "undefined" || !URLSearchParams) {
|
|
812
|
+
const r = getUrlParamRegex(name, url, _asArray);
|
|
813
|
+
return prepareResult(r, r);
|
|
814
|
+
}
|
|
815
|
+
const search2 = isUrl(url) ? url.search : ((_a = url.split("?")) == null ? void 0 : _a[1]) || "";
|
|
816
|
+
if (search2 === "?" || !search2) return prepareResult();
|
|
817
|
+
const params = new URLSearchParams(search2);
|
|
818
|
+
const getValue = (paramName) => {
|
|
819
|
+
const value = arrUnique(params.getAll(paramName));
|
|
820
|
+
return value.length > 1 || _asArray.includes(paramName) ? value : value[0];
|
|
821
|
+
};
|
|
822
|
+
if (name) return prepareResult(getValue(name));
|
|
823
|
+
const result = {};
|
|
824
|
+
for (const name2 of arrUnique([...params.keys()])) {
|
|
825
|
+
result[name2] = getValue(name2);
|
|
826
|
+
}
|
|
827
|
+
return result;
|
|
828
|
+
};
|
|
829
|
+
var getUrlParamRegex = (name, url, asArray = []) => {
|
|
830
|
+
url != null ? url : url = fallbackIfFails_default(() => window.location.href, [], "");
|
|
831
|
+
if (isUrl(url)) url = url.toString();
|
|
832
|
+
const params = {};
|
|
833
|
+
const regex = /[?&]+([^=&]+)=([^&]*)/gi;
|
|
834
|
+
url.replace(regex, (_, name2, value) => {
|
|
835
|
+
value = decodeURIComponent(value);
|
|
836
|
+
if (asArray.includes(name2) || params[name2] !== void 0) {
|
|
837
|
+
params[name2] = isArr(params[name2]) ? params[name2] : [params[name2]];
|
|
838
|
+
params[name2] = arrUnique([...params[name2], value]).filter(Boolean);
|
|
839
|
+
} else {
|
|
840
|
+
params[name2] = value;
|
|
841
|
+
}
|
|
842
|
+
return "";
|
|
843
|
+
});
|
|
844
|
+
return name ? params[name] : params;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
// src/str/regex.ts
|
|
848
|
+
var EMAIL_REGEX = new RegExp(
|
|
849
|
+
/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,9}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
|
|
850
|
+
);
|
|
851
|
+
var HEX_REGEX = /^0x[0-9a-f]+$/i;
|
|
852
|
+
var HASH_REGEX = /^0x[0-9a-f]{64}$/i;
|
|
853
|
+
export {
|
|
854
|
+
EMAIL_REGEX,
|
|
855
|
+
HASH_REGEX,
|
|
856
|
+
HEX_REGEX,
|
|
857
|
+
ReadOnlyArrayHelper,
|
|
858
|
+
arrReadOnly,
|
|
859
|
+
arrReverse,
|
|
860
|
+
arrToMap,
|
|
861
|
+
arrUnique,
|
|
862
|
+
asAny,
|
|
863
|
+
clearClutter,
|
|
864
|
+
copyToClipboard,
|
|
865
|
+
curry,
|
|
866
|
+
debounce,
|
|
867
|
+
deferred,
|
|
868
|
+
fallbackIfFails,
|
|
869
|
+
filter,
|
|
870
|
+
find,
|
|
871
|
+
forceCast,
|
|
872
|
+
getEntries,
|
|
873
|
+
getKeys,
|
|
874
|
+
getSize,
|
|
875
|
+
getUrlParam,
|
|
876
|
+
getValues,
|
|
877
|
+
is,
|
|
878
|
+
isArr,
|
|
879
|
+
isArr2D,
|
|
880
|
+
isArrLike,
|
|
881
|
+
isArrLikeSafe,
|
|
882
|
+
isArrObj,
|
|
883
|
+
isArrUnique,
|
|
884
|
+
isAsyncFn,
|
|
885
|
+
isBool,
|
|
886
|
+
isDate,
|
|
887
|
+
isDateValid,
|
|
888
|
+
isDefined,
|
|
889
|
+
isEmpty,
|
|
890
|
+
isEmptySafe,
|
|
891
|
+
isEnvBrowser,
|
|
892
|
+
isEnvNode,
|
|
893
|
+
isEnvTouchable,
|
|
894
|
+
isError,
|
|
895
|
+
isFn,
|
|
896
|
+
isInteger,
|
|
897
|
+
isMap,
|
|
898
|
+
isMapObj,
|
|
899
|
+
isNumber,
|
|
900
|
+
isObj,
|
|
901
|
+
isPositiveInteger,
|
|
902
|
+
isPositiveNumber,
|
|
903
|
+
isPromise,
|
|
904
|
+
isRegExp,
|
|
905
|
+
isSet,
|
|
906
|
+
isStr,
|
|
907
|
+
isSymbol,
|
|
908
|
+
isUint8Arr,
|
|
909
|
+
isUrl,
|
|
910
|
+
isUrlValid,
|
|
911
|
+
mapJoin,
|
|
912
|
+
matchItemOrProp,
|
|
913
|
+
noop,
|
|
914
|
+
noopAsync,
|
|
915
|
+
objClean,
|
|
916
|
+
objCopy,
|
|
917
|
+
objCreate,
|
|
918
|
+
objKeys,
|
|
919
|
+
objReadOnly,
|
|
920
|
+
objSetProp,
|
|
921
|
+
objSetPropUndefined,
|
|
922
|
+
objSort,
|
|
923
|
+
objWithoutKeys,
|
|
924
|
+
randomInt,
|
|
925
|
+
reverse,
|
|
926
|
+
search,
|
|
927
|
+
sliceMap,
|
|
928
|
+
sort,
|
|
929
|
+
throttled,
|
|
930
|
+
toDatetimeLocal
|
|
931
|
+
};
|