@esportsplus/web-storage 0.0.5 → 0.0.6

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.
@@ -39,11 +39,14 @@ const has = async (key) => {
39
39
  if (dot.has(cache, key)) {
40
40
  return true;
41
41
  }
42
- let value = await localforage.getItem(key.split('.')[0] || '');
42
+ let k = key.split('.'), f = k.shift() || '', value = await localforage.getItem(f);
43
43
  if (value !== null) {
44
- set(key, value);
44
+ set(f, value);
45
+ if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
46
+ return dot.has(value, k.join('.'));
47
+ }
45
48
  }
46
- return value !== null;
49
+ return false;
47
50
  };
48
51
  const prepend = async (key, value) => {
49
52
  let values = await get(key, []);
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "author": "ICJR",
3
- "dependencies": {
4
- "@esportsplus/dot": "^0.0.3",
5
- "localforage": "^1.10.0"
6
- },
7
- "description": "Web storage utility",
8
- "devDependencies": {
9
- "glob": "^7.1.7",
10
- "node-polyfill-webpack-plugin": "^1.1.4",
11
- "npm-run-all": "^4.1.5",
12
- "ts-loader": "^9.2.6",
13
- "tsc-alias": "^1.5.0",
14
- "tsconfig-paths-webpack-plugin": "^3.5.2",
15
- "typescript": "^4.5.2",
16
- "webpack": "^5.64.4",
17
- "webpack-cli": "^4.9.1"
18
- },
19
- "main": "./build/index.js",
20
- "name": "@esportsplus/web-storage",
21
- "private": false,
22
- "scripts": {
23
- "build": "tsc",
24
- "-": "-",
25
- "prepare": "npm run build",
26
- "prepublishOnly": "npm run build"
27
- },
28
- "types": "./build/index.d.ts",
29
- "version": "0.0.5"
30
- }
1
+ {
2
+ "author": "ICJR",
3
+ "dependencies": {
4
+ "@esportsplus/dot": "^0.0.3",
5
+ "localforage": "^1.10.0"
6
+ },
7
+ "description": "Web storage utility",
8
+ "devDependencies": {
9
+ "glob": "^7.1.7",
10
+ "node-polyfill-webpack-plugin": "^1.1.4",
11
+ "npm-run-all": "^4.1.5",
12
+ "ts-loader": "^9.2.6",
13
+ "tsc-alias": "^1.5.0",
14
+ "tsconfig-paths-webpack-plugin": "^3.5.2",
15
+ "typescript": "^4.5.2",
16
+ "webpack": "^5.64.4",
17
+ "webpack-cli": "^4.9.1"
18
+ },
19
+ "main": "./build/index.js",
20
+ "name": "@esportsplus/web-storage",
21
+ "private": false,
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "-": "-",
25
+ "prepare": "npm run build",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "types": "./build/index.d.ts",
29
+ "version": "0.0.6"
30
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import local from './local';
2
-
3
-
4
- export default { local };
5
- export { local };
1
+ import local from './local';
2
+
3
+
4
+ export default { local };
5
+ export { local };
@@ -59,13 +59,19 @@ const has = async (key: string): Promise<boolean> => {
59
59
  return true;
60
60
  }
61
61
 
62
- let value: any = await localforage.getItem(key.split('.')[0] || '');
62
+ let k = key.split('.'),
63
+ f = k.shift() || '',
64
+ value = await localforage.getItem(f);
63
65
 
64
66
  if (value !== null) {
65
- set(key, value);
67
+ set(f, value);
68
+
69
+ if (typeof value === 'object' && !Array.isArray(value) && value !== null) {
70
+ return dot.has(value, k.join('.'));
71
+ }
66
72
  }
67
73
 
68
- return value !== null;
74
+ return false;
69
75
  };
70
76
 
71
77
  const prepend = async (key: string, value: any): Promise<void> => {