@daysnap/utils 0.1.32 → 0.1.34
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/docs/classes/Poller.md +9 -9
- package/docs/classes/Storage.md +16 -16
- package/docs/interfaces/CreateWithToastOptions.md +37 -0
- package/docs/interfaces/EventBusCallback.md +1 -1
- package/docs/interfaces/PollerOptions.md +1 -1
- package/docs/interfaces/StorageManager.md +4 -4
- package/docs/interfaces/Trap.md +5 -5
- package/docs/modules.md +229 -159
- package/es/chunk-B6HL3YHK.js +26 -0
- package/es/chunk-YUYAN2IU.js +29 -0
- package/es/createWithToast.d.ts +10 -0
- package/es/createWithToast.js +7 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +61 -53
- package/es/merge.d.ts +6 -0
- package/es/merge.js +7 -0
- package/es/storage/index.js +3 -3
- package/lib/chunk-45ZFYMTN.cjs +26 -0
- package/lib/chunk-6TPHE34J.cjs +29 -0
- package/lib/createWithToast.cjs +7 -0
- package/lib/createWithToast.d.cts +10 -0
- package/lib/index.cjs +45 -37
- package/lib/index.d.cts +2 -0
- package/lib/merge.cjs +7 -0
- package/lib/merge.d.cts +6 -0
- package/lib/storage/index.cjs +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isObject
|
|
3
|
+
} from "./chunk-XCSSSEK2.js";
|
|
4
|
+
|
|
5
|
+
// src/merge.ts
|
|
6
|
+
function merge(target, ...sources) {
|
|
7
|
+
sources.forEach((source) => {
|
|
8
|
+
if (!isObject(source)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
Object.keys(source).forEach((key) => {
|
|
12
|
+
const sourceValue = source[key];
|
|
13
|
+
const targetValue = target[key];
|
|
14
|
+
if (isObject(targetValue) && isObject(sourceValue)) {
|
|
15
|
+
target[key] = merge(targetValue, sourceValue);
|
|
16
|
+
} else {
|
|
17
|
+
target[key] = sourceValue;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
merge
|
|
26
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPromiseLike
|
|
3
|
+
} from "./chunk-P5GEZD4D.js";
|
|
4
|
+
|
|
5
|
+
// src/createWithToast.ts
|
|
6
|
+
function createWithToast(options = {}) {
|
|
7
|
+
const { onError } = options;
|
|
8
|
+
return (fn) => {
|
|
9
|
+
return function(...args) {
|
|
10
|
+
try {
|
|
11
|
+
const result = fn.apply(this, args);
|
|
12
|
+
if (isPromiseLike(result)) {
|
|
13
|
+
return Promise.resolve(result).catch((err) => {
|
|
14
|
+
onError?.(err);
|
|
15
|
+
throw "cancel:handled";
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
onError?.(error);
|
|
21
|
+
throw "cancel:handled";
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createWithToast
|
|
29
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 处理错误信息可以弹出提示
|
|
3
|
+
*/
|
|
4
|
+
interface CreateWithToastOptions {
|
|
5
|
+
/** error */
|
|
6
|
+
onError?: (err: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function createWithToast(options?: CreateWithToastOptions): <T extends (...args: any) => any>(fn: T) => T;
|
|
9
|
+
|
|
10
|
+
export { type CreateWithToastOptions, createWithToast };
|
package/es/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { createFactory } from './createFactory.js';
|
|
|
16
16
|
export { colorGenByHash } from './createHexColorByHash.js';
|
|
17
17
|
export { createLinearFunction } from './createLinearFunction.js';
|
|
18
18
|
export { createWithLoading } from './createWithLoading.js';
|
|
19
|
+
export { CreateWithToastOptions, createWithToast } from './createWithToast.js';
|
|
19
20
|
export { crlfToBr, filterCRLF } from './crlfToBr.js';
|
|
20
21
|
export { debounce } from './debounce.js';
|
|
21
22
|
export { atob, btoa } from './decode.js';
|
|
@@ -97,6 +98,7 @@ export { kebabCase } from './kebabCase.js';
|
|
|
97
98
|
export { lfToBr } from './lfToBr.js';
|
|
98
99
|
export { listGenerator } from './listGenerator.js';
|
|
99
100
|
export { makePhoneCall } from './makePhoneCall.js';
|
|
101
|
+
export { merge } from './merge.js';
|
|
100
102
|
export { mousewheel } from './mousewheel.js';
|
|
101
103
|
export { nf } from './nf.js';
|
|
102
104
|
export { normalizeDate } from './normalizeDate.js';
|
package/es/index.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withPreventConsecutiveClicks
|
|
3
|
+
} from "./chunk-S6UH3LMW.js";
|
|
1
4
|
import {
|
|
2
5
|
getCache,
|
|
3
6
|
getLocal
|
|
4
7
|
} from "./chunk-LG2TIXRB.js";
|
|
8
|
+
import {
|
|
9
|
+
factory
|
|
10
|
+
} from "./chunk-M6B3UGFI.js";
|
|
5
11
|
import {
|
|
6
12
|
Storage
|
|
7
13
|
} from "./chunk-SBMDM4VS.js";
|
|
14
|
+
import {
|
|
15
|
+
throttle,
|
|
16
|
+
throttleLeading,
|
|
17
|
+
throttleTrailing
|
|
18
|
+
} from "./chunk-ASYHV5B7.js";
|
|
19
|
+
import {
|
|
20
|
+
toCDB
|
|
21
|
+
} from "./chunk-J2Y5ZZA3.js";
|
|
8
22
|
import {
|
|
9
23
|
toDBC
|
|
10
24
|
} from "./chunk-ONTP5SDE.js";
|
|
@@ -25,11 +39,11 @@ import {
|
|
|
25
39
|
withCache
|
|
26
40
|
} from "./chunk-ZI7MCCMB.js";
|
|
27
41
|
import {
|
|
28
|
-
|
|
29
|
-
} from "./chunk-
|
|
42
|
+
scrollToTop
|
|
43
|
+
} from "./chunk-P7QW362C.js";
|
|
30
44
|
import {
|
|
31
|
-
|
|
32
|
-
} from "./chunk-
|
|
45
|
+
setScrollTop
|
|
46
|
+
} from "./chunk-BULTIEJG.js";
|
|
33
47
|
import {
|
|
34
48
|
sounds
|
|
35
49
|
} from "./chunk-ODZQXCS4.js";
|
|
@@ -46,13 +60,14 @@ import {
|
|
|
46
60
|
stringifyQueryString
|
|
47
61
|
} from "./chunk-TSFGLHCP.js";
|
|
48
62
|
import {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
throttleTrailing
|
|
52
|
-
} from "./chunk-ASYHV5B7.js";
|
|
63
|
+
pickBy
|
|
64
|
+
} from "./chunk-2OEHQMIN.js";
|
|
53
65
|
import {
|
|
54
|
-
|
|
55
|
-
} from "./chunk-
|
|
66
|
+
Poller
|
|
67
|
+
} from "./chunk-QT2EM4X2.js";
|
|
68
|
+
import {
|
|
69
|
+
sleep
|
|
70
|
+
} from "./chunk-YUID5DXT.js";
|
|
56
71
|
import {
|
|
57
72
|
replaceCrlf
|
|
58
73
|
} from "./chunk-GNGSV7F7.js";
|
|
@@ -72,11 +87,11 @@ import {
|
|
|
72
87
|
roundUpToNearestInteger
|
|
73
88
|
} from "./chunk-OSACZX5M.js";
|
|
74
89
|
import {
|
|
75
|
-
|
|
76
|
-
} from "./chunk-
|
|
90
|
+
parseError
|
|
91
|
+
} from "./chunk-EJMUWNXI.js";
|
|
77
92
|
import {
|
|
78
|
-
|
|
79
|
-
} from "./chunk-
|
|
93
|
+
parseNumberString
|
|
94
|
+
} from "./chunk-ANY3ULZW.js";
|
|
80
95
|
import {
|
|
81
96
|
parseObject
|
|
82
97
|
} from "./chunk-M3NXNABN.js";
|
|
@@ -93,14 +108,8 @@ import {
|
|
|
93
108
|
pick
|
|
94
109
|
} from "./chunk-IPAT3N4P.js";
|
|
95
110
|
import {
|
|
96
|
-
|
|
97
|
-
} from "./chunk-
|
|
98
|
-
import {
|
|
99
|
-
Poller
|
|
100
|
-
} from "./chunk-QT2EM4X2.js";
|
|
101
|
-
import {
|
|
102
|
-
sleep
|
|
103
|
-
} from "./chunk-YUID5DXT.js";
|
|
111
|
+
normalizePath
|
|
112
|
+
} from "./chunk-CMP4T3ZH.js";
|
|
104
113
|
import {
|
|
105
114
|
numberToLetter
|
|
106
115
|
} from "./chunk-U7BK2TT3.js";
|
|
@@ -120,11 +129,8 @@ import {
|
|
|
120
129
|
parseDecimalString
|
|
121
130
|
} from "./chunk-N6ZMEBBU.js";
|
|
122
131
|
import {
|
|
123
|
-
|
|
124
|
-
} from "./chunk-
|
|
125
|
-
import {
|
|
126
|
-
parseNumberString
|
|
127
|
-
} from "./chunk-ANY3ULZW.js";
|
|
132
|
+
isWindow
|
|
133
|
+
} from "./chunk-QYCMY2T4.js";
|
|
128
134
|
import {
|
|
129
135
|
kebabCase
|
|
130
136
|
} from "./chunk-IPIA4Z65.js";
|
|
@@ -134,6 +140,9 @@ import {
|
|
|
134
140
|
import {
|
|
135
141
|
makePhoneCall
|
|
136
142
|
} from "./chunk-GYOXULKV.js";
|
|
143
|
+
import {
|
|
144
|
+
merge
|
|
145
|
+
} from "./chunk-B6HL3YHK.js";
|
|
137
146
|
import {
|
|
138
147
|
mousewheel
|
|
139
148
|
} from "./chunk-GVPHHNDY.js";
|
|
@@ -141,8 +150,8 @@ import {
|
|
|
141
150
|
nf
|
|
142
151
|
} from "./chunk-PAERS3SW.js";
|
|
143
152
|
import {
|
|
144
|
-
|
|
145
|
-
} from "./chunk-
|
|
153
|
+
isRegExp
|
|
154
|
+
} from "./chunk-Y4V5R7XA.js";
|
|
146
155
|
import {
|
|
147
156
|
isType
|
|
148
157
|
} from "./chunk-5EVWQVDV.js";
|
|
@@ -160,8 +169,8 @@ import {
|
|
|
160
169
|
isWeChatMiniProgram
|
|
161
170
|
} from "./chunk-SQ3L6IQW.js";
|
|
162
171
|
import {
|
|
163
|
-
|
|
164
|
-
} from "./chunk-
|
|
172
|
+
isNativeFunction
|
|
173
|
+
} from "./chunk-4N33UIAB.js";
|
|
165
174
|
import {
|
|
166
175
|
isNotEmpty
|
|
167
176
|
} from "./chunk-YYH4INGK.js";
|
|
@@ -175,11 +184,8 @@ import {
|
|
|
175
184
|
isPromise
|
|
176
185
|
} from "./chunk-LJ4CEJ5C.js";
|
|
177
186
|
import {
|
|
178
|
-
|
|
179
|
-
} from "./chunk-
|
|
180
|
-
import {
|
|
181
|
-
isRegExp
|
|
182
|
-
} from "./chunk-Y4V5R7XA.js";
|
|
187
|
+
isIE
|
|
188
|
+
} from "./chunk-QTKWJHHW.js";
|
|
183
189
|
import {
|
|
184
190
|
isIOS
|
|
185
191
|
} from "./chunk-5BVFSCCX.js";
|
|
@@ -202,8 +208,8 @@ import {
|
|
|
202
208
|
isMobile
|
|
203
209
|
} from "./chunk-L52JSZDZ.js";
|
|
204
210
|
import {
|
|
205
|
-
|
|
206
|
-
} from "./chunk-
|
|
211
|
+
isChinese
|
|
212
|
+
} from "./chunk-KYLBUCGC.js";
|
|
207
213
|
import {
|
|
208
214
|
isDate
|
|
209
215
|
} from "./chunk-A4YRDVZ4.js";
|
|
@@ -213,9 +219,6 @@ import {
|
|
|
213
219
|
import {
|
|
214
220
|
isError
|
|
215
221
|
} from "./chunk-6UGTRW2S.js";
|
|
216
|
-
import {
|
|
217
|
-
isIE
|
|
218
|
-
} from "./chunk-QTKWJHHW.js";
|
|
219
222
|
import {
|
|
220
223
|
insertLink
|
|
221
224
|
} from "./chunk-FIHEVMN6.js";
|
|
@@ -235,8 +238,8 @@ import {
|
|
|
235
238
|
isBoolean
|
|
236
239
|
} from "./chunk-ZWXX326Y.js";
|
|
237
240
|
import {
|
|
238
|
-
|
|
239
|
-
} from "./chunk-
|
|
241
|
+
getRandomColor
|
|
242
|
+
} from "./chunk-D7OBO7J6.js";
|
|
240
243
|
import {
|
|
241
244
|
getRandomNumber
|
|
242
245
|
} from "./chunk-TZ2EQSRZ.js";
|
|
@@ -258,6 +261,9 @@ import {
|
|
|
258
261
|
import {
|
|
259
262
|
inBrowser
|
|
260
263
|
} from "./chunk-ZDRIUWKX.js";
|
|
264
|
+
import {
|
|
265
|
+
formatPathParams
|
|
266
|
+
} from "./chunk-JG33SHAK.js";
|
|
261
267
|
import {
|
|
262
268
|
getBlobByUrl
|
|
263
269
|
} from "./chunk-4QMOXXPL.js";
|
|
@@ -283,8 +289,8 @@ import {
|
|
|
283
289
|
listGenerator
|
|
284
290
|
} from "./chunk-2SUOLGG5.js";
|
|
285
291
|
import {
|
|
286
|
-
|
|
287
|
-
} from "./chunk-
|
|
292
|
+
filterString
|
|
293
|
+
} from "./chunk-KJX7IWF5.js";
|
|
288
294
|
import {
|
|
289
295
|
formatDateToZN
|
|
290
296
|
} from "./chunk-DW5GIB4A.js";
|
|
@@ -316,8 +322,8 @@ import {
|
|
|
316
322
|
parsePath
|
|
317
323
|
} from "./chunk-VMJHCN3P.js";
|
|
318
324
|
import {
|
|
319
|
-
|
|
320
|
-
} from "./chunk-
|
|
325
|
+
eventBus
|
|
326
|
+
} from "./chunk-HYCW7PL5.js";
|
|
321
327
|
import {
|
|
322
328
|
exitFullscreen
|
|
323
329
|
} from "./chunk-GV4IJGB2.js";
|
|
@@ -357,15 +363,18 @@ import {
|
|
|
357
363
|
import {
|
|
358
364
|
filterPhone
|
|
359
365
|
} from "./chunk-5Z3KN6O2.js";
|
|
360
|
-
import {
|
|
361
|
-
filterString
|
|
362
|
-
} from "./chunk-KJX7IWF5.js";
|
|
363
366
|
import {
|
|
364
367
|
createLinearFunction
|
|
365
368
|
} from "./chunk-53VI5KBY.js";
|
|
366
369
|
import {
|
|
367
370
|
createWithLoading
|
|
368
371
|
} from "./chunk-OC64NXZ2.js";
|
|
372
|
+
import {
|
|
373
|
+
createWithToast
|
|
374
|
+
} from "./chunk-YUYAN2IU.js";
|
|
375
|
+
import {
|
|
376
|
+
isPromiseLike
|
|
377
|
+
} from "./chunk-P5GEZD4D.js";
|
|
369
378
|
import {
|
|
370
379
|
crlfToBr,
|
|
371
380
|
filterCRLF
|
|
@@ -383,9 +392,6 @@ import {
|
|
|
383
392
|
import {
|
|
384
393
|
each
|
|
385
394
|
} from "./chunk-K4SQME6B.js";
|
|
386
|
-
import {
|
|
387
|
-
eventBus
|
|
388
|
-
} from "./chunk-HYCW7PL5.js";
|
|
389
395
|
import {
|
|
390
396
|
clamp
|
|
391
397
|
} from "./chunk-W52BRMSD.js";
|
|
@@ -464,6 +470,7 @@ export {
|
|
|
464
470
|
createLinearFunction,
|
|
465
471
|
createTrapInstance,
|
|
466
472
|
createWithLoading,
|
|
473
|
+
createWithToast,
|
|
467
474
|
crlfToBr,
|
|
468
475
|
debounce,
|
|
469
476
|
downloadFile,
|
|
@@ -549,6 +556,7 @@ export {
|
|
|
549
556
|
lfToBr,
|
|
550
557
|
listGenerator,
|
|
551
558
|
makePhoneCall,
|
|
559
|
+
merge,
|
|
552
560
|
mousewheel,
|
|
553
561
|
nf,
|
|
554
562
|
normalizeDate,
|
package/es/merge.d.ts
ADDED
package/es/merge.js
ADDED
package/es/storage/index.js
CHANGED
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
getCache,
|
|
3
3
|
getLocal
|
|
4
4
|
} from "../chunk-LG2TIXRB.js";
|
|
5
|
-
import {
|
|
6
|
-
Storage
|
|
7
|
-
} from "../chunk-SBMDM4VS.js";
|
|
8
5
|
import {
|
|
9
6
|
factory
|
|
10
7
|
} from "../chunk-M6B3UGFI.js";
|
|
8
|
+
import {
|
|
9
|
+
Storage
|
|
10
|
+
} from "../chunk-SBMDM4VS.js";
|
|
11
11
|
import "../chunk-CSZ7G34M.js";
|
|
12
12
|
import "../chunk-XCSSSEK2.js";
|
|
13
13
|
export {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkOSEQ7XR6cjs = require('./chunk-OSEQ7XR6.cjs');
|
|
4
|
+
|
|
5
|
+
// src/merge.ts
|
|
6
|
+
function merge(target, ...sources) {
|
|
7
|
+
sources.forEach((source) => {
|
|
8
|
+
if (!_chunkOSEQ7XR6cjs.isObject.call(void 0, source)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
Object.keys(source).forEach((key) => {
|
|
12
|
+
const sourceValue = source[key];
|
|
13
|
+
const targetValue = target[key];
|
|
14
|
+
if (_chunkOSEQ7XR6cjs.isObject.call(void 0, targetValue) && _chunkOSEQ7XR6cjs.isObject.call(void 0, sourceValue)) {
|
|
15
|
+
target[key] = merge(targetValue, sourceValue);
|
|
16
|
+
} else {
|
|
17
|
+
target[key] = sourceValue;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.merge = merge;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkN455COPHcjs = require('./chunk-N455COPH.cjs');
|
|
4
|
+
|
|
5
|
+
// src/createWithToast.ts
|
|
6
|
+
function createWithToast(options = {}) {
|
|
7
|
+
const { onError } = options;
|
|
8
|
+
return (fn) => {
|
|
9
|
+
return function(...args) {
|
|
10
|
+
try {
|
|
11
|
+
const result = fn.apply(this, args);
|
|
12
|
+
if (_chunkN455COPHcjs.isPromiseLike.call(void 0, result)) {
|
|
13
|
+
return Promise.resolve(result).catch((err) => {
|
|
14
|
+
_optionalChain([onError, 'optionalCall', _ => _(err)]);
|
|
15
|
+
throw "cancel:handled";
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
_optionalChain([onError, 'optionalCall', _2 => _2(error)]);
|
|
21
|
+
throw "cancel:handled";
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.createWithToast = createWithToast;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 处理错误信息可以弹出提示
|
|
3
|
+
*/
|
|
4
|
+
interface CreateWithToastOptions {
|
|
5
|
+
/** error */
|
|
6
|
+
onError?: (err: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
declare function createWithToast(options?: CreateWithToastOptions): <T extends (...args: any) => any>(fn: T) => T;
|
|
9
|
+
|
|
10
|
+
export { type CreateWithToastOptions, createWithToast };
|