@daysnap/utils 0.0.26 → 0.0.27
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/es/storage/index.d.ts +2 -2
- package/es/storage/index.js +11 -2
- package/lib/storage/index.d.ts +2 -2
- package/lib/storage/index.js +14 -5
- package/package.json +1 -1
package/es/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getCache: () => {
|
|
2
2
|
setItem: <T>(key: string, val: T) => T;
|
|
3
3
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
4
4
|
removeItem: (key: string) => void;
|
|
@@ -11,7 +11,7 @@ export declare const cache: {
|
|
|
11
11
|
updateItem: (val: Partial<T_3>) => T_3;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getLocal: () => {
|
|
15
15
|
setItem: <T>(key: string, val: T) => T;
|
|
16
16
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
17
17
|
removeItem: (key: string) => void;
|
package/es/storage/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { factory } from './factory';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var getStorage = function getStorage(type) {
|
|
3
|
+
var instance = null;
|
|
4
|
+
return function () {
|
|
5
|
+
if (!instance) {
|
|
6
|
+
instance = factory(type);
|
|
7
|
+
}
|
|
8
|
+
return instance;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export var getCache = getStorage('sessionStorage');
|
|
12
|
+
export var getLocal = getStorage('localStorage');
|
package/lib/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getCache: () => {
|
|
2
2
|
setItem: <T>(key: string, val: T) => T;
|
|
3
3
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
4
4
|
removeItem: (key: string) => void;
|
|
@@ -11,7 +11,7 @@ export declare const cache: {
|
|
|
11
11
|
updateItem: (val: Partial<T_3>) => T_3;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getLocal: () => {
|
|
15
15
|
setItem: <T>(key: string, val: T) => T;
|
|
16
16
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
17
17
|
removeItem: (key: string) => void;
|
package/lib/storage/index.js
CHANGED
|
@@ -3,9 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getLocal = exports.getCache = void 0;
|
|
7
7
|
var _factory = require("./factory");
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
var getStorage = function getStorage(type) {
|
|
9
|
+
var instance = null;
|
|
10
|
+
return function () {
|
|
11
|
+
if (!instance) {
|
|
12
|
+
instance = (0, _factory.factory)(type);
|
|
13
|
+
}
|
|
14
|
+
return instance;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var getCache = getStorage('sessionStorage');
|
|
18
|
+
exports.getCache = getCache;
|
|
19
|
+
var getLocal = getStorage('localStorage');
|
|
20
|
+
exports.getLocal = getLocal;
|