mazey 5.4.1 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -0
- package/README.zh-CN.md +88 -0
- package/lib/index.cjs.js +2 -2
- package/lib/index.d.ts +984 -786
- package/lib/index.esm.js +2 -2
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,114 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compute the length of the longest common substring of two strings.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
*
|
|
6
|
-
* ```javascript
|
|
7
|
-
* import { longestComSubstring } from "mazey";
|
|
8
|
-
*
|
|
9
|
-
* const ret = longestComSubstring("fish", "finish");
|
|
10
|
-
* console.log(ret);
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Output:
|
|
14
|
-
*
|
|
15
|
-
* ```text
|
|
16
|
-
* 3
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param {string} aStr String
|
|
20
|
-
* @param {string} bStr String
|
|
21
|
-
* @returns {number} Length
|
|
22
|
-
* @category Calculate and Formula
|
|
23
|
-
*/
|
|
24
|
-
declare function longestComSubstring(aStr: string, bStr: string): number;
|
|
25
|
-
/**
|
|
26
|
-
* Alias of `longestComSubstring`.
|
|
27
|
-
*
|
|
28
|
-
* @hidden
|
|
29
|
-
*/
|
|
30
|
-
declare function calLongestCommonSubstring(aStr: string, bStr: string): number;
|
|
31
|
-
/**
|
|
32
|
-
* Compute the length of the longest common subsequence of two strings.
|
|
33
|
-
*
|
|
34
|
-
* Usage:
|
|
35
|
-
*
|
|
36
|
-
* ```javascript
|
|
37
|
-
* import { longestComSubsequence } from "mazey";
|
|
38
|
-
*
|
|
39
|
-
* const ret = longestComSubsequence("fish", "finish");
|
|
40
|
-
* console.log(ret);
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* Output:
|
|
44
|
-
*
|
|
45
|
-
* ```text
|
|
46
|
-
* 4
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @param {string} aStr The first string.
|
|
50
|
-
* @param {string} bStr The second string.
|
|
51
|
-
* @returns {number} The length of the longest common subsequence.
|
|
52
|
-
* @category Calculate and Formula
|
|
53
|
-
*/
|
|
54
|
-
declare function longestComSubsequence(aStr: string, bStr: string): number;
|
|
55
|
-
/**
|
|
56
|
-
* Alias of `longestComSubsequence`.
|
|
57
|
-
*
|
|
58
|
-
* @hidden
|
|
59
|
-
*/
|
|
60
|
-
declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
|
|
61
|
-
/**
|
|
62
|
-
* Return whether a random value falls within the given probability.
|
|
63
|
-
*
|
|
64
|
-
* Usage:
|
|
65
|
-
*
|
|
66
|
-
* ```javascript
|
|
67
|
-
* import { isHit } from "mazey";
|
|
68
|
-
*
|
|
69
|
-
* const ret = isHit(0.5); // A 50% chance of returning true.
|
|
70
|
-
* console.log(ret);
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* Output:
|
|
74
|
-
*
|
|
75
|
-
* ```text
|
|
76
|
-
* true
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* Example: Test the precision.
|
|
80
|
-
*
|
|
81
|
-
* ```javascript
|
|
82
|
-
* let trueCount = 0;
|
|
83
|
-
* let falseCount = 0;
|
|
84
|
-
* new Array(1000000).fill(0).forEach(() => {
|
|
85
|
-
* if (isHit(0.5)) {
|
|
86
|
-
* trueCount++;
|
|
87
|
-
* } else {
|
|
88
|
-
* falseCount++;
|
|
89
|
-
* }
|
|
90
|
-
* });
|
|
91
|
-
* console.log(trueCount, falseCount);
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* Output:
|
|
95
|
-
*
|
|
96
|
-
* ```text
|
|
97
|
-
* 499994 500006
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* @param {number} rate Probability expressed as a value from 0 to 1.
|
|
101
|
-
* @returns {boolean} Whether the random value is less than the probability.
|
|
102
|
-
* @category Calculate and Formula
|
|
103
|
-
*/
|
|
104
|
-
declare function isHit(rate: number): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Alias of `isHit`.
|
|
107
|
-
*
|
|
108
|
-
* @hidden
|
|
109
|
-
*/
|
|
110
|
-
declare function inRate(rate: number): boolean;
|
|
111
|
-
|
|
112
1
|
/**
|
|
113
2
|
* @author Cheng
|
|
114
3
|
*/
|
|
@@ -206,1383 +95,1619 @@ interface OnURLChangeOptions {
|
|
|
206
95
|
fireOnInit?: boolean;
|
|
207
96
|
}
|
|
208
97
|
|
|
98
|
+
type InvestmentReturnRate = number | string;
|
|
209
99
|
/**
|
|
210
|
-
*
|
|
100
|
+
* Calculate an investment's Compound Annual Growth Rate (CAGR).
|
|
211
101
|
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
102
|
+
* Numeric total returns use decimal ratios. For example, `0.202` represents
|
|
103
|
+
* `20.2%`. String total returns use percentage values, so `"20.2%"` and
|
|
104
|
+
* `"20.2"` both represent `20.2%`. A trailing percent sign is optional, and
|
|
105
|
+
* the complete trimmed string must be a finite JavaScript number. Scientific
|
|
106
|
+
* notation such as `"2.02e1%"` is accepted.
|
|
107
|
+
*
|
|
108
|
+
* The returned CAGR is a decimal ratio and is not rounded. The calculation
|
|
109
|
+
* uses:
|
|
110
|
+
*
|
|
111
|
+
* `CAGR = (1 + totalReturn)^(365 / durationInDays) - 1`
|
|
214
112
|
*
|
|
215
113
|
* Usage:
|
|
216
114
|
*
|
|
217
|
-
* ```
|
|
218
|
-
* import {
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import {
|
|
117
|
+
* calculateCAGR,
|
|
118
|
+
* floatToPercent,
|
|
119
|
+
* } from "mazey";
|
|
219
120
|
*
|
|
220
|
-
* const
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
121
|
+
* const cagr = calculateCAGR(
|
|
122
|
+
* "2022-04-01",
|
|
123
|
+
* "2025-10-01",
|
|
124
|
+
* "20.2%"
|
|
125
|
+
* );
|
|
126
|
+
* const equivalentCagr = calculateCAGR(
|
|
127
|
+
* "2022-04-01",
|
|
128
|
+
* "2025-10-01",
|
|
129
|
+
* 0.202
|
|
130
|
+
* );
|
|
131
|
+
* const negativeCagr = calculateCAGR(
|
|
132
|
+
* "2022-04-01",
|
|
133
|
+
* "2025-10-01",
|
|
134
|
+
* "-15.5%"
|
|
135
|
+
* );
|
|
136
|
+
*
|
|
137
|
+
* console.log({
|
|
138
|
+
* cagr,
|
|
139
|
+
* equivalentCagr,
|
|
140
|
+
* negativeCagr,
|
|
141
|
+
* percentage: floatToPercent(cagr, 2),
|
|
142
|
+
* });
|
|
224
143
|
* ```
|
|
225
144
|
*
|
|
226
|
-
*
|
|
145
|
+
* Possible output:
|
|
227
146
|
*
|
|
228
147
|
* ```text
|
|
229
|
-
*
|
|
230
|
-
*
|
|
148
|
+
* {
|
|
149
|
+
* cagr: 0.053908...,
|
|
150
|
+
* equivalentCagr: 0.053908...,
|
|
151
|
+
* negativeCagr: -0.046926...,
|
|
152
|
+
* percentage: "5.39%"
|
|
153
|
+
* }
|
|
231
154
|
* ```
|
|
232
155
|
*
|
|
233
|
-
* @param
|
|
234
|
-
* @
|
|
235
|
-
* @
|
|
156
|
+
* @param startDate Start date as a supported structured string, millisecond timestamp, or `Date`.
|
|
157
|
+
* @param endDate End date in the same accepted forms. It must be strictly later than `startDate`.
|
|
158
|
+
* @param totalReturnRate Total period return. Numbers are decimal ratios; strings are percentage values.
|
|
159
|
+
* @returns The unrounded CAGR as a decimal ratio.
|
|
160
|
+
* @throws {TypeError} If either date or the total return is invalid.
|
|
161
|
+
* @throws {RangeError} If the dates are not increasing, the total return is at most `-1`, or the result is not finite.
|
|
162
|
+
* @remarks Duration uses the exact elapsed milliseconds, including time of day, converted to fractional days. A financial year is always fixed at 365 days. Input `Date` objects are copied and never mutated.
|
|
163
|
+
* @category Calculate and Formula
|
|
236
164
|
*/
|
|
237
|
-
declare function
|
|
165
|
+
declare function calculateCAGR(startDate: MazeyDate, endDate: MazeyDate, totalReturnRate: InvestmentReturnRate): number;
|
|
238
166
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* Primitive values and objects that are already frozen are returned unchanged.
|
|
167
|
+
* Compute the length of the longest common substring of two strings.
|
|
242
168
|
*
|
|
243
169
|
* Usage:
|
|
244
170
|
*
|
|
245
171
|
* ```javascript
|
|
246
|
-
* import {
|
|
247
|
-
*
|
|
248
|
-
* const config = deepFreeze({
|
|
249
|
-
* api: {
|
|
250
|
-
* timeout: 5000,
|
|
251
|
-
* },
|
|
252
|
-
* });
|
|
172
|
+
* import { longestComSubstring } from "mazey";
|
|
253
173
|
*
|
|
254
|
-
*
|
|
255
|
-
* console.log(
|
|
174
|
+
* const ret = longestComSubstring("fish", "finish");
|
|
175
|
+
* console.log(ret);
|
|
256
176
|
* ```
|
|
257
177
|
*
|
|
258
178
|
* Output:
|
|
259
179
|
*
|
|
260
180
|
* ```text
|
|
261
|
-
*
|
|
262
|
-
* true
|
|
181
|
+
* 3
|
|
263
182
|
* ```
|
|
264
183
|
*
|
|
265
|
-
* @param
|
|
266
|
-
* @
|
|
267
|
-
* @
|
|
184
|
+
* @param {string} aStr String
|
|
185
|
+
* @param {string} bStr String
|
|
186
|
+
* @returns {number} Length
|
|
187
|
+
* @category Calculate and Formula
|
|
268
188
|
*/
|
|
269
|
-
declare function
|
|
189
|
+
declare function longestComSubstring(aStr: string, bStr: string): number;
|
|
270
190
|
/**
|
|
271
|
-
* Alias of `
|
|
191
|
+
* Alias of `longestComSubstring`.
|
|
272
192
|
*
|
|
273
193
|
* @hidden
|
|
274
194
|
*/
|
|
275
|
-
declare function
|
|
195
|
+
declare function calLongestCommonSubstring(aStr: string, bStr: string): number;
|
|
276
196
|
/**
|
|
277
|
-
*
|
|
197
|
+
* Compute the length of the longest common subsequence of two strings.
|
|
278
198
|
*
|
|
279
199
|
* Usage:
|
|
280
200
|
*
|
|
281
201
|
* ```javascript
|
|
282
|
-
* import {
|
|
202
|
+
* import { longestComSubsequence } from "mazey";
|
|
283
203
|
*
|
|
284
|
-
* const
|
|
285
|
-
*
|
|
286
|
-
* console.log(ret1);
|
|
287
|
-
* console.log(ret2);
|
|
204
|
+
* const ret = longestComSubsequence("fish", "finish");
|
|
205
|
+
* console.log(ret);
|
|
288
206
|
* ```
|
|
289
207
|
*
|
|
290
208
|
* Output:
|
|
291
209
|
*
|
|
292
210
|
* ```text
|
|
293
|
-
*
|
|
294
|
-
* a-b-c
|
|
211
|
+
* 4
|
|
295
212
|
* ```
|
|
296
213
|
*
|
|
297
|
-
* @param {string}
|
|
298
|
-
* @
|
|
299
|
-
* @
|
|
214
|
+
* @param {string} aStr The first string.
|
|
215
|
+
* @param {string} bStr The second string.
|
|
216
|
+
* @returns {number} The length of the longest common subsequence.
|
|
217
|
+
* @category Calculate and Formula
|
|
300
218
|
*/
|
|
301
|
-
declare function
|
|
219
|
+
declare function longestComSubsequence(aStr: string, bStr: string): number;
|
|
302
220
|
/**
|
|
303
|
-
*
|
|
221
|
+
* Alias of `longestComSubsequence`.
|
|
222
|
+
*
|
|
223
|
+
* @hidden
|
|
224
|
+
*/
|
|
225
|
+
declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
|
|
226
|
+
/**
|
|
227
|
+
* Return whether a random value falls within the given probability.
|
|
304
228
|
*
|
|
305
229
|
* Usage:
|
|
306
230
|
*
|
|
307
231
|
* ```javascript
|
|
308
|
-
* import {
|
|
232
|
+
* import { isHit } from "mazey";
|
|
309
233
|
*
|
|
310
|
-
* const
|
|
311
|
-
*
|
|
312
|
-
* console.log(ret1, ret2);
|
|
234
|
+
* const ret = isHit(0.5); // A 50% chance of returning true.
|
|
235
|
+
* console.log(ret);
|
|
313
236
|
* ```
|
|
314
237
|
*
|
|
315
238
|
* Output:
|
|
316
239
|
*
|
|
317
240
|
* ```text
|
|
318
|
-
*
|
|
241
|
+
* true
|
|
319
242
|
* ```
|
|
320
243
|
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
244
|
+
* Example: Test the precision.
|
|
245
|
+
*
|
|
246
|
+
* ```javascript
|
|
247
|
+
* let trueCount = 0;
|
|
248
|
+
* let falseCount = 0;
|
|
249
|
+
* new Array(1000000).fill(0).forEach(() => {
|
|
250
|
+
* if (isHit(0.5)) {
|
|
251
|
+
* trueCount++;
|
|
252
|
+
* } else {
|
|
253
|
+
* falseCount++;
|
|
254
|
+
* }
|
|
255
|
+
* });
|
|
256
|
+
* console.log(trueCount, falseCount);
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* Output:
|
|
260
|
+
*
|
|
261
|
+
* ```text
|
|
262
|
+
* 499994 500006
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* @param {number} rate Probability expressed as a value from 0 to 1.
|
|
266
|
+
* @returns {boolean} Whether the random value is less than the probability.
|
|
267
|
+
* @category Calculate and Formula
|
|
324
268
|
*/
|
|
325
|
-
declare function
|
|
269
|
+
declare function isHit(rate: number): boolean;
|
|
326
270
|
/**
|
|
327
|
-
* Alias of `
|
|
271
|
+
* Alias of `isHit`.
|
|
328
272
|
*
|
|
329
273
|
* @hidden
|
|
330
274
|
*/
|
|
331
|
-
declare function
|
|
275
|
+
declare function inRate(rate: number): boolean;
|
|
276
|
+
|
|
332
277
|
/**
|
|
333
|
-
*
|
|
278
|
+
* Get the current timestamp in milliseconds.
|
|
334
279
|
*
|
|
335
280
|
* Usage:
|
|
336
281
|
*
|
|
337
282
|
* ```javascript
|
|
338
|
-
* import {
|
|
283
|
+
* import { mNow } from "mazey";
|
|
339
284
|
*
|
|
340
|
-
* const
|
|
341
|
-
*
|
|
342
|
-
* console.log(ret1);
|
|
343
|
-
* console.log(ret2);
|
|
285
|
+
* const ret = mNow();
|
|
286
|
+
* console.log(ret);
|
|
344
287
|
* ```
|
|
345
288
|
*
|
|
346
289
|
* Output:
|
|
347
290
|
*
|
|
348
291
|
* ```text
|
|
349
|
-
*
|
|
350
|
-
* a_b_c
|
|
292
|
+
* 1585325367122
|
|
351
293
|
* ```
|
|
352
294
|
*
|
|
353
|
-
* @
|
|
354
|
-
* @returns {string} "a_b_c"
|
|
295
|
+
* @returns {number} The current timestamp in milliseconds.
|
|
355
296
|
* @category Util
|
|
356
297
|
*/
|
|
357
|
-
declare function
|
|
298
|
+
declare function mNow(): number;
|
|
358
299
|
/**
|
|
359
|
-
*
|
|
300
|
+
* Calculate the interval between two dates or timestamps.
|
|
301
|
+
*
|
|
302
|
+
* The default `d` type returns the number of whole days. The `text` type
|
|
303
|
+
* returns an English duration using days, hours, minutes, and seconds while
|
|
304
|
+
* omitting zero-valued units. A zero interval returns `"0 seconds"`. Any other
|
|
305
|
+
* type returns the number of whole seconds. Negative intervals and invalid
|
|
306
|
+
* dates return an empty string.
|
|
360
307
|
*
|
|
361
308
|
* Usage:
|
|
362
309
|
*
|
|
363
310
|
* ```javascript
|
|
364
|
-
* import {
|
|
311
|
+
* import { getDateDifference } from "mazey";
|
|
365
312
|
*
|
|
366
|
-
* const
|
|
367
|
-
* const
|
|
368
|
-
*
|
|
313
|
+
* const days = getDateDifference(0, 90061000);
|
|
314
|
+
* const text = getDateDifference(0, 90061000, { type: "text" });
|
|
315
|
+
* const compactText = getDateDifference(0, 90060000, { type: "text" });
|
|
316
|
+
* const dateStringDays = getDateDifference(
|
|
317
|
+
* "2020-03-28 00:09:27",
|
|
318
|
+
* "2023-04-18 10:54:00"
|
|
319
|
+
* );
|
|
320
|
+
* console.log(days);
|
|
321
|
+
* console.log(text);
|
|
322
|
+
* console.log(compactText);
|
|
323
|
+
* console.log(dateStringDays);
|
|
369
324
|
* ```
|
|
370
325
|
*
|
|
371
326
|
* Output:
|
|
372
327
|
*
|
|
373
328
|
* ```text
|
|
374
|
-
*
|
|
329
|
+
* 1
|
|
330
|
+
* 1 day 1 hour 1 minute 1 second
|
|
331
|
+
* 1 day 1 hour 1 minute
|
|
332
|
+
* 1116
|
|
375
333
|
* ```
|
|
376
334
|
*
|
|
377
|
-
* @param
|
|
378
|
-
* @
|
|
335
|
+
* @param start Start date or timestamp.
|
|
336
|
+
* @param end End date or timestamp.
|
|
337
|
+
* @param options Formatting options. Use `d` for whole days or `text` for an English duration.
|
|
338
|
+
* @returns Whole days, whole seconds, an English duration, or an empty string for a negative or invalid interval.
|
|
339
|
+
* @remarks Strings in `YYYY-MM-DD HH:mm:ss` format are normalized and parsed as local time. Other date strings use the runtime's native `Date` parser; use timestamps or ISO strings with an explicit timezone when parsing must be portable.
|
|
379
340
|
* @category Util
|
|
380
341
|
*/
|
|
381
|
-
declare function
|
|
342
|
+
declare function getDateDifference(start?: number | string | Date, end?: number | string | Date, options?: {
|
|
343
|
+
type?: string;
|
|
344
|
+
}): number | string;
|
|
382
345
|
/**
|
|
383
|
-
* Alias of `
|
|
346
|
+
* Alias of `getDateDifference`.
|
|
384
347
|
*
|
|
385
348
|
* @hidden
|
|
386
349
|
*/
|
|
387
|
-
declare function
|
|
350
|
+
declare function getFriendlyInterval(start?: number | string | Date, end?: number | string | Date, options?: {
|
|
351
|
+
type?: string;
|
|
352
|
+
}): number | string;
|
|
388
353
|
/**
|
|
389
|
-
*
|
|
354
|
+
* Format a duration in milliseconds using its largest applicable English unit.
|
|
390
355
|
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
356
|
+
* Values are rounded to at most one decimal place. Negative durations are
|
|
357
|
+
* clamped to zero, and non-finite values return `"0 seconds"`.
|
|
393
358
|
*
|
|
394
359
|
* Usage:
|
|
395
360
|
*
|
|
396
361
|
* ```javascript
|
|
397
|
-
* import {
|
|
398
|
-
*
|
|
399
|
-
* const globalName = toJavaScriptGlobalName("@scope/my-library");
|
|
400
|
-
* console.log(globalName);
|
|
401
|
-
* ```
|
|
402
|
-
*
|
|
403
|
-
* Output:
|
|
362
|
+
* import { formatDurationFromMs } from "mazey";
|
|
404
363
|
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
364
|
+
* formatDurationFromMs(500); // "0.5 seconds"
|
|
365
|
+
* formatDurationFromMs(90000); // "1.5 minutes"
|
|
366
|
+
* formatDurationFromMs(3600000); // "1 hour"
|
|
367
|
+
* formatDurationFromMs(129600000); // "1.5 days"
|
|
407
368
|
* ```
|
|
408
369
|
*
|
|
409
|
-
* @param
|
|
410
|
-
* @returns
|
|
411
|
-
* @throws TypeError when `value` is not a string.
|
|
370
|
+
* @param {number} durationMs Duration in milliseconds.
|
|
371
|
+
* @returns {string} Concise duration using seconds, minutes, hours, or days.
|
|
412
372
|
* @category Util
|
|
413
373
|
*/
|
|
414
|
-
declare function
|
|
374
|
+
declare function formatDurationFromMs(durationMs: number): string;
|
|
415
375
|
/**
|
|
416
|
-
*
|
|
376
|
+
* Check whether an unknown value represents a valid date.
|
|
417
377
|
*
|
|
418
|
-
*
|
|
378
|
+
* Valid inputs include `Date` instances, finite millisecond timestamps,
|
|
379
|
+
* structured local date strings, and ISO 8601 strings with `Z` or a numeric
|
|
380
|
+
* timezone offset. Structured strings are parsed into numeric components and
|
|
381
|
+
* validated strictly, so invalid calendar dates are not normalized.
|
|
382
|
+
*
|
|
383
|
+
* Supported string forms are `YYYY-MM-DD`, `YYYY-MM-DD HH:mm[:ss]`,
|
|
384
|
+
* `YYYY-MM-DDTHH:mm[:ss]`, and the same `T`-separated date-time with `Z` or
|
|
385
|
+
* a `+HH:mm`/`-HH:mm` offset. Zoned strings may include 1-3 millisecond digits.
|
|
419
386
|
*
|
|
420
387
|
* Usage:
|
|
421
388
|
*
|
|
422
389
|
* ```javascript
|
|
423
|
-
* import {
|
|
390
|
+
* import { isValidDate } from "mazey";
|
|
424
391
|
*
|
|
425
|
-
* const ret1 =
|
|
426
|
-
* const ret2 =
|
|
427
|
-
*
|
|
428
|
-
*
|
|
392
|
+
* const ret1 = isValidDate(1577877720000);
|
|
393
|
+
* const ret2 = isValidDate("2020-01-01 11:22");
|
|
394
|
+
* const ret3 = isValidDate("2020-02-30");
|
|
395
|
+
* const ret4 = isValidDate(new Date("invalid"));
|
|
396
|
+
*
|
|
397
|
+
* console.log(ret1, ret2, ret3, ret4);
|
|
429
398
|
* ```
|
|
430
399
|
*
|
|
431
400
|
* Output:
|
|
432
401
|
*
|
|
433
402
|
* ```text
|
|
434
|
-
*
|
|
435
|
-
* abc
|
|
403
|
+
* true true false false
|
|
436
404
|
* ```
|
|
437
405
|
*
|
|
438
|
-
* @param
|
|
439
|
-
* @returns
|
|
406
|
+
* @param value A `Date`, millisecond timestamp, or supported structured date string.
|
|
407
|
+
* @returns Whether the value represents a valid date.
|
|
440
408
|
* @category Util
|
|
441
|
-
* @hidden
|
|
442
409
|
*/
|
|
443
|
-
declare function
|
|
410
|
+
declare function isValidDate(value: unknown): boolean;
|
|
444
411
|
/**
|
|
445
|
-
* Check whether
|
|
412
|
+
* Check whether a date is today in the runtime's local timezone.
|
|
446
413
|
*
|
|
447
414
|
* Usage:
|
|
448
415
|
*
|
|
449
416
|
* ```javascript
|
|
450
|
-
* import {
|
|
417
|
+
* import { isToday } from "mazey";
|
|
451
418
|
*
|
|
452
|
-
* const
|
|
453
|
-
*
|
|
454
|
-
* console.log(ret1);
|
|
455
|
-
* console.log(ret2);
|
|
419
|
+
* const ret = isToday(new Date());
|
|
420
|
+
* console.log(ret);
|
|
456
421
|
* ```
|
|
457
422
|
*
|
|
458
423
|
* Output:
|
|
459
424
|
*
|
|
460
425
|
* ```text
|
|
461
|
-
* false
|
|
462
426
|
* true
|
|
463
427
|
* ```
|
|
464
428
|
*
|
|
465
|
-
* @param
|
|
466
|
-
* @returns
|
|
467
|
-
* @
|
|
468
|
-
*/
|
|
469
|
-
declare function isJSONString(str: string): boolean;
|
|
470
|
-
/**
|
|
471
|
-
* Alias of `isJSONString`.
|
|
472
|
-
*
|
|
473
|
-
* @hidden
|
|
474
|
-
*/
|
|
475
|
-
declare function isJsonString(str: string): boolean;
|
|
476
|
-
/**
|
|
477
|
-
* Parse a JSON string and return a caller-defined fallback when parsing fails.
|
|
478
|
-
*
|
|
479
|
-
* Usage:
|
|
480
|
-
*
|
|
481
|
-
* ```javascript
|
|
482
|
-
* import { parseJsonSafe } from "mazey";
|
|
483
|
-
*
|
|
484
|
-
* const data = parseJsonSafe('{"enabled":true}');
|
|
485
|
-
* const fallback = parseJsonSafe("invalid", {});
|
|
486
|
-
* ```
|
|
487
|
-
*
|
|
488
|
-
* @param value JSON string to parse.
|
|
489
|
-
* @param fallback Value returned when parsing fails. Defaults to `null`.
|
|
490
|
-
* @returns The parsed JSON value or the supplied fallback.
|
|
429
|
+
* @param date A `Date`, millisecond timestamp, or string accepted by `isValidDate`.
|
|
430
|
+
* @returns Whether the value has the current local year, month, and day. Invalid input returns `false`.
|
|
431
|
+
* @remarks Hours, minutes, seconds, and milliseconds are ignored. Results depend on the runtime's local timezone.
|
|
491
432
|
* @category Util
|
|
492
433
|
*/
|
|
493
|
-
declare function
|
|
434
|
+
declare function isToday(date: MazeyDate): boolean;
|
|
494
435
|
/**
|
|
495
|
-
*
|
|
436
|
+
* Check whether a date is in the current local calendar year.
|
|
496
437
|
*
|
|
497
438
|
* Usage:
|
|
498
439
|
*
|
|
499
440
|
* ```javascript
|
|
500
|
-
* import {
|
|
441
|
+
* import { isThisYear } from "mazey";
|
|
501
442
|
*
|
|
502
|
-
* const
|
|
503
|
-
*
|
|
504
|
-
* console.log(ret1);
|
|
505
|
-
* console.log(ret2);
|
|
443
|
+
* const ret = isThisYear(new Date());
|
|
444
|
+
* console.log(ret);
|
|
506
445
|
* ```
|
|
507
446
|
*
|
|
508
447
|
* Output:
|
|
509
448
|
*
|
|
510
449
|
* ```text
|
|
511
|
-
*
|
|
512
|
-
* 2262490
|
|
450
|
+
* true
|
|
513
451
|
* ```
|
|
514
452
|
*
|
|
515
|
-
* @param
|
|
516
|
-
* @returns
|
|
453
|
+
* @param date A `Date`, millisecond timestamp, or string accepted by `isValidDate`.
|
|
454
|
+
* @returns Whether the value has the current local year. Invalid input returns `false`.
|
|
455
|
+
* @remarks Results depend on the runtime's local timezone.
|
|
517
456
|
* @category Util
|
|
518
457
|
*/
|
|
519
|
-
declare function
|
|
520
|
-
/**
|
|
521
|
-
* Alias of `genRndNumString`.
|
|
522
|
-
*
|
|
523
|
-
* @hidden
|
|
524
|
-
*/
|
|
525
|
-
declare function generateRndNum(n?: number): string;
|
|
458
|
+
declare function isThisYear(date: MazeyDate): boolean;
|
|
526
459
|
/**
|
|
527
|
-
*
|
|
528
|
-
* random numeric suffix.
|
|
460
|
+
* Check whether a date is in the current local calendar month and year.
|
|
529
461
|
*
|
|
530
462
|
* Usage:
|
|
531
463
|
*
|
|
532
464
|
* ```javascript
|
|
533
|
-
* import {
|
|
465
|
+
* import { isThisMonth } from "mazey";
|
|
534
466
|
*
|
|
535
|
-
* const
|
|
536
|
-
*
|
|
537
|
-
* console.log(ret1);
|
|
538
|
-
* console.log(ret2);
|
|
467
|
+
* const ret = isThisMonth(new Date());
|
|
468
|
+
* console.log(ret);
|
|
539
469
|
* ```
|
|
540
470
|
*
|
|
541
471
|
* Output:
|
|
542
472
|
*
|
|
543
473
|
* ```text
|
|
544
|
-
*
|
|
545
|
-
* 1538324722364123
|
|
474
|
+
* true
|
|
546
475
|
* ```
|
|
547
476
|
*
|
|
548
|
-
* @param
|
|
549
|
-
* @returns
|
|
477
|
+
* @param date A `Date`, millisecond timestamp, or string accepted by `isValidDate`.
|
|
478
|
+
* @returns Whether the value has the current local year and month. Invalid input returns `false`.
|
|
479
|
+
* @remarks Results depend on the runtime's local timezone.
|
|
550
480
|
* @category Util
|
|
551
481
|
*/
|
|
552
|
-
declare function
|
|
553
|
-
/**
|
|
554
|
-
* Alias of `genUniqueNumString`.
|
|
555
|
-
*
|
|
556
|
-
* @hidden
|
|
557
|
-
*/
|
|
558
|
-
declare function generateUniqueNum(n?: number): string;
|
|
482
|
+
declare function isThisMonth(date: MazeyDate): boolean;
|
|
559
483
|
/**
|
|
560
|
-
*
|
|
484
|
+
* Check whether a date is in the current Monday-first local calendar week.
|
|
561
485
|
*
|
|
562
486
|
* Usage:
|
|
563
487
|
*
|
|
564
488
|
* ```javascript
|
|
565
|
-
* import {
|
|
489
|
+
* import { isThisWeek } from "mazey";
|
|
566
490
|
*
|
|
567
|
-
* const ret =
|
|
491
|
+
* const ret = isThisWeek(new Date());
|
|
568
492
|
* console.log(ret);
|
|
569
493
|
* ```
|
|
570
494
|
*
|
|
571
495
|
* Output:
|
|
572
496
|
*
|
|
573
497
|
* ```text
|
|
574
|
-
*
|
|
498
|
+
* true
|
|
575
499
|
* ```
|
|
576
500
|
*
|
|
577
|
-
* @
|
|
501
|
+
* @param date A `Date`, millisecond timestamp, or string accepted by `isValidDate`.
|
|
502
|
+
* @returns Whether the value is in the current local week. Invalid input returns `false`.
|
|
503
|
+
* @remarks The week begins on Monday and ends before the following Monday. Boundaries use local time and a half-open range.
|
|
578
504
|
* @category Util
|
|
579
505
|
*/
|
|
580
|
-
declare function
|
|
506
|
+
declare function isThisWeek(date: MazeyDate): boolean;
|
|
581
507
|
/**
|
|
582
|
-
*
|
|
508
|
+
* Check whether a date is within the current local clock hour.
|
|
583
509
|
*
|
|
584
510
|
* Usage:
|
|
585
511
|
*
|
|
586
512
|
* ```javascript
|
|
587
|
-
* import {
|
|
513
|
+
* import { isThisHour } from "mazey";
|
|
588
514
|
*
|
|
589
|
-
* const
|
|
590
|
-
*
|
|
591
|
-
* console.log(ret1);
|
|
592
|
-
* console.log(ret2);
|
|
515
|
+
* const ret = isThisHour(new Date());
|
|
516
|
+
* console.log(ret);
|
|
593
517
|
* ```
|
|
594
518
|
*
|
|
595
519
|
* Output:
|
|
596
520
|
*
|
|
597
521
|
* ```text
|
|
598
|
-
*
|
|
599
|
-
* 20.00%
|
|
522
|
+
* true
|
|
600
523
|
* ```
|
|
601
524
|
*
|
|
602
|
-
* @param
|
|
603
|
-
* @
|
|
604
|
-
* @
|
|
525
|
+
* @param date A `Date`, millisecond timestamp, or string accepted by `isValidDate`.
|
|
526
|
+
* @returns Whether the value has the current local year, month, day, and hour. Invalid input returns `false`.
|
|
527
|
+
* @remarks Minutes, seconds, and milliseconds are ignored. Results depend on the runtime's local timezone.
|
|
605
528
|
* @category Util
|
|
606
529
|
*/
|
|
607
|
-
declare function
|
|
530
|
+
declare function isThisHour(date: MazeyDate): boolean;
|
|
608
531
|
/**
|
|
609
|
-
* Format
|
|
532
|
+
* Format the absolute distance from a date to now in concise English words.
|
|
610
533
|
*
|
|
611
534
|
* Usage:
|
|
612
535
|
*
|
|
613
536
|
* ```javascript
|
|
614
|
-
* import {
|
|
537
|
+
* import { formatDistanceToNow } from "mazey";
|
|
615
538
|
*
|
|
616
|
-
* const
|
|
617
|
-
*
|
|
618
|
-
* console.log(ret1);
|
|
619
|
-
* console.log(ret2);
|
|
539
|
+
* const ret = formatDistanceToNow(new Date(Date.now() - 60 * 60 * 1000));
|
|
540
|
+
* console.log(ret);
|
|
620
541
|
* ```
|
|
621
542
|
*
|
|
622
543
|
* Output:
|
|
623
544
|
*
|
|
624
545
|
* ```text
|
|
625
|
-
*
|
|
626
|
-
* 0.20
|
|
546
|
+
* about 1 hour
|
|
627
547
|
* ```
|
|
628
548
|
*
|
|
629
|
-
* @param
|
|
630
|
-
* @
|
|
631
|
-
* @
|
|
549
|
+
* @param date A `Date`, millisecond timestamp, or string accepted by `isValidDate`.
|
|
550
|
+
* @returns The absolute approximate distance phrase, or an empty string for invalid input.
|
|
551
|
+
* @remarks Past and future dates use the same wording without `ago` or `in`. Months and years use fixed approximate durations of 30 and 365 days.
|
|
632
552
|
* @category Util
|
|
633
553
|
*/
|
|
634
|
-
declare function
|
|
554
|
+
declare function formatDistanceToNow(date: MazeyDate): string;
|
|
635
555
|
/**
|
|
636
|
-
*
|
|
556
|
+
* Return the formatted date string in the given format.
|
|
557
|
+
*
|
|
558
|
+
* Supported format tokens:
|
|
559
|
+
*
|
|
560
|
+
* | Token | Meaning | Range or example |
|
|
561
|
+
* | ------ | -------------------------------------- | ---------------- |
|
|
562
|
+
* | `yyyy` | Four-digit year | `2022` |
|
|
563
|
+
* | `MM` | Two-digit month | `01`–`12` |
|
|
564
|
+
* | `dd` | Two-digit day of the month | `01`–`31` |
|
|
565
|
+
* | `HH` | Two-digit hour using the 24-hour clock | `00`–`23` |
|
|
566
|
+
* | `hh` | Two-digit hour using the 12-hour clock | `01`–`12` |
|
|
567
|
+
* | `mm` | Two-digit minute | `00`–`59` |
|
|
568
|
+
* | `ss` | Two-digit second | `00`–`59` |
|
|
569
|
+
* | `a` | Uppercase meridiem indicator | `AM` or `PM` |
|
|
570
|
+
*
|
|
571
|
+
* The function creates a native `Date` and reads its local date and time
|
|
572
|
+
* fields. Timestamp output can therefore differ between runtime time zones.
|
|
637
573
|
*
|
|
638
574
|
* Usage:
|
|
639
575
|
*
|
|
640
576
|
* ```javascript
|
|
641
|
-
* import {
|
|
577
|
+
* import { formatDate } from "mazey";
|
|
642
578
|
*
|
|
643
|
-
* const
|
|
644
|
-
*
|
|
645
|
-
*
|
|
579
|
+
* const ret1 = formatDate();
|
|
580
|
+
* const ret2 = formatDate("Tue Jan 11 2022 14:12:26 GMT+0800 (China Standard Time)", "yyyy-MM-dd hh:mm:ss a");
|
|
581
|
+
* const ret3 = formatDate(1641881235000, "yyyy-MM-dd hh:mm:ss a");
|
|
582
|
+
* const ret4 = formatDate(new Date(2014, 1, 11), "MM/dd/yyyy");
|
|
583
|
+
* console.log("Default formatDate value:", ret1);
|
|
584
|
+
* console.log("String formatDate value:", ret2);
|
|
585
|
+
* console.log("Number formatDate value:", ret3);
|
|
586
|
+
* console.log("Date formatDate value:", ret4);
|
|
646
587
|
* ```
|
|
647
588
|
*
|
|
648
|
-
*
|
|
589
|
+
* Output:
|
|
649
590
|
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
591
|
+
* ```text
|
|
592
|
+
* Default formatDate value: 2023-01-11
|
|
593
|
+
* String formatDate value: 2022-01-11 02:12:26 PM
|
|
594
|
+
* Number formatDate value: 2022-01-11 02:07:15 PM
|
|
595
|
+
* Date formatDate value: 02/11/2014
|
|
596
|
+
* ```
|
|
597
|
+
*
|
|
598
|
+
* @param {MazeyDate} dateIns Original date value. Defaults to the current date and time.
|
|
599
|
+
* @param {string} format Format string composed of supported format tokens. Defaults to `yyyy-MM-dd`.
|
|
600
|
+
* @returns {string} The formatted date string.
|
|
601
|
+
* @throws {RangeError} If `dateIns` is not a valid date.
|
|
655
602
|
* @category Util
|
|
656
603
|
*/
|
|
657
|
-
declare function
|
|
658
|
-
leading?: boolean;
|
|
659
|
-
trailing?: boolean;
|
|
660
|
-
}): ThrottleFunc<T>;
|
|
604
|
+
declare function formatDate(dateIns?: MazeyDate, format?: string): string;
|
|
661
605
|
/**
|
|
662
|
-
*
|
|
663
|
-
*
|
|
606
|
+
* Generate a local-time Calendar Versioning string from a date.
|
|
607
|
+
*
|
|
608
|
+
* The conceptual format is `yyyy.MMdd.HHmmss`. Leading zeroes are removed
|
|
609
|
+
* from each segment to keep numeric Semantic Versioning identifiers valid.
|
|
664
610
|
*
|
|
665
611
|
* Usage:
|
|
666
612
|
*
|
|
667
613
|
* ```javascript
|
|
668
|
-
* import {
|
|
614
|
+
* import { generateCalendarVersion } from "mazey";
|
|
669
615
|
*
|
|
670
|
-
* const
|
|
671
|
-
*
|
|
672
|
-
* }, 1000, true);
|
|
616
|
+
* const ret = generateCalendarVersion(new Date(2026, 6, 11, 7, 40, 35));
|
|
617
|
+
* console.log(ret);
|
|
673
618
|
* ```
|
|
674
619
|
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
620
|
+
* Output:
|
|
621
|
+
*
|
|
622
|
+
* ```text
|
|
623
|
+
* 2026.711.74035
|
|
624
|
+
* ```
|
|
625
|
+
*
|
|
626
|
+
* @param {MazeyDate} dateIns Original date. Defaults to the current date.
|
|
627
|
+
* @returns {string} Return the generated calendar version.
|
|
628
|
+
* @throws {RangeError} If `dateIns` is not a valid date.
|
|
679
629
|
* @category Util
|
|
680
630
|
*/
|
|
681
|
-
declare function
|
|
631
|
+
declare function generateCalendarVersion(dateIns?: MazeyDate): string;
|
|
632
|
+
|
|
682
633
|
/**
|
|
683
|
-
*
|
|
634
|
+
* Copy/Clone Object deeply.
|
|
684
635
|
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
* omitting zero-valued units. A zero interval returns `"0 seconds"`. Any other
|
|
688
|
-
* type returns the number of whole seconds. Negative intervals and invalid
|
|
689
|
-
* dates return an empty string.
|
|
636
|
+
* Custom class instances are copied as plain objects containing their own
|
|
637
|
+
* properties. Unsupported native instances are preserved by reference.
|
|
690
638
|
*
|
|
691
639
|
* Usage:
|
|
692
640
|
*
|
|
693
641
|
* ```javascript
|
|
694
|
-
* import {
|
|
642
|
+
* import { deepCopy } from "mazey";
|
|
695
643
|
*
|
|
696
|
-
* const
|
|
697
|
-
* const
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
644
|
+
* const ret1 = deepCopy(["a", "b", "c"]);
|
|
645
|
+
* const ret2 = deepCopy("abc");
|
|
646
|
+
* console.log(ret1);
|
|
647
|
+
* console.log(ret2);
|
|
648
|
+
* ```
|
|
649
|
+
*
|
|
650
|
+
* Output:
|
|
651
|
+
*
|
|
652
|
+
* ```text
|
|
653
|
+
* ["a", "b", "c"]
|
|
654
|
+
* abc
|
|
655
|
+
* ```
|
|
656
|
+
*
|
|
657
|
+
* @param {object} obj The value to clone.
|
|
658
|
+
* @returns {object} Returns the deep cloned value.
|
|
659
|
+
* @category Util
|
|
660
|
+
*/
|
|
661
|
+
declare function deepCopy<T>(obj: T): T;
|
|
662
|
+
/**
|
|
663
|
+
* Recursively freeze an object and its nested enumerable values.
|
|
664
|
+
*
|
|
665
|
+
* Primitive values and objects that are already frozen are returned unchanged.
|
|
666
|
+
*
|
|
667
|
+
* Usage:
|
|
668
|
+
*
|
|
669
|
+
* ```javascript
|
|
670
|
+
* import { deepFreeze } from "mazey";
|
|
671
|
+
*
|
|
672
|
+
* const config = deepFreeze({
|
|
673
|
+
* api: {
|
|
674
|
+
* timeout: 5000,
|
|
675
|
+
* },
|
|
676
|
+
* });
|
|
677
|
+
*
|
|
678
|
+
* console.log(Object.isFrozen(config));
|
|
679
|
+
* console.log(Object.isFrozen(config.api));
|
|
680
|
+
* ```
|
|
681
|
+
*
|
|
682
|
+
* Output:
|
|
683
|
+
*
|
|
684
|
+
* ```text
|
|
685
|
+
* true
|
|
686
|
+
* true
|
|
687
|
+
* ```
|
|
688
|
+
*
|
|
689
|
+
* @param value The value to freeze.
|
|
690
|
+
* @returns The original value with its nested enumerable values frozen.
|
|
691
|
+
* @category Util
|
|
692
|
+
*/
|
|
693
|
+
declare function deepFreeze<T>(value: T): T;
|
|
694
|
+
/**
|
|
695
|
+
* Shallowly assign defined properties from one or more sources.
|
|
696
|
+
*
|
|
697
|
+
* The target is mutated. Only own enumerable string-keyed properties are
|
|
698
|
+
* considered, and `undefined` values are skipped. Other falsy values such as
|
|
699
|
+
* `null`, an empty string, `0`, and `false` are assigned.
|
|
700
|
+
*
|
|
701
|
+
* Usage:
|
|
702
|
+
*
|
|
703
|
+
* ```javascript
|
|
704
|
+
* import { assignDefined } from "mazey";
|
|
705
|
+
*
|
|
706
|
+
* const options = assignDefined(
|
|
707
|
+
* { retries: 3, verbose: true },
|
|
708
|
+
* { retries: undefined, verbose: false },
|
|
702
709
|
* );
|
|
703
|
-
*
|
|
704
|
-
* console.log(
|
|
705
|
-
* console.log(compactText);
|
|
706
|
-
* console.log(dateStringDays);
|
|
710
|
+
*
|
|
711
|
+
* console.log(options);
|
|
707
712
|
* ```
|
|
708
713
|
*
|
|
709
714
|
* Output:
|
|
710
715
|
*
|
|
711
716
|
* ```text
|
|
712
|
-
*
|
|
713
|
-
* 1 day 1 hour 1 minute 1 second
|
|
714
|
-
* 1 day 1 hour 1 minute
|
|
715
|
-
* 1116
|
|
717
|
+
* { retries: 3, verbose: false }
|
|
716
718
|
* ```
|
|
717
719
|
*
|
|
718
|
-
* @param
|
|
719
|
-
* @param
|
|
720
|
-
* @
|
|
721
|
-
* @returns Whole days, whole seconds, an English duration, or an empty string for a negative or invalid interval.
|
|
722
|
-
* @remarks Strings in `YYYY-MM-DD HH:mm:ss` format are normalized and parsed as local time. Other date strings use the runtime's native `Date` parser; use timestamps or ISO strings with an explicit timezone when parsing must be portable.
|
|
720
|
+
* @param target The object to mutate.
|
|
721
|
+
* @param sources Sources applied from left to right.
|
|
722
|
+
* @returns The mutated target.
|
|
723
723
|
* @category Util
|
|
724
724
|
*/
|
|
725
|
-
declare function
|
|
726
|
-
type?: string;
|
|
727
|
-
}): number | string;
|
|
725
|
+
declare function assignDefined<T extends object>(target: T, ...sources: ReadonlyArray<Partial<T> | undefined>): T;
|
|
728
726
|
/**
|
|
729
|
-
* Alias of `
|
|
727
|
+
* Alias of `deepCopy`.
|
|
730
728
|
*
|
|
731
729
|
* @hidden
|
|
732
730
|
*/
|
|
733
|
-
declare function
|
|
734
|
-
type?: string;
|
|
735
|
-
}): number | string;
|
|
731
|
+
declare function deepCopyObject<T>(obj: T): T;
|
|
736
732
|
/**
|
|
737
|
-
*
|
|
733
|
+
* Convert CamelCase to KebabCase.
|
|
738
734
|
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
735
|
+
* Usage:
|
|
736
|
+
*
|
|
737
|
+
* ```javascript
|
|
738
|
+
* import { convertCamelToKebab } from "mazey";
|
|
739
|
+
*
|
|
740
|
+
* const ret1 = convertCamelToKebab("ABC");
|
|
741
|
+
* const ret2 = convertCamelToKebab("aBC");
|
|
742
|
+
* console.log(ret1);
|
|
743
|
+
* console.log(ret2);
|
|
744
|
+
* ```
|
|
745
|
+
*
|
|
746
|
+
* Output:
|
|
747
|
+
*
|
|
748
|
+
* ```text
|
|
749
|
+
* a-b-c
|
|
750
|
+
* a-b-c
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* @param {string} camelCase "aBC" or "ABC"
|
|
754
|
+
* @returns {string} "a-b-c"
|
|
755
|
+
* @category Util
|
|
756
|
+
*/
|
|
757
|
+
declare function convertCamelToKebab(camelCase: string): string;
|
|
758
|
+
/**
|
|
759
|
+
* Convert KebabCase to CamelCase.
|
|
741
760
|
*
|
|
742
761
|
* Usage:
|
|
743
762
|
*
|
|
744
763
|
* ```javascript
|
|
745
|
-
* import {
|
|
764
|
+
* import { convertKebabToCamel } from "mazey";
|
|
746
765
|
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* formatDurationFromMs(129600000); // "1.5 days"
|
|
766
|
+
* const ret1 = convertKebabToCamel("a-b-c");
|
|
767
|
+
* const ret2 = convertKebabToCamel("a-bb-cc");
|
|
768
|
+
* console.log(ret1, ret2);
|
|
751
769
|
* ```
|
|
752
770
|
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
771
|
+
* Output:
|
|
772
|
+
*
|
|
773
|
+
* ```text
|
|
774
|
+
* aBC aBbCc
|
|
775
|
+
* ```
|
|
776
|
+
*
|
|
777
|
+
* @param {string} kebabCase "a-bb-cc"
|
|
778
|
+
* @returns {string} "aBbCc"
|
|
755
779
|
* @category Util
|
|
756
780
|
*/
|
|
757
|
-
declare function
|
|
781
|
+
declare function convertKebabToCamel(kebabCase: string): string;
|
|
758
782
|
/**
|
|
759
|
-
*
|
|
783
|
+
* Alias of `convertCamelToKebab`.
|
|
784
|
+
*
|
|
785
|
+
* @hidden
|
|
786
|
+
*/
|
|
787
|
+
declare function camelCaseToKebabCase(camelCase: string): string;
|
|
788
|
+
/**
|
|
789
|
+
* Convert CamelCase to Underscore.
|
|
760
790
|
*
|
|
761
791
|
* Usage:
|
|
762
792
|
*
|
|
763
793
|
* ```javascript
|
|
764
|
-
* import {
|
|
794
|
+
* import { convertCamelToUnder } from "mazey";
|
|
765
795
|
*
|
|
766
|
-
* const ret1 =
|
|
767
|
-
* const ret2 =
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
* const ret4 = isNumber(Infinity, { isInfinityAsNumber: true });
|
|
771
|
-
* const ret5 = isNumber(NaN);
|
|
772
|
-
* const ret6 = isNumber(NaN, { isNaNAsNumber: true, isInfinityAsNumber: true });
|
|
773
|
-
* console.log(ret1, ret2, ret3, ret4, ret5, ret6);
|
|
796
|
+
* const ret1 = convertCamelToUnder("ABC");
|
|
797
|
+
* const ret2 = convertCamelToUnder("aBC");
|
|
798
|
+
* console.log(ret1);
|
|
799
|
+
* console.log(ret2);
|
|
774
800
|
* ```
|
|
775
801
|
*
|
|
776
802
|
* Output:
|
|
777
803
|
*
|
|
778
804
|
* ```text
|
|
779
|
-
*
|
|
805
|
+
* a_b_c
|
|
806
|
+
* a_b_c
|
|
780
807
|
* ```
|
|
781
808
|
*
|
|
782
|
-
* @param {
|
|
783
|
-
* @
|
|
784
|
-
* @returns {boolean} Whether the value is an allowed number.
|
|
809
|
+
* @param {string} camelCase "aBC" or "ABC"
|
|
810
|
+
* @returns {string} "a_b_c"
|
|
785
811
|
* @category Util
|
|
786
812
|
*/
|
|
787
|
-
declare function
|
|
813
|
+
declare function convertCamelToUnder(camelCase: string): string;
|
|
788
814
|
/**
|
|
789
|
-
*
|
|
815
|
+
* Convert Underscore to CamelCase.
|
|
790
816
|
*
|
|
791
817
|
* Usage:
|
|
792
818
|
*
|
|
793
819
|
* ```javascript
|
|
794
|
-
* import {
|
|
820
|
+
* import { convertUnderToCamel } from "mazey";
|
|
795
821
|
*
|
|
796
|
-
* const
|
|
797
|
-
*
|
|
798
|
-
*
|
|
822
|
+
* const ret1 = convertUnderToCamel("a_b_c");
|
|
823
|
+
* const ret2 = convertUnderToCamel("a_bb_cc");
|
|
824
|
+
* console.log(ret1, ret2);
|
|
799
825
|
* ```
|
|
800
826
|
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
827
|
+
* Output:
|
|
828
|
+
*
|
|
829
|
+
* ```text
|
|
830
|
+
* aBC aBbCc
|
|
831
|
+
* ```
|
|
832
|
+
*
|
|
833
|
+
* @param {string} underCase "a_bb_cc"
|
|
834
|
+
* @returns {string} "aBbCc"
|
|
804
835
|
* @category Util
|
|
805
836
|
*/
|
|
806
|
-
declare function
|
|
837
|
+
declare function convertUnderToCamel(underCase: string): string;
|
|
807
838
|
/**
|
|
808
|
-
* Alias of `
|
|
839
|
+
* Alias of `convertCamelToUnder`.
|
|
809
840
|
*
|
|
810
841
|
* @hidden
|
|
811
842
|
*/
|
|
812
|
-
declare function
|
|
843
|
+
declare function camelCase2Underscore(camelCase: string): string;
|
|
813
844
|
/**
|
|
814
|
-
*
|
|
845
|
+
* Convert text to a deterministic uppercase ASCII JavaScript identifier.
|
|
846
|
+
*
|
|
847
|
+
* Characters outside `A-Z`, `a-z`, `0-9`, `_`, and `$` become `_`. A result
|
|
848
|
+
* beginning with a digit is prefixed with `_`; an empty input therefore returns `_`.
|
|
815
849
|
*
|
|
816
850
|
* Usage:
|
|
817
851
|
*
|
|
818
852
|
* ```javascript
|
|
819
|
-
* import {
|
|
853
|
+
* import { toJavaScriptGlobalName } from "mazey";
|
|
820
854
|
*
|
|
821
|
-
* const
|
|
822
|
-
* console.log(
|
|
855
|
+
* const globalName = toJavaScriptGlobalName("@scope/my-library");
|
|
856
|
+
* console.log(globalName);
|
|
823
857
|
* ```
|
|
824
858
|
*
|
|
825
859
|
* Output:
|
|
826
860
|
*
|
|
827
861
|
* ```text
|
|
828
|
-
*
|
|
862
|
+
* _SCOPE_MY_LIBRARY
|
|
829
863
|
* ```
|
|
830
864
|
*
|
|
865
|
+
* @param value Text such as a package name or bundle filename.
|
|
866
|
+
* @returns An uppercase identifier suitable for an IIFE global name.
|
|
867
|
+
* @throws TypeError when `value` is not a string.
|
|
831
868
|
* @category Util
|
|
832
869
|
*/
|
|
833
|
-
declare function
|
|
870
|
+
declare function toJavaScriptGlobalName(value: string): string;
|
|
834
871
|
/**
|
|
835
|
-
*
|
|
872
|
+
* Remove leading and trailing whitespace or specified characters from string.
|
|
873
|
+
*
|
|
874
|
+
* Note: This method is used to replace the native `String.prototype.trim()`. But it is not necessary to use it in modern browsers.
|
|
836
875
|
*
|
|
837
876
|
* Usage:
|
|
838
877
|
*
|
|
839
878
|
* ```javascript
|
|
840
|
-
* import {
|
|
879
|
+
* import { mTrim } from "mazey";
|
|
841
880
|
*
|
|
842
|
-
* const ret1 =
|
|
843
|
-
* const ret2 =
|
|
844
|
-
*
|
|
845
|
-
*
|
|
881
|
+
* const ret1 = mTrim(" 1 2 3 ");
|
|
882
|
+
* const ret2 = mTrim("abc ");
|
|
883
|
+
* console.log(ret1);
|
|
884
|
+
* console.log(ret2);
|
|
885
|
+
* ```
|
|
846
886
|
*
|
|
847
|
-
*
|
|
887
|
+
* Output:
|
|
888
|
+
*
|
|
889
|
+
* ```text
|
|
890
|
+
* 1 2 3
|
|
891
|
+
* abc
|
|
892
|
+
* ```
|
|
893
|
+
*
|
|
894
|
+
* @param {string} str The string to trim.
|
|
895
|
+
* @returns {string} Trimmed string.
|
|
896
|
+
* @category Util
|
|
897
|
+
* @hidden
|
|
898
|
+
*/
|
|
899
|
+
declare function mTrim(str: string): string;
|
|
900
|
+
/**
|
|
901
|
+
* Check whether it is a valid JSON string.
|
|
902
|
+
*
|
|
903
|
+
* Usage:
|
|
904
|
+
*
|
|
905
|
+
* ```javascript
|
|
906
|
+
* import { isJSONString } from "mazey";
|
|
907
|
+
*
|
|
908
|
+
* const ret1 = isJSONString(`['a', 'b', 'c']`);
|
|
909
|
+
* const ret2 = isJSONString(`["a", "b", "c"]`);
|
|
910
|
+
* console.log(ret1);
|
|
911
|
+
* console.log(ret2);
|
|
848
912
|
* ```
|
|
849
913
|
*
|
|
850
914
|
* Output:
|
|
851
915
|
*
|
|
852
916
|
* ```text
|
|
853
|
-
*
|
|
917
|
+
* false
|
|
918
|
+
* true
|
|
854
919
|
* ```
|
|
855
920
|
*
|
|
856
|
-
* @param {
|
|
857
|
-
* @returns {boolean} Return
|
|
921
|
+
* @param {string} str The string to check.
|
|
922
|
+
* @returns {boolean} Return the result of checking.
|
|
858
923
|
* @category Util
|
|
859
924
|
*/
|
|
860
|
-
declare function
|
|
925
|
+
declare function isJSONString(str: string): boolean;
|
|
861
926
|
/**
|
|
862
|
-
*
|
|
927
|
+
* Alias of `isJSONString`.
|
|
928
|
+
*
|
|
929
|
+
* @hidden
|
|
930
|
+
*/
|
|
931
|
+
declare function isJsonString(str: string): boolean;
|
|
932
|
+
/**
|
|
933
|
+
* Parse a JSON string and return a caller-defined fallback when parsing fails.
|
|
863
934
|
*
|
|
864
935
|
* Usage:
|
|
865
936
|
*
|
|
866
937
|
* ```javascript
|
|
867
|
-
* import {
|
|
868
|
-
*
|
|
869
|
-
* const ret1 = isFunction(() => {});
|
|
870
|
-
* const ret2 = isFunction("abc");
|
|
871
|
-
* const ret3 = isFunction(null);
|
|
872
|
-
* console.log(ret1, ret2, ret3);
|
|
873
|
-
* ```
|
|
874
|
-
*
|
|
875
|
-
* Output:
|
|
938
|
+
* import { parseJsonSafe } from "mazey";
|
|
876
939
|
*
|
|
877
|
-
*
|
|
878
|
-
*
|
|
940
|
+
* const data = parseJsonSafe('{"enabled":true}');
|
|
941
|
+
* const fallback = parseJsonSafe("invalid", {});
|
|
879
942
|
* ```
|
|
880
943
|
*
|
|
881
|
-
* @param
|
|
882
|
-
* @
|
|
944
|
+
* @param value JSON string to parse.
|
|
945
|
+
* @param fallback Value returned when parsing fails. Defaults to `null`.
|
|
946
|
+
* @returns The parsed JSON value or the supplied fallback.
|
|
883
947
|
* @category Util
|
|
884
948
|
*/
|
|
885
|
-
declare function
|
|
949
|
+
declare function parseJsonSafe<T, F = null>(value: string, fallback?: F): T | F;
|
|
886
950
|
/**
|
|
887
|
-
*
|
|
951
|
+
* Generate a random string of number, `genRndNumString(7)` => "7658495".
|
|
888
952
|
*
|
|
889
953
|
* Usage:
|
|
890
954
|
*
|
|
891
955
|
* ```javascript
|
|
892
|
-
* import {
|
|
956
|
+
* import { genRndNumString } from "mazey";
|
|
893
957
|
*
|
|
894
|
-
* const ret1 =
|
|
895
|
-
* const ret2 =
|
|
896
|
-
*
|
|
897
|
-
* console.log(
|
|
958
|
+
* const ret1 = genRndNumString(4);
|
|
959
|
+
* const ret2 = genRndNumString(7);
|
|
960
|
+
* console.log(ret1);
|
|
961
|
+
* console.log(ret2);
|
|
898
962
|
* ```
|
|
899
963
|
*
|
|
900
964
|
* Output:
|
|
901
965
|
*
|
|
902
966
|
* ```text
|
|
903
|
-
*
|
|
967
|
+
* 9730
|
|
968
|
+
* 2262490
|
|
904
969
|
* ```
|
|
905
970
|
*
|
|
906
|
-
* @param {
|
|
907
|
-
* @returns {
|
|
971
|
+
* @param {number} n Length
|
|
972
|
+
* @returns {string} Return the random string.
|
|
908
973
|
* @category Util
|
|
909
974
|
*/
|
|
910
|
-
declare function
|
|
975
|
+
declare function genRndNumString(n?: number): string;
|
|
911
976
|
/**
|
|
912
|
-
*
|
|
977
|
+
* Alias of `genRndNumString`.
|
|
978
|
+
*
|
|
979
|
+
* @hidden
|
|
980
|
+
*/
|
|
981
|
+
declare function generateRndNum(n?: number): string;
|
|
982
|
+
/**
|
|
983
|
+
* Generate a numeric identifier by combining the current timestamp with a
|
|
984
|
+
* random numeric suffix.
|
|
913
985
|
*
|
|
914
986
|
* Usage:
|
|
915
987
|
*
|
|
916
988
|
* ```javascript
|
|
917
|
-
* import {
|
|
989
|
+
* import { genUniqueNumString } from "mazey";
|
|
918
990
|
*
|
|
919
|
-
* const ret1 =
|
|
920
|
-
* const ret2 =
|
|
921
|
-
*
|
|
922
|
-
*
|
|
923
|
-
* console.log(ret1, ret2, ret3, ret4);
|
|
991
|
+
* const ret1 = genUniqueNumString();
|
|
992
|
+
* const ret2 = genUniqueNumString(3);
|
|
993
|
+
* console.log(ret1);
|
|
994
|
+
* console.log(ret2);
|
|
924
995
|
* ```
|
|
925
996
|
*
|
|
926
997
|
* Output:
|
|
927
998
|
*
|
|
928
999
|
* ```text
|
|
929
|
-
*
|
|
1000
|
+
* 1538324722364123
|
|
1001
|
+
* 1538324722364123
|
|
930
1002
|
* ```
|
|
931
1003
|
*
|
|
932
|
-
* @param {
|
|
933
|
-
* @returns {
|
|
1004
|
+
* @param {number} n Length of the random numeric suffix.
|
|
1005
|
+
* @returns {string} A timestamp-based numeric identifier.
|
|
934
1006
|
* @category Util
|
|
935
1007
|
*/
|
|
936
|
-
declare function
|
|
1008
|
+
declare function genUniqueNumString(n?: number): string;
|
|
937
1009
|
/**
|
|
938
|
-
* Alias of `
|
|
1010
|
+
* Alias of `genUniqueNumString`.
|
|
1011
|
+
*
|
|
1012
|
+
* @hidden
|
|
939
1013
|
*/
|
|
940
|
-
declare function
|
|
1014
|
+
declare function generateUniqueNum(n?: number): string;
|
|
941
1015
|
/**
|
|
942
|
-
*
|
|
1016
|
+
* Convert a floating-point ratio to a percentage string.
|
|
943
1017
|
*
|
|
944
1018
|
* Usage:
|
|
945
1019
|
*
|
|
946
1020
|
* ```javascript
|
|
947
|
-
* import {
|
|
1021
|
+
* import { floatToPercent } from "mazey";
|
|
948
1022
|
*
|
|
949
|
-
* const ret1 =
|
|
950
|
-
* const ret2 =
|
|
951
|
-
*
|
|
952
|
-
* console.log(
|
|
1023
|
+
* const ret1 = floatToPercent(0.2);
|
|
1024
|
+
* const ret2 = floatToPercent(0.2, 2);
|
|
1025
|
+
* console.log(ret1);
|
|
1026
|
+
* console.log(ret2);
|
|
953
1027
|
* ```
|
|
954
1028
|
*
|
|
955
1029
|
* Output:
|
|
956
1030
|
*
|
|
957
1031
|
* ```text
|
|
958
|
-
*
|
|
1032
|
+
* 20%
|
|
1033
|
+
* 20.00%
|
|
959
1034
|
* ```
|
|
960
1035
|
*
|
|
961
|
-
* @param {
|
|
962
|
-
* @
|
|
1036
|
+
* @param {number} num Floating-point ratio to convert.
|
|
1037
|
+
* @param {number} fixSize Number of decimal places in the percentage.
|
|
1038
|
+
* @returns {string} The percentage string.
|
|
963
1039
|
* @category Util
|
|
964
1040
|
*/
|
|
965
|
-
declare function
|
|
1041
|
+
declare function floatToPercent(num: number, fixSize?: number): string;
|
|
966
1042
|
/**
|
|
967
|
-
*
|
|
1043
|
+
* Format a number with a fixed number of decimal places.
|
|
968
1044
|
*
|
|
969
1045
|
* Usage:
|
|
970
1046
|
*
|
|
971
1047
|
* ```javascript
|
|
972
|
-
* import {
|
|
1048
|
+
* import { floatFixed } from "mazey";
|
|
973
1049
|
*
|
|
974
|
-
* const ret1 =
|
|
975
|
-
* const ret2 =
|
|
976
|
-
*
|
|
977
|
-
*
|
|
978
|
-
* console.log(ret1, ret2, ret3, ret4);
|
|
1050
|
+
* const ret1 = floatFixed(0.2);
|
|
1051
|
+
* const ret2 = floatFixed(0.2, 2);
|
|
1052
|
+
* console.log(ret1);
|
|
1053
|
+
* console.log(ret2);
|
|
979
1054
|
* ```
|
|
980
1055
|
*
|
|
981
1056
|
* Output:
|
|
982
1057
|
*
|
|
983
1058
|
* ```text
|
|
984
|
-
*
|
|
1059
|
+
* 0
|
|
1060
|
+
* 0.20
|
|
985
1061
|
* ```
|
|
986
1062
|
*
|
|
987
|
-
* @param
|
|
988
|
-
* @
|
|
1063
|
+
* @param num Number or numeric string to format.
|
|
1064
|
+
* @param size Number of decimal places.
|
|
1065
|
+
* @returns The fixed-point string.
|
|
989
1066
|
* @category Util
|
|
990
1067
|
*/
|
|
991
|
-
declare function
|
|
1068
|
+
declare function floatFixed(num: number | string, size?: number): string;
|
|
992
1069
|
/**
|
|
993
|
-
*
|
|
1070
|
+
* Limit how frequently a function can be invoked over time.
|
|
994
1071
|
*
|
|
995
1072
|
* Usage:
|
|
996
1073
|
*
|
|
997
1074
|
* ```javascript
|
|
998
|
-
* import {
|
|
1075
|
+
* import { throttle } from "mazey";
|
|
999
1076
|
*
|
|
1000
|
-
* const
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
* const ret4 = isNonEmptyObject(null);
|
|
1004
|
-
* console.log(ret1, ret2, ret3, ret4);
|
|
1077
|
+
* const foo = throttle(() => {
|
|
1078
|
+
* console.log("The function will be invoked at most once per every wait 1000 milliseconds.");
|
|
1079
|
+
* }, 1000, { leading: true });
|
|
1005
1080
|
* ```
|
|
1006
1081
|
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1009
|
-
* ```text
|
|
1010
|
-
* true false false false
|
|
1011
|
-
* ```
|
|
1082
|
+
* Reference: [Lodash](https://lodash.com/docs/4.17.15#throttle)
|
|
1012
1083
|
*
|
|
1013
|
-
* @param
|
|
1014
|
-
* @
|
|
1084
|
+
* @param func Function to throttle.
|
|
1085
|
+
* @param wait Minimum interval between invocations, in milliseconds.
|
|
1086
|
+
* @param options.leading Whether to invoke on the leading edge.
|
|
1087
|
+
* @param options.trailing Whether to invoke on the trailing edge.
|
|
1088
|
+
* @returns The throttled function.
|
|
1089
|
+
* @category Util
|
|
1015
1090
|
*/
|
|
1016
|
-
declare function
|
|
1091
|
+
declare function throttle<T extends (...args: MazeyFnParams) => MazeyFnReturn>(func: T, wait: number, options?: {
|
|
1092
|
+
leading?: boolean;
|
|
1093
|
+
trailing?: boolean;
|
|
1094
|
+
}): ThrottleFunc<T>;
|
|
1017
1095
|
/**
|
|
1018
|
-
*
|
|
1096
|
+
* Delay function execution until the specified time has passed since the last
|
|
1097
|
+
* invocation.
|
|
1019
1098
|
*
|
|
1020
1099
|
* Usage:
|
|
1021
1100
|
*
|
|
1022
1101
|
* ```javascript
|
|
1023
|
-
* import {
|
|
1024
|
-
*
|
|
1025
|
-
* const ret1 = convertToHtmlBreaks("a\nb\nc");
|
|
1026
|
-
* const ret2 = convertToHtmlBreaks("a\n\nbc");
|
|
1027
|
-
* console.log(ret1);
|
|
1028
|
-
* console.log(ret2);
|
|
1029
|
-
* ```
|
|
1030
|
-
*
|
|
1031
|
-
* Output:
|
|
1102
|
+
* import { debounce } from "mazey";
|
|
1032
1103
|
*
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1035
|
-
*
|
|
1104
|
+
* const foo = debounce(() => {
|
|
1105
|
+
* console.log("The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.");
|
|
1106
|
+
* }, 1000, true);
|
|
1036
1107
|
* ```
|
|
1037
1108
|
*
|
|
1038
|
-
* @param
|
|
1039
|
-
* @
|
|
1109
|
+
* @param func Function to debounce.
|
|
1110
|
+
* @param wait Delay after the last invocation, in milliseconds.
|
|
1111
|
+
* @param immediate Whether to invoke on the leading edge instead.
|
|
1112
|
+
* @returns The debounced function.
|
|
1040
1113
|
* @category Util
|
|
1041
1114
|
*/
|
|
1042
|
-
declare function
|
|
1043
|
-
/**
|
|
1044
|
-
* Alias of `convertToHtmlBreaks`.
|
|
1045
|
-
*
|
|
1046
|
-
* @hidden
|
|
1047
|
-
*/
|
|
1048
|
-
declare function newLine(str: string): string;
|
|
1115
|
+
declare function debounce<T extends (...args: MazeyFnParams) => MazeyFnReturn>(func: T, wait: number, immediate?: boolean): DebounceFunc<T>;
|
|
1049
1116
|
/**
|
|
1050
|
-
*
|
|
1117
|
+
* Check whether a value is a number allowed by the supplied options.
|
|
1051
1118
|
*
|
|
1052
1119
|
* Usage:
|
|
1053
1120
|
*
|
|
1054
1121
|
* ```javascript
|
|
1055
|
-
* import {
|
|
1122
|
+
* import { isNumber } from "mazey";
|
|
1056
1123
|
*
|
|
1057
|
-
* const
|
|
1058
|
-
*
|
|
1124
|
+
* const ret1 = isNumber(123);
|
|
1125
|
+
* const ret2 = isNumber("123");
|
|
1126
|
+
* // Default: NaN, Infinity is not Number
|
|
1127
|
+
* const ret3 = isNumber(Infinity);
|
|
1128
|
+
* const ret4 = isNumber(Infinity, { isInfinityAsNumber: true });
|
|
1129
|
+
* const ret5 = isNumber(NaN);
|
|
1130
|
+
* const ret6 = isNumber(NaN, { isNaNAsNumber: true, isInfinityAsNumber: true });
|
|
1131
|
+
* console.log(ret1, ret2, ret3, ret4, ret5, ret6);
|
|
1059
1132
|
* ```
|
|
1060
1133
|
*
|
|
1061
1134
|
* Output:
|
|
1062
1135
|
*
|
|
1063
1136
|
* ```text
|
|
1064
|
-
*
|
|
1137
|
+
* true false false true false true
|
|
1065
1138
|
* ```
|
|
1066
1139
|
*
|
|
1067
|
-
* @param {
|
|
1068
|
-
* @
|
|
1140
|
+
* @param {*} num Value to check.
|
|
1141
|
+
* @param options Controls whether `NaN`, `Infinity`, or other non-finite values count as numbers.
|
|
1142
|
+
* @returns {boolean} Whether the value is an allowed number.
|
|
1069
1143
|
* @category Util
|
|
1070
1144
|
*/
|
|
1071
|
-
declare function
|
|
1072
|
-
removeNewLine?: boolean;
|
|
1073
|
-
}): string;
|
|
1145
|
+
declare function isNumber(num: unknown, options?: IsNumberOptions): boolean;
|
|
1074
1146
|
/**
|
|
1075
|
-
*
|
|
1147
|
+
* Invoke a value only when it is a function.
|
|
1076
1148
|
*
|
|
1077
|
-
*
|
|
1078
|
-
*/
|
|
1079
|
-
declare function removeHtml(str: string, options?: {
|
|
1080
|
-
removeNewLine?: boolean;
|
|
1081
|
-
}): string;
|
|
1082
|
-
/**
|
|
1083
|
-
* Alias of `removeHTML`.
|
|
1149
|
+
* Usage:
|
|
1084
1150
|
*
|
|
1085
|
-
*
|
|
1151
|
+
* ```javascript
|
|
1152
|
+
* import { invokeFn } from "mazey";
|
|
1153
|
+
*
|
|
1154
|
+
* const ret = invokeFn(() => {
|
|
1155
|
+
* console.log("invokeFn");
|
|
1156
|
+
* });
|
|
1157
|
+
* ```
|
|
1158
|
+
*
|
|
1159
|
+
* @param {function} fn Potential function to invoke.
|
|
1160
|
+
* @param params Arguments passed to the function.
|
|
1161
|
+
* @returns The function result, or `null` when `fn` is not callable.
|
|
1162
|
+
* @category Util
|
|
1086
1163
|
*/
|
|
1087
|
-
declare function
|
|
1088
|
-
removeNewLine?: boolean;
|
|
1089
|
-
}): string;
|
|
1164
|
+
declare function invokeFn(fn: MazeyFunction | null | undefined, ...params: Parameters<MazeyFunction>): ReturnType<MazeyFunction> | null;
|
|
1090
1165
|
/**
|
|
1091
|
-
* Alias of `
|
|
1166
|
+
* Alias of `invokeFn`.
|
|
1092
1167
|
*
|
|
1093
1168
|
* @hidden
|
|
1094
1169
|
*/
|
|
1095
|
-
declare function
|
|
1096
|
-
removeNewLine?: boolean;
|
|
1097
|
-
}): string;
|
|
1170
|
+
declare function doFn(fn: MazeyFunction | null | undefined, ...params: Parameters<MazeyFunction>): ReturnType<MazeyFunction> | null;
|
|
1098
1171
|
/**
|
|
1099
|
-
*
|
|
1172
|
+
* Verify the validity of a non-empty array.
|
|
1100
1173
|
*
|
|
1101
1174
|
* Usage:
|
|
1102
1175
|
*
|
|
1103
1176
|
* ```javascript
|
|
1104
|
-
* import {
|
|
1177
|
+
* import { isNonEmptyArray } from "mazey";
|
|
1105
1178
|
*
|
|
1106
|
-
* const ret =
|
|
1179
|
+
* const ret = isNonEmptyArray([1, 2, 3]);
|
|
1107
1180
|
* console.log(ret);
|
|
1108
1181
|
* ```
|
|
1109
1182
|
*
|
|
1110
1183
|
* Output:
|
|
1111
1184
|
*
|
|
1112
1185
|
* ```text
|
|
1113
|
-
*
|
|
1186
|
+
* true
|
|
1114
1187
|
* ```
|
|
1115
1188
|
*
|
|
1116
|
-
* @param input - The input string to sanitize
|
|
1117
|
-
* @returns The sanitized input string
|
|
1118
1189
|
* @category Util
|
|
1119
1190
|
*/
|
|
1120
|
-
declare function
|
|
1191
|
+
declare function isNonEmptyArray<T>(arr: Array<T>): boolean;
|
|
1121
1192
|
/**
|
|
1122
|
-
*
|
|
1193
|
+
* Verify the validity of a pure object.
|
|
1123
1194
|
*
|
|
1124
1195
|
* Usage:
|
|
1125
1196
|
*
|
|
1126
1197
|
* ```javascript
|
|
1127
|
-
* import {
|
|
1198
|
+
* import { isPureObject } from "mazey";
|
|
1128
1199
|
*
|
|
1129
|
-
* const
|
|
1130
|
-
*
|
|
1200
|
+
* const ret1 = isPureObject({ a: 1 });
|
|
1201
|
+
* const ret2 = isPureObject("abc");
|
|
1202
|
+
* const ret3 = isPureObject(null);
|
|
1203
|
+
* const ret4 = isPureObject([]);
|
|
1204
|
+
*
|
|
1205
|
+
* console.log(ret1, ret2, ret3, ret4);
|
|
1131
1206
|
* ```
|
|
1132
1207
|
*
|
|
1133
1208
|
* Output:
|
|
1134
1209
|
*
|
|
1135
1210
|
* ```text
|
|
1136
|
-
*
|
|
1211
|
+
* true false false false
|
|
1137
1212
|
* ```
|
|
1138
1213
|
*
|
|
1139
|
-
* @param
|
|
1140
|
-
* @returns
|
|
1214
|
+
* @param {MazeyObject} obj The object to verify.
|
|
1215
|
+
* @returns {boolean} Return TRUE if the object is a pure object.
|
|
1141
1216
|
* @category Util
|
|
1142
1217
|
*/
|
|
1143
|
-
declare function
|
|
1144
|
-
/**
|
|
1145
|
-
* Alias of `unsanitizeInput`.
|
|
1146
|
-
*
|
|
1147
|
-
* @hidden
|
|
1148
|
-
*/
|
|
1149
|
-
declare function unsanitize(str: string): string;
|
|
1218
|
+
declare function isPureObject(obj: MazeyObject): boolean;
|
|
1150
1219
|
/**
|
|
1151
|
-
*
|
|
1152
|
-
* units.
|
|
1220
|
+
* Verify the validity of a function.
|
|
1153
1221
|
*
|
|
1154
1222
|
* Usage:
|
|
1155
1223
|
*
|
|
1156
1224
|
* ```javascript
|
|
1157
|
-
* import {
|
|
1225
|
+
* import { isFunction } from "mazey";
|
|
1158
1226
|
*
|
|
1159
|
-
* const
|
|
1160
|
-
*
|
|
1227
|
+
* const ret1 = isFunction(() => {});
|
|
1228
|
+
* const ret2 = isFunction("abc");
|
|
1229
|
+
* const ret3 = isFunction(null);
|
|
1230
|
+
* console.log(ret1, ret2, ret3);
|
|
1161
1231
|
* ```
|
|
1162
1232
|
*
|
|
1163
1233
|
* Output:
|
|
1164
1234
|
*
|
|
1165
1235
|
* ```text
|
|
1166
|
-
*
|
|
1236
|
+
* true false false
|
|
1167
1237
|
* ```
|
|
1168
1238
|
*
|
|
1169
|
-
* @param {
|
|
1170
|
-
* @
|
|
1171
|
-
* @param {boolean} options.hasDot Whether to append truncation text.
|
|
1172
|
-
* @param {string} options.dotText Text appended when truncation occurs.
|
|
1173
|
-
* @returns {string} The truncated string.
|
|
1239
|
+
* @param {MazeyObject} fn The function to verify.
|
|
1240
|
+
* @returns {boolean} Return TRUE if the object is a function.
|
|
1174
1241
|
* @category Util
|
|
1175
1242
|
*/
|
|
1176
|
-
declare function
|
|
1177
|
-
hasDot?: boolean;
|
|
1178
|
-
dotText?: string;
|
|
1179
|
-
}): string;
|
|
1243
|
+
declare function isFunction(fn: MazeyObject): boolean;
|
|
1180
1244
|
/**
|
|
1181
|
-
*
|
|
1245
|
+
* Verify the validity of a string.
|
|
1182
1246
|
*
|
|
1183
1247
|
* Usage:
|
|
1184
1248
|
*
|
|
1185
1249
|
* ```javascript
|
|
1186
|
-
* import {
|
|
1250
|
+
* import { isString } from "mazey";
|
|
1187
1251
|
*
|
|
1188
|
-
* const
|
|
1189
|
-
*
|
|
1252
|
+
* const ret1 = isString("abc");
|
|
1253
|
+
* const ret2 = isString({ a: 1 });
|
|
1254
|
+
* const ret3 = isString(null);
|
|
1255
|
+
* console.log(ret1, ret2, ret3);
|
|
1190
1256
|
* ```
|
|
1191
1257
|
*
|
|
1192
1258
|
* Output:
|
|
1193
1259
|
*
|
|
1194
1260
|
* ```text
|
|
1195
|
-
*
|
|
1261
|
+
* true false false
|
|
1196
1262
|
* ```
|
|
1197
1263
|
*
|
|
1198
|
-
* @param {
|
|
1199
|
-
* @
|
|
1200
|
-
* @
|
|
1201
|
-
* @returns {string} The truncated string.
|
|
1202
|
-
* @hidden
|
|
1264
|
+
* @param {MazeyObject} str The string to verify.
|
|
1265
|
+
* @returns {boolean} Return TRUE if the object is a string.
|
|
1266
|
+
* @category Util
|
|
1203
1267
|
*/
|
|
1204
|
-
declare function
|
|
1268
|
+
declare function isString(str: MazeyObject): boolean;
|
|
1205
1269
|
/**
|
|
1206
|
-
*
|
|
1270
|
+
* Verify the validity of a boolean.
|
|
1207
1271
|
*
|
|
1208
|
-
*
|
|
1209
|
-
*/
|
|
1210
|
-
declare function cutCHSString(str: string | null | undefined, len: number, hasDot?: boolean): string;
|
|
1211
|
-
/**
|
|
1212
|
-
* Verify the validity of axios response.
|
|
1272
|
+
* Usage:
|
|
1213
1273
|
*
|
|
1214
|
-
*
|
|
1274
|
+
* ```javascript
|
|
1275
|
+
* import { isBool } from "mazey";
|
|
1276
|
+
*
|
|
1277
|
+
* const ret1 = isBool(true);
|
|
1278
|
+
* const ret2 = isBool({ a: 1 });
|
|
1279
|
+
* const ret3 = isBool("abc");
|
|
1280
|
+
* const ret4 = isBool(null);
|
|
1281
|
+
* console.log(ret1, ret2, ret3, ret4);
|
|
1282
|
+
* ```
|
|
1283
|
+
*
|
|
1284
|
+
* Output:
|
|
1285
|
+
*
|
|
1286
|
+
* ```text
|
|
1287
|
+
* true false false false
|
|
1288
|
+
* ```
|
|
1215
1289
|
*
|
|
1290
|
+
* @param {MazeyObject} bool The boolean to verify.
|
|
1291
|
+
* @returns {boolean} Return TRUE if the object is a boolean.
|
|
1216
1292
|
* @category Util
|
|
1217
|
-
* @hidden
|
|
1218
1293
|
*/
|
|
1219
|
-
declare function
|
|
1294
|
+
declare function isBool(bool: MazeyObject): boolean;
|
|
1220
1295
|
/**
|
|
1221
|
-
*
|
|
1296
|
+
* Alias of `isBool`.
|
|
1297
|
+
*/
|
|
1298
|
+
declare function isBoolean(bool: MazeyObject): boolean;
|
|
1299
|
+
/**
|
|
1300
|
+
* Verify the validity of a value.
|
|
1222
1301
|
*
|
|
1223
1302
|
* Usage:
|
|
1224
1303
|
*
|
|
1225
1304
|
* ```javascript
|
|
1226
|
-
* import {
|
|
1305
|
+
* import { isUdfOrNul } from "mazey";
|
|
1227
1306
|
*
|
|
1228
|
-
* const
|
|
1229
|
-
*
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
1232
|
-
* }
|
|
1233
|
-
* }
|
|
1234
|
-
* };
|
|
1235
|
-
* const isValidDataResA = isValidData(validData, ["a", "b", "c"], 2333);
|
|
1236
|
-
* const isValidDataResB = isValidData(validData, ["a", "b", "c"], 413);
|
|
1237
|
-
* const isValidDataResC = isValidData(validData, ["d", "d"], 413);
|
|
1238
|
-
* console.log("isValidDataResA:", isValidDataResA);
|
|
1239
|
-
* console.log("isValidDataResB:", isValidDataResB);
|
|
1240
|
-
* console.log("isValidDataResC:", isValidDataResC);
|
|
1307
|
+
* const ret1 = isUdfOrNul(undefined);
|
|
1308
|
+
* const ret2 = isUdfOrNul(null);
|
|
1309
|
+
* const ret3 = isUdfOrNul("abc");
|
|
1310
|
+
* console.log(ret1, ret2, ret3);
|
|
1241
1311
|
* ```
|
|
1242
1312
|
*
|
|
1243
1313
|
* Output:
|
|
1244
1314
|
*
|
|
1245
1315
|
* ```text
|
|
1246
|
-
*
|
|
1247
|
-
* isValidDataResB: true
|
|
1248
|
-
* isValidDataResC: false
|
|
1316
|
+
* true true false
|
|
1249
1317
|
* ```
|
|
1250
1318
|
*
|
|
1251
|
-
* @param {
|
|
1252
|
-
* @
|
|
1253
|
-
* @param {any} validValue Given Value for verifying.
|
|
1254
|
-
* @returns {boolean} Return TRUE if the data is valid.
|
|
1319
|
+
* @param {MazeyObject} val The value to verify.
|
|
1320
|
+
* @returns {boolean} Return TRUE if the object is undefined or null.
|
|
1255
1321
|
* @category Util
|
|
1256
1322
|
*/
|
|
1257
|
-
declare function
|
|
1323
|
+
declare function isUdfOrNul(val: MazeyObject): boolean;
|
|
1258
1324
|
/**
|
|
1259
|
-
*
|
|
1325
|
+
* Verify the validity of an array.
|
|
1260
1326
|
*
|
|
1261
1327
|
* Usage:
|
|
1262
1328
|
*
|
|
1263
1329
|
* ```javascript
|
|
1264
|
-
* import {
|
|
1330
|
+
* import { isArray } from "mazey";
|
|
1265
1331
|
*
|
|
1266
|
-
* const
|
|
1267
|
-
*
|
|
1332
|
+
* const ret1 = isArray([1, 2, 3]);
|
|
1333
|
+
* const ret2 = isArray({ a: 1 });
|
|
1334
|
+
* const ret3 = isArray("abc");
|
|
1335
|
+
* const ret4 = isArray(null);
|
|
1336
|
+
* console.log(ret1, ret2, ret3, ret4);
|
|
1268
1337
|
* ```
|
|
1269
1338
|
*
|
|
1270
1339
|
* Output:
|
|
1271
1340
|
*
|
|
1272
1341
|
* ```text
|
|
1273
|
-
*
|
|
1342
|
+
* true false false false
|
|
1274
1343
|
* ```
|
|
1275
1344
|
*
|
|
1276
|
-
* @param
|
|
1277
|
-
* @returns
|
|
1345
|
+
* @param {MazeyObject} obj The object to verify.
|
|
1346
|
+
* @returns {boolean} Return TRUE if the object is an array.
|
|
1278
1347
|
* @category Util
|
|
1279
1348
|
*/
|
|
1280
|
-
declare function
|
|
1349
|
+
declare function isArray(obj: MazeyObject): boolean;
|
|
1281
1350
|
/**
|
|
1282
|
-
*
|
|
1351
|
+
* Verify the validity of a non-empty object.
|
|
1283
1352
|
*
|
|
1284
1353
|
* Usage:
|
|
1285
1354
|
*
|
|
1286
1355
|
* ```javascript
|
|
1287
|
-
* import {
|
|
1356
|
+
* import { isNonEmptyObject } from "mazey";
|
|
1288
1357
|
*
|
|
1289
|
-
* const
|
|
1290
|
-
*
|
|
1358
|
+
* const ret1 = isNonEmptyObject({ a: 1 });
|
|
1359
|
+
* const ret2 = isNonEmptyObject({});
|
|
1360
|
+
* const ret3 = isNonEmptyObject("abc");
|
|
1361
|
+
* const ret4 = isNonEmptyObject(null);
|
|
1362
|
+
* console.log(ret1, ret2, ret3, ret4);
|
|
1291
1363
|
* ```
|
|
1292
1364
|
*
|
|
1293
1365
|
* Output:
|
|
1294
1366
|
*
|
|
1295
1367
|
* ```text
|
|
1296
|
-
*
|
|
1368
|
+
* true false false false
|
|
1297
1369
|
* ```
|
|
1298
1370
|
*
|
|
1299
|
-
*
|
|
1300
|
-
*
|
|
1301
|
-
* @category Util
|
|
1371
|
+
* @param obj
|
|
1372
|
+
* @returns
|
|
1302
1373
|
*/
|
|
1303
|
-
declare function
|
|
1374
|
+
declare function isNonEmptyObject(obj: MazeyObject): boolean;
|
|
1304
1375
|
/**
|
|
1305
|
-
*
|
|
1376
|
+
* Convert newline characters `\n` into HTML line breaks `<br />`.
|
|
1306
1377
|
*
|
|
1307
1378
|
* Usage:
|
|
1308
1379
|
*
|
|
1309
1380
|
* ```javascript
|
|
1310
|
-
* import {
|
|
1381
|
+
* import { convertToHtmlBreaks } from "mazey";
|
|
1311
1382
|
*
|
|
1312
|
-
* const
|
|
1313
|
-
*
|
|
1383
|
+
* const ret1 = convertToHtmlBreaks("a\nb\nc");
|
|
1384
|
+
* const ret2 = convertToHtmlBreaks("a\n\nbc");
|
|
1385
|
+
* console.log(ret1);
|
|
1386
|
+
* console.log(ret2);
|
|
1314
1387
|
* ```
|
|
1315
1388
|
*
|
|
1316
1389
|
* Output:
|
|
1317
1390
|
*
|
|
1318
1391
|
* ```text
|
|
1319
|
-
*
|
|
1392
|
+
* a<br />b<br />c
|
|
1393
|
+
* a<br /><br />bc
|
|
1320
1394
|
* ```
|
|
1321
1395
|
*
|
|
1322
|
-
* @
|
|
1323
|
-
* @
|
|
1324
|
-
* @returns A promise that resolves to the lowercase hexadecimal digest.
|
|
1325
|
-
* @throws When the required platform API is unavailable. Digest failures are propagated.
|
|
1396
|
+
* @param {string} str The string to make a new line.
|
|
1397
|
+
* @returns {string} A newline with `br`.
|
|
1326
1398
|
* @category Util
|
|
1327
1399
|
*/
|
|
1328
|
-
declare function
|
|
1400
|
+
declare function convertToHtmlBreaks(str: string): string;
|
|
1329
1401
|
/**
|
|
1330
|
-
*
|
|
1331
|
-
*
|
|
1332
|
-
* Valid inputs include `Date` instances, finite millisecond timestamps,
|
|
1333
|
-
* structured local date strings, and ISO 8601 strings with `Z` or a numeric
|
|
1334
|
-
* timezone offset. Structured strings are parsed into numeric components and
|
|
1335
|
-
* validated strictly, so invalid calendar dates are not normalized.
|
|
1402
|
+
* Alias of `convertToHtmlBreaks`.
|
|
1336
1403
|
*
|
|
1337
|
-
*
|
|
1338
|
-
|
|
1339
|
-
|
|
1404
|
+
* @hidden
|
|
1405
|
+
*/
|
|
1406
|
+
declare function newLine(str: string): string;
|
|
1407
|
+
/**
|
|
1408
|
+
* Remove HTML tags from a string, and optionally newline characters.
|
|
1340
1409
|
*
|
|
1341
1410
|
* Usage:
|
|
1342
1411
|
*
|
|
1343
1412
|
* ```javascript
|
|
1344
|
-
* import {
|
|
1345
|
-
*
|
|
1346
|
-
* const ret1 = isValidDate(1577877720000);
|
|
1347
|
-
* const ret2 = isValidDate("2020-01-01 11:22");
|
|
1348
|
-
* const ret3 = isValidDate("2020-02-30");
|
|
1349
|
-
* const ret4 = isValidDate(new Date("invalid"));
|
|
1413
|
+
* import { removeHTML } from "mazey";
|
|
1350
1414
|
*
|
|
1351
|
-
*
|
|
1415
|
+
* const ret = removeHTML("<div>hello world</div>");
|
|
1416
|
+
* console.log(ret);
|
|
1352
1417
|
* ```
|
|
1353
1418
|
*
|
|
1354
1419
|
* Output:
|
|
1355
1420
|
*
|
|
1356
1421
|
* ```text
|
|
1357
|
-
*
|
|
1422
|
+
* hello world
|
|
1358
1423
|
* ```
|
|
1359
1424
|
*
|
|
1360
|
-
* @param
|
|
1361
|
-
* @returns
|
|
1362
|
-
* @category Util
|
|
1425
|
+
* @param {string} str A string that may contain HTML tags.
|
|
1426
|
+
* @returns {string} The string with HTML tags removed.
|
|
1427
|
+
* @category Util
|
|
1428
|
+
*/
|
|
1429
|
+
declare function removeHTML(str: string, options?: {
|
|
1430
|
+
removeNewLine?: boolean;
|
|
1431
|
+
}): string;
|
|
1432
|
+
/**
|
|
1433
|
+
* Alias of `removeHTML`.
|
|
1434
|
+
*
|
|
1435
|
+
* @hidden
|
|
1436
|
+
*/
|
|
1437
|
+
declare function removeHtml(str: string, options?: {
|
|
1438
|
+
removeNewLine?: boolean;
|
|
1439
|
+
}): string;
|
|
1440
|
+
/**
|
|
1441
|
+
* Alias of `removeHTML`.
|
|
1442
|
+
*
|
|
1443
|
+
* @hidden
|
|
1444
|
+
*/
|
|
1445
|
+
declare function clearHTML(str: string, options?: {
|
|
1446
|
+
removeNewLine?: boolean;
|
|
1447
|
+
}): string;
|
|
1448
|
+
/**
|
|
1449
|
+
* Alias of `removeHTML`.
|
|
1450
|
+
*
|
|
1451
|
+
* @hidden
|
|
1363
1452
|
*/
|
|
1364
|
-
declare function
|
|
1453
|
+
declare function clearHtml(str: string, options?: {
|
|
1454
|
+
removeNewLine?: boolean;
|
|
1455
|
+
}): string;
|
|
1365
1456
|
/**
|
|
1366
|
-
*
|
|
1457
|
+
* Sanitizes user input to prevent XSS attacks.
|
|
1367
1458
|
*
|
|
1368
1459
|
* Usage:
|
|
1369
1460
|
*
|
|
1370
1461
|
* ```javascript
|
|
1371
|
-
* import {
|
|
1462
|
+
* import { sanitizeInput } from "mazey";
|
|
1372
1463
|
*
|
|
1373
|
-
* const ret =
|
|
1464
|
+
* const ret = sanitizeInput("<div>hello world</div>");
|
|
1374
1465
|
* console.log(ret);
|
|
1375
1466
|
* ```
|
|
1376
1467
|
*
|
|
1377
1468
|
* Output:
|
|
1378
1469
|
*
|
|
1379
1470
|
* ```text
|
|
1380
|
-
*
|
|
1471
|
+
* <div>hello world</div>
|
|
1381
1472
|
* ```
|
|
1382
1473
|
*
|
|
1383
|
-
* @param
|
|
1384
|
-
* @returns
|
|
1385
|
-
* @remarks Hours, minutes, seconds, and milliseconds are ignored. Results depend on the runtime's local timezone.
|
|
1474
|
+
* @param input - The input string to sanitize
|
|
1475
|
+
* @returns The sanitized input string
|
|
1386
1476
|
* @category Util
|
|
1387
1477
|
*/
|
|
1388
|
-
declare function
|
|
1478
|
+
declare function sanitizeInput(input: string): string;
|
|
1389
1479
|
/**
|
|
1390
|
-
*
|
|
1480
|
+
* Reverses the sanitization done by the `sanitizeInput` function.
|
|
1391
1481
|
*
|
|
1392
1482
|
* Usage:
|
|
1393
1483
|
*
|
|
1394
1484
|
* ```javascript
|
|
1395
|
-
* import {
|
|
1485
|
+
* import { unsanitizeInput } from "mazey";
|
|
1396
1486
|
*
|
|
1397
|
-
* const ret =
|
|
1487
|
+
* const ret = unsanitizeInput("<div>hello world</div>");
|
|
1398
1488
|
* console.log(ret);
|
|
1399
1489
|
* ```
|
|
1400
1490
|
*
|
|
1401
1491
|
* Output:
|
|
1402
1492
|
*
|
|
1403
1493
|
* ```text
|
|
1404
|
-
*
|
|
1494
|
+
* <div>hello world</div>
|
|
1405
1495
|
* ```
|
|
1406
1496
|
*
|
|
1407
|
-
* @param
|
|
1408
|
-
* @returns
|
|
1409
|
-
* @remarks Results depend on the runtime's local timezone.
|
|
1497
|
+
* @param input - The input string to unsanitize
|
|
1498
|
+
* @returns The unsanitized input string
|
|
1410
1499
|
* @category Util
|
|
1411
1500
|
*/
|
|
1412
|
-
declare function
|
|
1501
|
+
declare function unsanitizeInput(input: string): string;
|
|
1413
1502
|
/**
|
|
1414
|
-
*
|
|
1503
|
+
* Alias of `unsanitizeInput`.
|
|
1504
|
+
*
|
|
1505
|
+
* @hidden
|
|
1506
|
+
*/
|
|
1507
|
+
declare function unsanitize(str: string): string;
|
|
1508
|
+
/**
|
|
1509
|
+
* Truncate a string by weighted length, counting non-ASCII characters as two
|
|
1510
|
+
* units.
|
|
1415
1511
|
*
|
|
1416
1512
|
* Usage:
|
|
1417
1513
|
*
|
|
1418
1514
|
* ```javascript
|
|
1419
|
-
* import {
|
|
1515
|
+
* import { cutZHString } from "mazey";
|
|
1420
1516
|
*
|
|
1421
|
-
* const ret =
|
|
1517
|
+
* const ret = cutZHString("hello world", 5);
|
|
1422
1518
|
* console.log(ret);
|
|
1423
1519
|
* ```
|
|
1424
1520
|
*
|
|
1425
1521
|
* Output:
|
|
1426
1522
|
*
|
|
1427
1523
|
* ```text
|
|
1428
|
-
*
|
|
1524
|
+
* hello
|
|
1429
1525
|
* ```
|
|
1430
1526
|
*
|
|
1431
|
-
* @param
|
|
1432
|
-
* @
|
|
1433
|
-
* @
|
|
1527
|
+
* @param {string} str String to truncate.
|
|
1528
|
+
* @param {number} len Maximum weighted length.
|
|
1529
|
+
* @param {boolean} options.hasDot Whether to append truncation text.
|
|
1530
|
+
* @param {string} options.dotText Text appended when truncation occurs.
|
|
1531
|
+
* @returns {string} The truncated string.
|
|
1434
1532
|
* @category Util
|
|
1435
1533
|
*/
|
|
1436
|
-
declare function
|
|
1534
|
+
declare function cutZHString(str: string | null | undefined, len: number, options?: {
|
|
1535
|
+
hasDot?: boolean;
|
|
1536
|
+
dotText?: string;
|
|
1537
|
+
}): string;
|
|
1437
1538
|
/**
|
|
1438
|
-
*
|
|
1539
|
+
* Alias of `cutZHString`.
|
|
1439
1540
|
*
|
|
1440
1541
|
* Usage:
|
|
1441
1542
|
*
|
|
1442
1543
|
* ```javascript
|
|
1443
|
-
* import {
|
|
1544
|
+
* import { truncateZHString } from "mazey";
|
|
1444
1545
|
*
|
|
1445
|
-
* const ret =
|
|
1546
|
+
* const ret = truncateZHString("hello world", 5);
|
|
1446
1547
|
* console.log(ret);
|
|
1447
1548
|
* ```
|
|
1448
1549
|
*
|
|
1449
1550
|
* Output:
|
|
1450
1551
|
*
|
|
1451
1552
|
* ```text
|
|
1452
|
-
*
|
|
1553
|
+
* hello
|
|
1453
1554
|
* ```
|
|
1454
1555
|
*
|
|
1455
|
-
* @param
|
|
1456
|
-
* @
|
|
1457
|
-
* @
|
|
1556
|
+
* @param {string} str String to truncate.
|
|
1557
|
+
* @param {number} len Maximum weighted length.
|
|
1558
|
+
* @param {boolean} hasDot Whether to append the default truncation text.
|
|
1559
|
+
* @returns {string} The truncated string.
|
|
1560
|
+
* @hidden
|
|
1561
|
+
*/
|
|
1562
|
+
declare function truncateZHString(str: string | null | undefined, len: number, hasDot?: boolean): string;
|
|
1563
|
+
/**
|
|
1564
|
+
* Alias of `truncateZHString`.
|
|
1565
|
+
*
|
|
1566
|
+
* @hidden
|
|
1567
|
+
*/
|
|
1568
|
+
declare function cutCHSString(str: string | null | undefined, len: number, hasDot?: boolean): string;
|
|
1569
|
+
/**
|
|
1570
|
+
* Verify the validity of axios response.
|
|
1571
|
+
*
|
|
1572
|
+
* Reference: [Handling Errors](https://axios-http.com/docs/handling_errors)
|
|
1573
|
+
*
|
|
1458
1574
|
* @category Util
|
|
1575
|
+
* @hidden
|
|
1459
1576
|
*/
|
|
1460
|
-
declare function
|
|
1577
|
+
declare function zAxiosIsValidRes(res: ZResResponse | undefined, options?: ZResIsValidResOptions | null): boolean;
|
|
1461
1578
|
/**
|
|
1462
|
-
*
|
|
1579
|
+
* Determine the validity of the data.
|
|
1463
1580
|
*
|
|
1464
1581
|
* Usage:
|
|
1465
1582
|
*
|
|
1466
1583
|
* ```javascript
|
|
1467
|
-
* import {
|
|
1584
|
+
* import { isValidData } from "mazey";
|
|
1468
1585
|
*
|
|
1469
|
-
* const
|
|
1470
|
-
*
|
|
1586
|
+
* const validData = {
|
|
1587
|
+
* a: {
|
|
1588
|
+
* b: {
|
|
1589
|
+
* c: 413
|
|
1590
|
+
* }
|
|
1591
|
+
* }
|
|
1592
|
+
* };
|
|
1593
|
+
* const isValidDataResA = isValidData(validData, ["a", "b", "c"], 2333);
|
|
1594
|
+
* const isValidDataResB = isValidData(validData, ["a", "b", "c"], 413);
|
|
1595
|
+
* const isValidDataResC = isValidData(validData, ["d", "d"], 413);
|
|
1596
|
+
* console.log("isValidDataResA:", isValidDataResA);
|
|
1597
|
+
* console.log("isValidDataResB:", isValidDataResB);
|
|
1598
|
+
* console.log("isValidDataResC:", isValidDataResC);
|
|
1471
1599
|
* ```
|
|
1472
1600
|
*
|
|
1473
1601
|
* Output:
|
|
1474
1602
|
*
|
|
1475
1603
|
* ```text
|
|
1476
|
-
*
|
|
1604
|
+
* isValidDataResA: false
|
|
1605
|
+
* isValidDataResB: true
|
|
1606
|
+
* isValidDataResC: false
|
|
1477
1607
|
* ```
|
|
1478
1608
|
*
|
|
1479
|
-
* @param
|
|
1480
|
-
* @
|
|
1481
|
-
* @
|
|
1609
|
+
* @param {any} data Original Data
|
|
1610
|
+
* @param {string[]} attributes Data Attributes
|
|
1611
|
+
* @param {any} validValue Given Value for verifying.
|
|
1612
|
+
* @returns {boolean} Return TRUE if the data is valid.
|
|
1482
1613
|
* @category Util
|
|
1483
1614
|
*/
|
|
1484
|
-
declare function
|
|
1615
|
+
declare function isValidData(data: MazeyObject, attributes: string[], validValue: SimpleType): boolean;
|
|
1485
1616
|
/**
|
|
1486
|
-
*
|
|
1617
|
+
* Options for formatting a byte count.
|
|
1487
1618
|
*
|
|
1488
|
-
*
|
|
1619
|
+
* @category Util
|
|
1620
|
+
*/
|
|
1621
|
+
interface FormatByteSizeOptions {
|
|
1622
|
+
/** Unit scale. Defaults to `1024`. */
|
|
1623
|
+
base?: 1000 | 1024;
|
|
1624
|
+
/** Decimal places for rounded values. Must be an integer from 0 to 20. Defaults to `1`. */
|
|
1625
|
+
fractionDigits?: number;
|
|
1626
|
+
/** Returned for negative, non-finite, or otherwise invalid input. Defaults to an empty string. */
|
|
1627
|
+
invalidValue?: string;
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Format a non-negative byte count using `B`, `KB`, `MB`, `GB`, or `TB`.
|
|
1489
1631
|
*
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1632
|
+
* Scaling defaults to 1024 with one fractional digit. Byte values omit
|
|
1633
|
+
* insignificant trailing zeroes, while scaled values retain the requested
|
|
1634
|
+
* number of fractional digits. Values beyond terabytes remain expressed in
|
|
1635
|
+
* `TB`.
|
|
1492
1636
|
*
|
|
1493
|
-
*
|
|
1494
|
-
* console.log(ret);
|
|
1495
|
-
* ```
|
|
1637
|
+
* Usage:
|
|
1496
1638
|
*
|
|
1497
|
-
*
|
|
1639
|
+
* ```javascript
|
|
1640
|
+
* import { formatByteSize } from "mazey";
|
|
1498
1641
|
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1642
|
+
* formatByteSize(0); // "0 B"
|
|
1643
|
+
* formatByteSize(1536); // "1.5 KB"
|
|
1644
|
+
* formatByteSize(1500000, { base: 1000, fractionDigits: 2 }); // "1.50 MB"
|
|
1501
1645
|
* ```
|
|
1502
1646
|
*
|
|
1503
|
-
* @param
|
|
1504
|
-
* @
|
|
1505
|
-
* @
|
|
1647
|
+
* @param bytes Byte count to format.
|
|
1648
|
+
* @param options Formatting options.
|
|
1649
|
+
* @returns A formatted byte-size string, or `invalidValue` for invalid input.
|
|
1506
1650
|
* @category Util
|
|
1507
1651
|
*/
|
|
1508
|
-
declare function
|
|
1652
|
+
declare function formatByteSize(bytes: number, options?: FormatByteSizeOptions): string;
|
|
1509
1653
|
/**
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
* Supported format tokens:
|
|
1654
|
+
* Deprecated alias of `formatByteSize`.
|
|
1513
1655
|
*
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
*
|
|
1518
|
-
*
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
*
|
|
1523
|
-
* | `a` | Uppercase meridiem indicator | `AM` or `PM` |
|
|
1524
|
-
*
|
|
1525
|
-
* The function creates a native `Date` and reads its local date and time
|
|
1526
|
-
* fields. Timestamp output can therefore differ between runtime time zones.
|
|
1656
|
+
* @deprecated Use `formatByteSize` instead.
|
|
1657
|
+
* @param size Byte count to format.
|
|
1658
|
+
* @param options Formatting options.
|
|
1659
|
+
* @returns The result of `formatByteSize`.
|
|
1660
|
+
* @category Util
|
|
1661
|
+
*/
|
|
1662
|
+
declare function getFileSize(size: number, options?: FormatByteSizeOptions): string;
|
|
1663
|
+
/**
|
|
1664
|
+
* Generate a Hash Code from a string.
|
|
1527
1665
|
*
|
|
1528
1666
|
* Usage:
|
|
1529
1667
|
*
|
|
1530
1668
|
* ```javascript
|
|
1531
|
-
* import {
|
|
1669
|
+
* import { genHashCode } from "mazey";
|
|
1532
1670
|
*
|
|
1533
|
-
* const
|
|
1534
|
-
*
|
|
1535
|
-
* const ret3 = formatDate(1641881235000, "yyyy-MM-dd hh:mm:ss a");
|
|
1536
|
-
* const ret4 = formatDate(new Date(2014, 1, 11), "MM/dd/yyyy");
|
|
1537
|
-
* console.log("Default formatDate value:", ret1);
|
|
1538
|
-
* console.log("String formatDate value:", ret2);
|
|
1539
|
-
* console.log("Number formatDate value:", ret3);
|
|
1540
|
-
* console.log("Date formatDate value:", ret4);
|
|
1671
|
+
* const ret = genHashCode("hello world");
|
|
1672
|
+
* console.log(ret);
|
|
1541
1673
|
* ```
|
|
1542
1674
|
*
|
|
1543
1675
|
* Output:
|
|
1544
1676
|
*
|
|
1545
1677
|
* ```text
|
|
1546
|
-
*
|
|
1547
|
-
* String formatDate value: 2022-01-11 02:12:26 PM
|
|
1548
|
-
* Number formatDate value: 2022-01-11 02:07:15 PM
|
|
1549
|
-
* Date formatDate value: 02/11/2014
|
|
1678
|
+
* 1794106052
|
|
1550
1679
|
* ```
|
|
1551
1680
|
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
* @returns {string} The formatted date string.
|
|
1555
|
-
* @throws {RangeError} If `dateIns` is not a valid date.
|
|
1681
|
+
* Reference: [Generate a Hash from string in Javascript](https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery)
|
|
1682
|
+
*
|
|
1556
1683
|
* @category Util
|
|
1557
1684
|
*/
|
|
1558
|
-
declare function
|
|
1685
|
+
declare function genHashCode(str: string): number;
|
|
1559
1686
|
/**
|
|
1560
|
-
* Generate a
|
|
1561
|
-
*
|
|
1562
|
-
* The conceptual format is `yyyy.MMdd.HHmmss`. Leading zeroes are removed
|
|
1563
|
-
* from each segment to keep numeric Semantic Versioning identifiers valid.
|
|
1687
|
+
* Generate a lowercase SHA-256 hexadecimal digest with the Web Crypto API.
|
|
1564
1688
|
*
|
|
1565
1689
|
* Usage:
|
|
1566
1690
|
*
|
|
1567
1691
|
* ```javascript
|
|
1568
|
-
* import {
|
|
1692
|
+
* import { sha256Hex } from "mazey";
|
|
1569
1693
|
*
|
|
1570
|
-
* const
|
|
1571
|
-
* console.log(
|
|
1694
|
+
* const digest = await sha256Hex("hello world");
|
|
1695
|
+
* console.log(digest);
|
|
1572
1696
|
* ```
|
|
1573
1697
|
*
|
|
1574
1698
|
* Output:
|
|
1575
1699
|
*
|
|
1576
1700
|
* ```text
|
|
1577
|
-
*
|
|
1701
|
+
* b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
|
|
1578
1702
|
* ```
|
|
1579
1703
|
*
|
|
1580
|
-
* @
|
|
1581
|
-
* @
|
|
1582
|
-
* @
|
|
1704
|
+
* @remarks Requires Web Crypto. String input also requires `TextEncoder`.
|
|
1705
|
+
* @param input Text or binary data to hash.
|
|
1706
|
+
* @returns A promise that resolves to the lowercase hexadecimal digest.
|
|
1707
|
+
* @throws When the required platform API is unavailable. Digest failures are propagated.
|
|
1583
1708
|
* @category Util
|
|
1584
1709
|
*/
|
|
1585
|
-
declare function
|
|
1710
|
+
declare function sha256Hex(input: string | BufferSource): Promise<string>;
|
|
1586
1711
|
/**
|
|
1587
1712
|
* Check if the given string is a mobile phone number.
|
|
1588
1713
|
*
|
|
@@ -3240,6 +3365,79 @@ declare function getTTFB(): Promise<number>;
|
|
|
3240
3365
|
*/
|
|
3241
3366
|
declare function getPerformance(camelCase?: boolean): Promise<WebPerformance>;
|
|
3242
3367
|
|
|
3368
|
+
/**
|
|
3369
|
+
* Conservative visitor classifications detected from supported browser-side
|
|
3370
|
+
* signals.
|
|
3371
|
+
*
|
|
3372
|
+
* - `"crawler"`: a known crawler or automated-fetcher user-agent token matched.
|
|
3373
|
+
* - `"automation"`: an explicit automation user-agent token matched or
|
|
3374
|
+
* `navigator.webdriver` is `true`.
|
|
3375
|
+
* - `"unknown"`: no supported crawler or automation signal was detected.
|
|
3376
|
+
*
|
|
3377
|
+
* `"unknown"` does not mean that the visitor is verified as human.
|
|
3378
|
+
*
|
|
3379
|
+
* @remarks This heuristic result is not suitable for authentication,
|
|
3380
|
+
* authorization, fraud prevention, access control, or other security decisions.
|
|
3381
|
+
* @category Browser Information
|
|
3382
|
+
*/
|
|
3383
|
+
type VisitorType = "crawler" | "automation" | "unknown";
|
|
3384
|
+
/**
|
|
3385
|
+
* Classify a visitor using conservative browser-side heuristics.
|
|
3386
|
+
*
|
|
3387
|
+
* Classification checks known crawler and automated-fetcher user-agent tokens
|
|
3388
|
+
* first. It then checks explicit browser-automation user-agent tokens and
|
|
3389
|
+
* `navigator.webdriver === true`. All other visitors return `"unknown"`.
|
|
3390
|
+
*
|
|
3391
|
+
* `"unknown"` means that no supported signal was detected. It does not verify
|
|
3392
|
+
* that the visitor is human. User-agent values can be modified or spoofed, and
|
|
3393
|
+
* automation signals can be hidden, modified, or unavailable. Both false
|
|
3394
|
+
* positives and false negatives are possible.
|
|
3395
|
+
*
|
|
3396
|
+
* Usage:
|
|
3397
|
+
*
|
|
3398
|
+
* ```typescript
|
|
3399
|
+
* import { detectVisitorType } from "mazey";
|
|
3400
|
+
*
|
|
3401
|
+
* const visitorType = detectVisitorType();
|
|
3402
|
+
* console.log(visitorType);
|
|
3403
|
+
* ```
|
|
3404
|
+
*
|
|
3405
|
+
* Possible output:
|
|
3406
|
+
*
|
|
3407
|
+
* ```text
|
|
3408
|
+
* unknown
|
|
3409
|
+
* ```
|
|
3410
|
+
*
|
|
3411
|
+
* Explicit user-agent:
|
|
3412
|
+
*
|
|
3413
|
+
* ```typescript
|
|
3414
|
+
* const visitorType = detectVisitorType(
|
|
3415
|
+
* "Mozilla/5.0 (compatible; Googlebot/2.1)"
|
|
3416
|
+
* );
|
|
3417
|
+
*
|
|
3418
|
+
* console.log(visitorType);
|
|
3419
|
+
* ```
|
|
3420
|
+
*
|
|
3421
|
+
* Output:
|
|
3422
|
+
*
|
|
3423
|
+
* ```text
|
|
3424
|
+
* crawler
|
|
3425
|
+
* ```
|
|
3426
|
+
*
|
|
3427
|
+
* @param userAgent Optional user-agent string. Defaults to
|
|
3428
|
+
* `navigator.userAgent` when available. An explicit value replaces only the
|
|
3429
|
+
* user-agent source; the current browser's WebDriver signal is still checked.
|
|
3430
|
+
* @returns `"crawler"`, `"automation"`, or `"unknown"`, in that priority.
|
|
3431
|
+
* @throws {TypeError} If an explicitly supplied user agent is not a string.
|
|
3432
|
+
* @remarks Safe during SSR and in Node.js. This is a heuristic classification
|
|
3433
|
+
* utility, not human verification, crawler authentication, or a security
|
|
3434
|
+
* boundary. Do not use it by itself for authentication, authorization,
|
|
3435
|
+
* payments, rate limiting, fraud prevention, access control, or
|
|
3436
|
+
* security-sensitive content. Genuine crawler verification generally requires
|
|
3437
|
+
* server-side request information and provider-specific validation.
|
|
3438
|
+
* @category Browser Information
|
|
3439
|
+
*/
|
|
3440
|
+
declare function detectVisitorType(userAgent?: string): VisitorType;
|
|
3243
3441
|
/**
|
|
3244
3442
|
* Options for {@link isSafePWAEnv}.
|
|
3245
3443
|
*
|
|
@@ -3658,5 +3856,5 @@ declare const mazeyCon: Console;
|
|
|
3658
3856
|
*/
|
|
3659
3857
|
declare const timeCon: Console;
|
|
3660
3858
|
|
|
3661
|
-
export { addClass, addEvent, addStyle, calLongestCommonSubsequence, calLongestCommonSubstring, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertToHtmlBreaks, convertUnderToCamel, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, doFn, extractElementText, fireEvent, floatFixed, floatToPercent, formatDate, formatDistanceToNow, formatDurationFromMs, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionStorage, getTTFB, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, inRate, invokeEvent, invokeFn, isArray, isBool, isBoolean, isBrowser, isFunction, isHit, isJSONString, isJsonString, isNonEmptyArray, isNonEmptyObject, isNumber, isPureObject, isSafePWAEnv, isStandalonePWA, isString, isSupportWebp, isSupportedEntryType, isThisHour, isThisMonth, isThisWeek, isThisYear, isToday, isUdfOrNul, isValidCssSelector, isValidData, isValidDate, isValidEmail, isValidHttpUrl, isValidPhoneNumber, isValidUrl, loadCSS, loadImage, loadScript, loadScriptIfUndefined, longestComSubsequence, longestComSubstring, mNow, mTrim, mazeyCon, newLine, onURLChange, parseGitHubRepository, parseJsonSafe, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalStorage, setSessionStorage, setThemePreference, sha256Hex, sleep, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, windowLoaded, zAxiosIsValidRes };
|
|
3662
|
-
export type { GitHubRepositoryDetails, IsSafePWAEnvOptions, PreferenceResult, ResolvedTheme, ThemePreference };
|
|
3859
|
+
export { addClass, addEvent, addStyle, assignDefined, calLongestCommonSubsequence, calLongestCommonSubstring, calculateCAGR, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHTML, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, convertHttpToHttps, convertKebabToCamel, convertObjectToQuery, convertToHtmlBreaks, convertUnderToCamel, cutCHSString, cutZHString, debounce, deepCopy, deepCopyObject, deepFreeze, delCookie, detectVisitorType, doFn, extractElementText, fireEvent, floatFixed, floatToPercent, formatByteSize, formatDate, formatDistanceToNow, formatDurationFromMs, genBrowserAttrs, genCustomConsole, genHashCode, genRndNumString, genStyleString, genUniqueNumString, generateCalendarVersion, generateRndNum, generateUniqueNum, getAllQueryParams, getBrowserInfo, getCLS, getCookie, getCurrentVersion, getDateDifference, getDefineListeners, getDomain, getFCP, getFID, getFP, getFileSize, getFriendlyInterval, getHashQueryParam, getLCP, getLocalStorage, getPageMeta, getPerformance, getQueryParam, getScriptQueryParam, getSessionStorage, getTTFB, getUrlFileType, getUrlHost, getUrlParam, getUrlPath, hasClass, inRate, invokeEvent, invokeFn, isArray, isBool, isBoolean, isBrowser, isFunction, isHit, isJSONString, isJsonString, isNonEmptyArray, isNonEmptyObject, isNumber, isPureObject, isSafePWAEnv, isStandalonePWA, isString, isSupportWebp, isSupportedEntryType, isThisHour, isThisMonth, isThisWeek, isThisYear, isToday, isUdfOrNul, isValidCssSelector, isValidData, isValidDate, isValidEmail, isValidHttpUrl, isValidPhoneNumber, isValidUrl, loadCSS, loadImage, loadScript, loadScriptIfUndefined, longestComSubsequence, longestComSubstring, mNow, mTrim, mazeyCon, newLine, onURLChange, parseGitHubRepository, parseJsonSafe, removeClass, removeCookie, removeEvent, removeHTML, removeHtml, repeatUntilConditionMet, replaceHttp, resolveLanguagePreference, resolveThemePreference, sanitizeInput, setClass, setCookie, setImgSizeBySrc, setImgWidHeiBySrc, setLanguagePreference, setLocalStorage, setSessionStorage, setThemePreference, sha256Hex, sleep, throttle, timeCon, toJavaScriptGlobalName, truncateZHString, unsanitize, unsanitizeInput, updateQueryParam, waitTime, windowLoaded, zAxiosIsValidRes };
|
|
3860
|
+
export type { FormatByteSizeOptions, GitHubRepositoryDetails, InvestmentReturnRate, IsSafePWAEnvOptions, PreferenceResult, ResolvedTheme, ThemePreference, VisitorType };
|