@daysnap/utils 0.1.28 → 0.1.30
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 +68 -18
- 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 +179 -156
- package/es/chunk-6CNTNYSN.js +8 -0
- package/es/{chunk-56QUZDMU.js → chunk-SBMDM4VS.js} +36 -8
- package/es/index.d.ts +1 -0
- package/es/index.js +5 -1
- package/es/storage/index.js +1 -1
- package/es/storage/storage.d.ts +17 -5
- package/es/storage/storage.js +1 -1
- package/es/toPosix.d.ts +6 -0
- package/es/toPosix.js +6 -0
- package/lib/{chunk-GQFHHWIV.cjs → chunk-247HC54W.cjs} +36 -8
- package/lib/chunk-EUL63MJO.cjs +8 -0
- package/lib/index.cjs +6 -2
- package/lib/index.d.cts +1 -0
- package/lib/storage/index.cjs +2 -2
- package/lib/storage/storage.cjs +2 -2
- package/lib/storage/storage.d.cts +17 -5
- package/lib/toPosix.cjs +6 -0
- package/lib/toPosix.d.cts +6 -0
- package/package.json +1 -1
|
@@ -10,20 +10,35 @@ var Storage = class {
|
|
|
10
10
|
key;
|
|
11
11
|
storage;
|
|
12
12
|
value = null;
|
|
13
|
-
|
|
13
|
+
options = { debug: false, cached: false };
|
|
14
|
+
constructor(key, storage, options) {
|
|
15
|
+
const { initialValue, ...rest } = options || {};
|
|
14
16
|
this.key = key;
|
|
15
17
|
this.storage = storage;
|
|
18
|
+
if (options) {
|
|
19
|
+
Object.assign(this.options, rest);
|
|
20
|
+
}
|
|
21
|
+
if (initialValue != void 0) {
|
|
22
|
+
this.setItem(initialValue);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_debug(...args) {
|
|
26
|
+
if (this.options.debug) {
|
|
27
|
+
console.log(`\u3010Storage\u3011=> `, ...args);
|
|
28
|
+
}
|
|
16
29
|
}
|
|
17
30
|
/**
|
|
18
31
|
* 设置值
|
|
19
32
|
*/
|
|
20
33
|
setItem(val) {
|
|
21
|
-
this.value = null;
|
|
22
34
|
this.storage.setItem(this.key, JSON.stringify(val));
|
|
35
|
+
if (this.options.cached) {
|
|
36
|
+
this.value = this.getItem();
|
|
37
|
+
}
|
|
23
38
|
return val;
|
|
24
39
|
}
|
|
25
40
|
getItem(defaultVal) {
|
|
26
|
-
const val = this.storage.getItem(this.key);
|
|
41
|
+
const val = this.storage.getItem(this.key) ?? null;
|
|
27
42
|
if (val === null) {
|
|
28
43
|
return defaultVal ?? null;
|
|
29
44
|
}
|
|
@@ -50,15 +65,28 @@ var Storage = class {
|
|
|
50
65
|
return this.setItem(val);
|
|
51
66
|
}
|
|
52
67
|
getItemOnce(defaultVal) {
|
|
53
|
-
const val = this.
|
|
68
|
+
const val = this.getItem(defaultVal);
|
|
69
|
+
this.removeItem();
|
|
70
|
+
return val;
|
|
71
|
+
}
|
|
72
|
+
getItemWithCache(defaultVal) {
|
|
73
|
+
if (this.value !== null) {
|
|
74
|
+
this._debug(`${this.key}: \u547D\u4E2D\u7F13\u5B58\uFF01`);
|
|
75
|
+
return this.value;
|
|
76
|
+
}
|
|
77
|
+
this._debug(`${this.key}: \u8BFB\u53D6\u5B58\u50A8\uFF01`);
|
|
78
|
+
const val = this.getItem();
|
|
54
79
|
if (val === null) {
|
|
55
80
|
return defaultVal ?? null;
|
|
56
81
|
}
|
|
57
|
-
this.
|
|
58
|
-
return
|
|
82
|
+
this.value = val;
|
|
83
|
+
return this.value;
|
|
59
84
|
}
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
/**
|
|
86
|
+
* 清除缓存
|
|
87
|
+
*/
|
|
88
|
+
clearCache() {
|
|
89
|
+
this.value = null;
|
|
62
90
|
}
|
|
63
91
|
};
|
|
64
92
|
|
package/es/index.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export { throttle, throttleLeading, throttleTrailing } from './throttle.js';
|
|
|
134
134
|
export { toCDB } from './toCDB.js';
|
|
135
135
|
export { toDBC } from './toDBC.js';
|
|
136
136
|
export { toFormData } from './toFormData.js';
|
|
137
|
+
export { toPosix } from './toPosix.js';
|
|
137
138
|
export { Trap, createTrapInstance, trap } from './trap.js';
|
|
138
139
|
export { typeOf } from './typeOf.js';
|
|
139
140
|
export { withCache } from './withCache.js';
|
package/es/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toPosix
|
|
3
|
+
} from "./chunk-6CNTNYSN.js";
|
|
1
4
|
import {
|
|
2
5
|
createTrapInstance,
|
|
3
6
|
trap
|
|
@@ -20,7 +23,7 @@ import {
|
|
|
20
23
|
} from "./chunk-M6B3UGFI.js";
|
|
21
24
|
import {
|
|
22
25
|
Storage
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-SBMDM4VS.js";
|
|
24
27
|
import {
|
|
25
28
|
splitArray
|
|
26
29
|
} from "./chunk-BNF4U7EJ.js";
|
|
@@ -577,6 +580,7 @@ export {
|
|
|
577
580
|
toCDB,
|
|
578
581
|
toDBC,
|
|
579
582
|
toFormData,
|
|
583
|
+
toPosix,
|
|
580
584
|
trap,
|
|
581
585
|
typeOf,
|
|
582
586
|
withCache,
|
package/es/storage/index.js
CHANGED
package/es/storage/storage.d.ts
CHANGED
|
@@ -3,11 +3,19 @@ interface StorageLike {
|
|
|
3
3
|
setItem: (key: string, value: string) => void;
|
|
4
4
|
removeItem: (key: string) => void;
|
|
5
5
|
}
|
|
6
|
+
type DefaultVal<T> = T extends Record<string, any> ? Partial<T> : T;
|
|
7
|
+
interface StorageOptions<T = any> {
|
|
8
|
+
initialValue?: T;
|
|
9
|
+
debug: boolean;
|
|
10
|
+
cached: boolean;
|
|
11
|
+
}
|
|
6
12
|
declare class Storage<T = any> {
|
|
7
13
|
private readonly key;
|
|
8
14
|
private readonly storage;
|
|
9
15
|
private value;
|
|
10
|
-
|
|
16
|
+
private options;
|
|
17
|
+
constructor(key: string, storage: StorageLike, options?: Partial<StorageOptions<T>>);
|
|
18
|
+
_debug(...args: string[]): void;
|
|
11
19
|
/**
|
|
12
20
|
* 设置值
|
|
13
21
|
*/
|
|
@@ -16,7 +24,7 @@ declare class Storage<T = any> {
|
|
|
16
24
|
* 获取值
|
|
17
25
|
*/
|
|
18
26
|
getItem(): T | null;
|
|
19
|
-
getItem(defaultVal:
|
|
27
|
+
getItem(defaultVal: DefaultVal<T>): T;
|
|
20
28
|
/**
|
|
21
29
|
* 删除值
|
|
22
30
|
*/
|
|
@@ -24,17 +32,21 @@ declare class Storage<T = any> {
|
|
|
24
32
|
/**
|
|
25
33
|
* 更新值
|
|
26
34
|
*/
|
|
27
|
-
updateItem(val:
|
|
35
|
+
updateItem(val: DefaultVal<T>): T;
|
|
28
36
|
/**
|
|
29
37
|
* 获取值后,删除存储的值
|
|
30
38
|
*/
|
|
31
39
|
getItemOnce(): T | null;
|
|
32
|
-
getItemOnce(defaultVal:
|
|
40
|
+
getItemOnce(defaultVal: DefaultVal<T>): T;
|
|
33
41
|
/**
|
|
34
42
|
* 优先从缓存中获取值
|
|
35
43
|
*/
|
|
36
44
|
getItemWithCache(): T | null;
|
|
37
|
-
getItemWithCache(defaultVal:
|
|
45
|
+
getItemWithCache(defaultVal: DefaultVal<T>): T;
|
|
46
|
+
/**
|
|
47
|
+
* 清除缓存
|
|
48
|
+
*/
|
|
49
|
+
clearCache(): void;
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
export { Storage };
|
package/es/storage/storage.js
CHANGED
package/es/toPosix.d.ts
ADDED
package/es/toPosix.js
ADDED
|
@@ -10,20 +10,35 @@ var Storage = (_class = class {
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
__init() {this.value = null}
|
|
13
|
-
|
|
13
|
+
__init2() {this.options = { debug: false, cached: false }}
|
|
14
|
+
constructor(key, storage, options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
15
|
+
const { initialValue, ...rest } = options || {};
|
|
14
16
|
this.key = key;
|
|
15
17
|
this.storage = storage;
|
|
18
|
+
if (options) {
|
|
19
|
+
Object.assign(this.options, rest);
|
|
20
|
+
}
|
|
21
|
+
if (initialValue != void 0) {
|
|
22
|
+
this.setItem(initialValue);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_debug(...args) {
|
|
26
|
+
if (this.options.debug) {
|
|
27
|
+
console.log(`\u3010Storage\u3011=> `, ...args);
|
|
28
|
+
}
|
|
16
29
|
}
|
|
17
30
|
/**
|
|
18
31
|
* 设置值
|
|
19
32
|
*/
|
|
20
33
|
setItem(val) {
|
|
21
|
-
this.value = null;
|
|
22
34
|
this.storage.setItem(this.key, JSON.stringify(val));
|
|
35
|
+
if (this.options.cached) {
|
|
36
|
+
this.value = this.getItem();
|
|
37
|
+
}
|
|
23
38
|
return val;
|
|
24
39
|
}
|
|
25
40
|
getItem(defaultVal) {
|
|
26
|
-
const val = this.storage.getItem(this.key);
|
|
41
|
+
const val = _nullishCoalesce(this.storage.getItem(this.key), () => ( null));
|
|
27
42
|
if (val === null) {
|
|
28
43
|
return _nullishCoalesce(defaultVal, () => ( null));
|
|
29
44
|
}
|
|
@@ -50,15 +65,28 @@ var Storage = (_class = class {
|
|
|
50
65
|
return this.setItem(val);
|
|
51
66
|
}
|
|
52
67
|
getItemOnce(defaultVal) {
|
|
53
|
-
const val = this.
|
|
68
|
+
const val = this.getItem(defaultVal);
|
|
69
|
+
this.removeItem();
|
|
70
|
+
return val;
|
|
71
|
+
}
|
|
72
|
+
getItemWithCache(defaultVal) {
|
|
73
|
+
if (this.value !== null) {
|
|
74
|
+
this._debug(`${this.key}: \u547D\u4E2D\u7F13\u5B58\uFF01`);
|
|
75
|
+
return this.value;
|
|
76
|
+
}
|
|
77
|
+
this._debug(`${this.key}: \u8BFB\u53D6\u5B58\u50A8\uFF01`);
|
|
78
|
+
const val = this.getItem();
|
|
54
79
|
if (val === null) {
|
|
55
80
|
return _nullishCoalesce(defaultVal, () => ( null));
|
|
56
81
|
}
|
|
57
|
-
this.
|
|
58
|
-
return
|
|
82
|
+
this.value = val;
|
|
83
|
+
return this.value;
|
|
59
84
|
}
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
/**
|
|
86
|
+
* 清除缓存
|
|
87
|
+
*/
|
|
88
|
+
clearCache() {
|
|
89
|
+
this.value = null;
|
|
62
90
|
}
|
|
63
91
|
}, _class);
|
|
64
92
|
|
package/lib/index.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunkEUL63MJOcjs = require('./chunk-EUL63MJO.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
|
|
4
7
|
var _chunkMPVUIHAGcjs = require('./chunk-MPVUIHAG.cjs');
|
|
5
8
|
|
|
@@ -20,7 +23,7 @@ var _chunk2PEWYRYDcjs = require('./chunk-2PEWYRYD.cjs');
|
|
|
20
23
|
var _chunk4YOKT62Rcjs = require('./chunk-4YOKT62R.cjs');
|
|
21
24
|
|
|
22
25
|
|
|
23
|
-
var
|
|
26
|
+
var _chunk247HC54Wcjs = require('./chunk-247HC54W.cjs');
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
var _chunkDLFVAWQEcjs = require('./chunk-DLFVAWQE.cjs');
|
|
@@ -581,4 +584,5 @@ var _chunkOP4R4DYKcjs = require('./chunk-OP4R4DYK.cjs');
|
|
|
581
584
|
|
|
582
585
|
|
|
583
586
|
|
|
584
|
-
|
|
587
|
+
|
|
588
|
+
exports.Poller = _chunkX4KLPUWQcjs.Poller; exports.Storage = _chunk247HC54Wcjs.Storage; exports.ato = _chunkJM2YJOLHcjs.ato; exports.atob = _chunkFHNJXQ7Ccjs.atob; exports.base64ToBlob = _chunkAPR56HNVcjs.base64ToBlob; exports.blobToBase64 = _chunkYIW4PW4Qcjs.blobToBase64; exports.btoa = _chunkFHNJXQ7Ccjs.btoa; exports.cached = _chunkT5HZJXJZcjs.cached; exports.camelCase = _chunkKVFFHAG5cjs.camelCase; exports.canvasToBlob = _chunkXEH7QVTCcjs.canvasToBlob; exports.capitalize = _chunk3PWVY4SHcjs.capitalize; exports.chooseMedia = _chunkOP4R4DYKcjs.chooseMedia; exports.clamp = _chunk7OZ5UUVBcjs.clamp; exports.clone = _chunkCFV6PO5Ecjs.clone; exports.cloneSimple = _chunkWOIBXERDcjs.cloneSimple; exports.colorGenByHash = _chunk5ARDICATcjs.colorGenByHash; exports.compareVersion = _chunkFSSKYWRTcjs.compareVersion; exports.compressImage = _chunkL5KGR7MEcjs.compressImage; exports.crToBr = _chunkZSDKKWIQcjs.crToBr; exports.createFactory = _chunk5NP37CWOcjs.createFactory; exports.createLinearFunction = _chunk3TP6R4WAcjs.createLinearFunction; exports.createTrapInstance = _chunkMPVUIHAGcjs.createTrapInstance; exports.createWithLoading = _chunk74PINGFKcjs.createWithLoading; exports.crlfToBr = _chunkTMCJ3HTAcjs.crlfToBr; exports.debounce = _chunkHFUAXSGVcjs.debounce; exports.downloadFile = _chunkHGSEX5HQcjs.downloadFile; exports.each = _chunkUR2ABWZ4cjs.each; exports.eventBus = _chunkNSZPG5NOcjs.eventBus; exports.exitFullscreen = _chunkLG44HBZ4cjs.exitFullscreen; exports.factory = _chunk4YOKT62Rcjs.factory; exports.filterBankCardNo = _chunkH4CB6RZ5cjs.filterBankCardNo; exports.filterCRLF = _chunkTMCJ3HTAcjs.filterCRLF; exports.filterEmoji = _chunkPRWCT37Dcjs.filterEmoji; exports.filterEmptyValue = _chunk4P4EJVBWcjs.filterEmptyValue; exports.filterIdCard = _chunkIS7BS4UCcjs.filterIdCard; exports.filterName = _chunkPQTXZSTUcjs.filterName; exports.filterPhone = _chunk5KTUK4SScjs.filterPhone; exports.filterString = _chunkXK4UPPRRcjs.filterString; exports.formatAmount = _chunkGPBXHPDAcjs.formatAmount; exports.formatDate = _chunkBQ7SLF6Ccjs.formatDate; exports.formatDateStr = _chunkHJFHIODBcjs.formatDateStr; exports.formatDateToZN = _chunkKT3FWGJGcjs.formatDateToZN; exports.formatFileSize = _chunkEDVQTNLJcjs.formatFileSize; exports.formatGapDate = _chunkZ42N5FUVcjs.formatGapDate; exports.formatMessage = _chunk22FM4HKFcjs.formatMessage; exports.formatPathParams = _chunkE7MIER2Tcjs.formatPathParams; exports.getBlobByUrl = _chunkFJDQPA7Acjs.getBlobByUrl; exports.getCache = _chunk2PEWYRYDcjs.getCache; exports.getDateBoundsByMonths = _chunk44UMWNOZcjs.getDateBoundsByMonths; exports.getDayMillisecond = _chunkEZJIAA6Bcjs.getDayMillisecond; exports.getDaysOfMonth = _chunkEUH2FDMTcjs.getDaysOfMonth; exports.getImageInfo = _chunkPLAR2CBQcjs.getImageInfo; exports.getLocal = _chunk2PEWYRYDcjs.getLocal; exports.getMonthBounds = _chunkSZOUFWPJcjs.getMonthBounds; exports.getRandom = _chunkJFPD5JTYcjs.getRandom; exports.getRandomColor = _chunk3DLBDFKUcjs.getRandomColor; exports.getRandomNumber = _chunkIGD442DScjs.getRandomNumber; exports.getRangeDate = _chunkNEFFCHO5cjs.getRangeDate; exports.getScrollTop = _chunkXSHZO4H7cjs.getScrollTop; exports.getVideoInfo = _chunkHS5BXXAPcjs.getVideoInfo; exports.getWeekBounds = _chunk4WWOJSX3cjs.getWeekBounds; exports.getWeekday = _chunk6TABJ32Lcjs.getWeekday; exports.inBrowser = _chunkMWTRB6PBcjs.inBrowser; exports.insertLink = _chunkYSJISFDDcjs.insertLink; exports.insertScript = _chunkA5V2JWRFcjs.insertScript; exports.insertStyle = _chunkY65BJOJJcjs.insertStyle; exports.isAmount = _chunkFALWMHVNcjs.isAmount; exports.isAndroid = _chunk4AORUEO2cjs.isAndroid; exports.isArray = _chunk5PB5B4HHcjs.isArray; exports.isBoolean = _chunk6NGVHTCIcjs.isBoolean; exports.isChinese = _chunkEWEGXHJQcjs.isChinese; exports.isDate = _chunk2UG6AKMUcjs.isDate; exports.isEmail = _chunkRMH4RB2Dcjs.isEmail; exports.isEmpty = _chunkA2J34A3Kcjs.isEmpty; exports.isEmptyArray = _chunkX3A4TUQLcjs.isEmptyArray; exports.isEmptyObject = _chunk5XVQSGWZcjs.isEmptyObject; exports.isError = _chunkDZOWS2MAcjs.isError; exports.isFunction = _chunkOHDNJMMWcjs.isFunction; exports.isIE = _chunkKXUFBNO6cjs.isIE; exports.isIOS = _chunkGPSJ6TVVcjs.isIOS; exports.isIdCard = _chunkZIZGHVWBcjs.isIdCard; exports.isJSONString = _chunkE2DCMX7Ecjs.isJSONString; exports.isLan = _chunkC2J6KM7Acjs.isLan; exports.isLeapYear = _chunkUTUKZLENcjs.isLeapYear; exports.isLicenseCode = _chunk7PO2RFTNcjs.isLicenseCode; exports.isMobile = _chunk6RAOGPVDcjs.isMobile; exports.isNativeFunction = _chunkUEATWSR2cjs.isNativeFunction; exports.isNull = _chunkHILUSXLZcjs.isNull; exports.isNumber = _chunkOWRVHVPVcjs.isNumber; exports.isObject = _chunkOSEQ7XR6cjs.isObject; exports.isPhone = _chunk25SIHWQPcjs.isPhone; exports.isPromise = _chunkKZ4FXD7Xcjs.isPromise; exports.isRegExp = _chunk6U7TWPFKcjs.isRegExp; exports.isString = _chunkT5JI3MECcjs.isString; exports.isType = _chunkSGXWZSMScjs.isType; exports.isUndefined = _chunkFV6ZXO2Bcjs.isUndefined; exports.isUrl = _chunkI6VB2D7Ccjs.isUrl; exports.isValidDate = _chunkSOBKBDECcjs.isValidDate; exports.isWeChat = _chunkYRGRWQ7Lcjs.isWeChat; exports.isWeChatMiniProgram = _chunkASLPGL5Kcjs.isWeChatMiniProgram; exports.isWeixin = _chunkYRGRWQ7Lcjs.isWeixin; exports.isWindow = _chunkM6IV2L5Ccjs.isWindow; exports.kebabCase = _chunkM23T6OXJcjs.kebabCase; exports.lfToBr = _chunkXSCXPGEIcjs.lfToBr; exports.listGenerator = _chunk2C3XINC3cjs.listGenerator; exports.makePhoneCall = _chunkZZZLASMIcjs.makePhoneCall; exports.mousewheel = _chunkODAKGDKHcjs.mousewheel; exports.nf = _chunkJEUL7IDUcjs.nf; exports.normalizeDate = _chunkHEVW5ZN2cjs.normalizeDate; exports.normalizePath = _chunkZGX4PSUDcjs.normalizePath; exports.numberToLetter = _chunkHAOBASRWcjs.numberToLetter; exports.omit = _chunkSN4K47PZcjs.omit; exports.omitBy = _chunkMAS642WYcjs.omitBy; exports.padding = _chunkGDDKMJAIcjs.padding; exports.parseDate = _chunkJGIFNIG6cjs.parseDate; exports.parseDecimalString = _chunkJ5LO5FYMcjs.parseDecimalString; exports.parseError = _chunkSYJEN3G6cjs.parseError; exports.parseNumberString = _chunkMDWZRDATcjs.parseNumberString; exports.parseObject = _chunkOZ4OLVHRcjs.parseObject; exports.parsePath = _chunkKWKJUVO6cjs.parsePath; exports.parseQuery = _chunkBMT7LU53cjs.parseQuery; exports.parseQueryString = _chunk5R3HPYN2cjs.parseQueryString; exports.pascalCase = _chunkSGFZYTKRcjs.pascalCase; exports.pick = _chunkG4WAYEDTcjs.pick; exports.pickBy = _chunk7YW5G75Scjs.pickBy; exports.replaceCrlf = _chunkE6II5N2Qcjs.replaceCrlf; exports.requestFullScreen = _chunkTDDP3MWOcjs.requestFullScreen; exports.reserve = _chunkKEDGCQDCcjs.reserve; exports.rgbToHex = _chunkJEYNULD2cjs.rgbToHex; exports.round = _chunkH3CSJ2K4cjs.round; exports.roundUpToNearestInteger = _chunkKNITIDZ3cjs.roundUpToNearestInteger; exports.scrollToTop = _chunkIOIAYNDBcjs.scrollToTop; exports.setScrollTop = _chunkU6NQZGBGcjs.setScrollTop; exports.sleep = _chunkYODLJ422cjs.sleep; exports.sounds = _chunkGCRDIQOEcjs.sounds; exports.splitArray = _chunkDLFVAWQEcjs.splitArray; exports.stringTrim = _chunkLP2WQB3Xcjs.stringTrim; exports.stringifyQuery = _chunk4USHGA4Pcjs.stringifyQuery; exports.stringifyQueryString = _chunkHTVUYJEVcjs.stringifyQueryString; exports.throttle = _chunkTVAUIFMFcjs.throttle; exports.throttleLeading = _chunkTVAUIFMFcjs.throttleLeading; exports.throttleTrailing = _chunkTVAUIFMFcjs.throttleTrailing; exports.toCDB = _chunk7CGDZ7SUcjs.toCDB; exports.toDBC = _chunkEE6TAHREcjs.toDBC; exports.toFormData = _chunkYBDABMYBcjs.toFormData; exports.toPosix = _chunkEUL63MJOcjs.toPosix; exports.trap = _chunkMPVUIHAGcjs.trap; exports.typeOf = _chunkKU2JNLWGcjs.typeOf; exports.withCache = _chunk2XXFQQUMcjs.withCache; exports.withPreventConsecutiveClicks = _chunkLTSAC5DKcjs.withPreventConsecutiveClicks;
|
package/lib/index.d.cts
CHANGED
|
@@ -134,6 +134,7 @@ export { throttle, throttleLeading, throttleTrailing } from './throttle.cjs';
|
|
|
134
134
|
export { toCDB } from './toCDB.cjs';
|
|
135
135
|
export { toDBC } from './toDBC.cjs';
|
|
136
136
|
export { toFormData } from './toFormData.cjs';
|
|
137
|
+
export { toPosix } from './toPosix.cjs';
|
|
137
138
|
export { Trap, createTrapInstance, trap } from './trap.cjs';
|
|
138
139
|
export { typeOf } from './typeOf.cjs';
|
|
139
140
|
export { withCache } from './withCache.cjs';
|
package/lib/storage/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var _chunk2PEWYRYDcjs = require('../chunk-2PEWYRYD.cjs');
|
|
|
7
7
|
var _chunk4YOKT62Rcjs = require('../chunk-4YOKT62R.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk247HC54Wcjs = require('../chunk-247HC54W.cjs');
|
|
11
11
|
require('../chunk-5PB5B4HH.cjs');
|
|
12
12
|
require('../chunk-OSEQ7XR6.cjs');
|
|
13
13
|
|
|
@@ -15,4 +15,4 @@ require('../chunk-OSEQ7XR6.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
exports.Storage =
|
|
18
|
+
exports.Storage = _chunk247HC54Wcjs.Storage; exports.factory = _chunk4YOKT62Rcjs.factory; exports.getCache = _chunk2PEWYRYDcjs.getCache; exports.getLocal = _chunk2PEWYRYDcjs.getLocal;
|
package/lib/storage/storage.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk247HC54Wcjs = require('../chunk-247HC54W.cjs');
|
|
4
4
|
require('../chunk-5PB5B4HH.cjs');
|
|
5
5
|
require('../chunk-OSEQ7XR6.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.Storage =
|
|
8
|
+
exports.Storage = _chunk247HC54Wcjs.Storage;
|
|
@@ -3,11 +3,19 @@ interface StorageLike {
|
|
|
3
3
|
setItem: (key: string, value: string) => void;
|
|
4
4
|
removeItem: (key: string) => void;
|
|
5
5
|
}
|
|
6
|
+
type DefaultVal<T> = T extends Record<string, any> ? Partial<T> : T;
|
|
7
|
+
interface StorageOptions<T = any> {
|
|
8
|
+
initialValue?: T;
|
|
9
|
+
debug: boolean;
|
|
10
|
+
cached: boolean;
|
|
11
|
+
}
|
|
6
12
|
declare class Storage<T = any> {
|
|
7
13
|
private readonly key;
|
|
8
14
|
private readonly storage;
|
|
9
15
|
private value;
|
|
10
|
-
|
|
16
|
+
private options;
|
|
17
|
+
constructor(key: string, storage: StorageLike, options?: Partial<StorageOptions<T>>);
|
|
18
|
+
_debug(...args: string[]): void;
|
|
11
19
|
/**
|
|
12
20
|
* 设置值
|
|
13
21
|
*/
|
|
@@ -16,7 +24,7 @@ declare class Storage<T = any> {
|
|
|
16
24
|
* 获取值
|
|
17
25
|
*/
|
|
18
26
|
getItem(): T | null;
|
|
19
|
-
getItem(defaultVal:
|
|
27
|
+
getItem(defaultVal: DefaultVal<T>): T;
|
|
20
28
|
/**
|
|
21
29
|
* 删除值
|
|
22
30
|
*/
|
|
@@ -24,17 +32,21 @@ declare class Storage<T = any> {
|
|
|
24
32
|
/**
|
|
25
33
|
* 更新值
|
|
26
34
|
*/
|
|
27
|
-
updateItem(val:
|
|
35
|
+
updateItem(val: DefaultVal<T>): T;
|
|
28
36
|
/**
|
|
29
37
|
* 获取值后,删除存储的值
|
|
30
38
|
*/
|
|
31
39
|
getItemOnce(): T | null;
|
|
32
|
-
getItemOnce(defaultVal:
|
|
40
|
+
getItemOnce(defaultVal: DefaultVal<T>): T;
|
|
33
41
|
/**
|
|
34
42
|
* 优先从缓存中获取值
|
|
35
43
|
*/
|
|
36
44
|
getItemWithCache(): T | null;
|
|
37
|
-
getItemWithCache(defaultVal:
|
|
45
|
+
getItemWithCache(defaultVal: DefaultVal<T>): T;
|
|
46
|
+
/**
|
|
47
|
+
* 清除缓存
|
|
48
|
+
*/
|
|
49
|
+
clearCache(): void;
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
export { Storage };
|
package/lib/toPosix.cjs
ADDED