@esportsplus/web-storage 0.0.7 → 0.0.8

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/build/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import local from './local';
2
2
  declare const _default: {
3
3
  local: {
4
4
  clear: () => void;
5
- delete: (key: string) => void;
5
+ delete: (key: string) => Promise<void>;
6
6
  get: (key: string, value?: any) => Promise<any>;
7
7
  has: (key: string) => Promise<boolean>;
8
8
  prepend: (key: string, value: any) => Promise<void>;
@@ -10,7 +10,7 @@ declare const _default: {
10
10
  replace: (values: {
11
11
  [key: string]: any;
12
12
  }) => void;
13
- set: (key: string, value: any) => void;
13
+ set: (key: string, value: any) => Promise<void>;
14
14
  useIndexedDB: (options?: import("./local/types").Options) => void;
15
15
  useLocalStorage: (options?: import("./local/types").Options) => void;
16
16
  useOptions: (options?: import("./local/types").Options) => void;
@@ -1,7 +1,7 @@
1
1
  import type { Options } from './types';
2
2
  declare const _default: {
3
3
  clear: () => void;
4
- delete: (key: string) => void;
4
+ delete: (key: string) => Promise<void>;
5
5
  get: (key: string, value?: any) => Promise<any>;
6
6
  has: (key: string) => Promise<boolean>;
7
7
  prepend: (key: string, value: any) => Promise<void>;
@@ -9,7 +9,7 @@ declare const _default: {
9
9
  replace: (values: {
10
10
  [key: string]: any;
11
11
  }) => void;
12
- set: (key: string, value: any) => void;
12
+ set: (key: string, value: any) => Promise<void>;
13
13
  useIndexedDB: (options?: Options) => void;
14
14
  useLocalStorage: (options?: Options) => void;
15
15
  useOptions: (options?: Options) => void;
@@ -4,18 +4,18 @@ let cache = {}, driver = localforage.LOCALSTORAGE;
4
4
  function init(options = {}) {
5
5
  localforage.config(Object.assign({ name: 'store' }, options, { driver }));
6
6
  }
7
- function sync(key) {
7
+ async function sync(key) {
8
8
  let root = (key.split('.')[0] || '');
9
- localforage.setItem(root, dot.get(cache, root));
9
+ await localforage.setItem(root, dot.get(cache, root));
10
10
  }
11
11
  const clear = () => {
12
12
  cache = {};
13
13
  localforage.clear();
14
14
  };
15
- const del = (key) => {
15
+ const del = async (key) => {
16
16
  dot.set(cache, key, undefined);
17
17
  if (key.includes('.')) {
18
- sync(key);
18
+ await sync(key);
19
19
  }
20
20
  else {
21
21
  localforage.removeItem(key);
@@ -72,9 +72,9 @@ const replace = (values) => {
72
72
  set(key, values[key]);
73
73
  }
74
74
  };
75
- const set = (key, value) => {
75
+ const set = async (key, value) => {
76
76
  dot.set(cache, key, value);
77
- sync(key);
77
+ await sync(key);
78
78
  };
79
79
  const useIndexedDB = (options = {}) => {
80
80
  driver = localforage.INDEXEDDB;
package/package.json CHANGED
@@ -26,5 +26,5 @@
26
26
  "prepublishOnly": "npm run build"
27
27
  },
28
28
  "types": "./build/index.d.ts",
29
- "version": "0.0.7"
29
+ "version": "0.0.8"
30
30
  }
@@ -11,10 +11,10 @@ function init(options: Options = {}): void {
11
11
  localforage.config(Object.assign({ name: 'store' }, options, { driver }));
12
12
  }
13
13
 
14
- function sync(key: string) {
14
+ async function sync(key: string) {
15
15
  let root = (key.split('.')[0] || '');
16
16
 
17
- localforage.setItem(root, dot.get(cache, root));
17
+ await localforage.setItem(root, dot.get(cache, root));
18
18
  }
19
19
 
20
20
 
@@ -23,11 +23,11 @@ const clear = () => {
23
23
  localforage.clear();
24
24
  };
25
25
 
26
- const del = (key: string): void => {
26
+ const del = async (key: string): Promise<void> => {
27
27
  dot.set(cache, key, undefined);
28
28
 
29
29
  if (key.includes('.')) {
30
- sync(key);
30
+ await sync(key);
31
31
  }
32
32
  else {
33
33
  localforage.removeItem(key);
@@ -108,9 +108,9 @@ const replace = (values: { [key: string]: any }): void => {
108
108
  }
109
109
  };
110
110
 
111
- const set = (key: string, value: any): void => {
111
+ const set = async (key: string, value: any): Promise<void> => {
112
112
  dot.set(cache, key, value);
113
- sync(key);
113
+ await sync(key);
114
114
  };
115
115
 
116
116
  const useIndexedDB = (options: Options = {}): void => {