@daysnap/utils 0.0.25 → 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 +6 -3
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;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daysnap/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "通用的工具库",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"typings": "lib/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"ts-node": "npx ts-node --project ./tsconfig.json ./src/filename.ts",
|
|
10
9
|
"gen": "plop --plopfile ./scripts/gen.js --force",
|
|
11
10
|
"del": "plop --plopfile ./scripts/del.js --force",
|
|
12
11
|
"entry": "plop --plopfile ./scripts/entry.js --force",
|
|
13
12
|
"build": "dsc build",
|
|
14
13
|
"test": "jest",
|
|
15
14
|
"coverage": "jest --coverage",
|
|
16
|
-
"
|
|
15
|
+
"predeploy": "npm run test",
|
|
16
|
+
"deploy": "npm run build && dsc publish",
|
|
17
17
|
"husky": "husky install && echo 'export PATH=\"/usr/local/bin/:$PATH\"' >> ~/.huskyrc",
|
|
18
18
|
"lint": "eslint 'src/**/*.{js,ts}' --fix",
|
|
19
19
|
"prepare": "husky install && echo 'export PATH=\"/usr/local/bin/:$PATH\"' >> ~/.huskyrc"
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@commitlint/cli": "^16.2.1",
|
|
42
42
|
"@commitlint/config-conventional": "^16.2.1",
|
|
43
|
+
"@types/jest": "^29.2.3",
|
|
43
44
|
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
44
45
|
"@typescript-eslint/parser": "^5.40.0",
|
|
45
46
|
"commitizen": "^4.2.4",
|
|
@@ -49,11 +50,13 @@
|
|
|
49
50
|
"eslint-plugin-import": "^2.26.0",
|
|
50
51
|
"eslint-plugin-prettier": "^4.2.1",
|
|
51
52
|
"husky": "^7.0.4",
|
|
53
|
+
"jest": "^27.5.1",
|
|
52
54
|
"lint-staged": "^13.0.3",
|
|
53
55
|
"node-dir": "^0.1.17",
|
|
54
56
|
"plop": "^3.1.1",
|
|
55
57
|
"prettier": "^2.7.1",
|
|
56
58
|
"rimraf": "^3.0.2",
|
|
59
|
+
"ts-jest": "^27.1.4",
|
|
57
60
|
"ts-node": "^10.9.1",
|
|
58
61
|
"typescript": "^4.8.4"
|
|
59
62
|
},
|