@esportsplus/web-storage 0.1.13 → 0.1.14

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
@@ -1,7 +1,7 @@
1
1
  import local from './local';
2
2
  declare const _default: {
3
3
  local: {
4
- store: (options?: LocalForageOptions) => {
4
+ store: (options: import("./local/types").Options) => {
5
5
  instance: LocalForage;
6
6
  iterate: <T, U>(iteratee: (value: T, key: string, iterationNumber: number) => U, callback?: ((err: any, result: U) => void) | undefined) => Promise<U>;
7
7
  keys: (callback?: ((err: any, keys: string[]) => void) | undefined) => Promise<string[]>;
@@ -1,10 +1,10 @@
1
- import { Object } from './types';
1
+ import { Object, Options } from './types';
2
2
  declare class Store {
3
3
  instance: LocalForage;
4
4
  iterate: LocalForage['iterate'];
5
5
  keys: LocalForage['keys'];
6
6
  length: LocalForage['length'];
7
- constructor(options?: LocalForageOptions);
7
+ constructor(options: Options);
8
8
  all(): Promise<Object>;
9
9
  clear(): Promise<void>;
10
10
  delete(...keys: string[]): Promise<void>;
@@ -16,6 +16,6 @@ declare class Store {
16
16
  }): Promise<void>;
17
17
  }
18
18
  declare const _default: {
19
- store: (options?: LocalForageOptions) => Store;
19
+ store: (options: Options) => Store;
20
20
  };
21
21
  export default _default;
@@ -10,8 +10,8 @@ class Store {
10
10
  iterate;
11
11
  keys;
12
12
  length;
13
- constructor(options = {}) {
14
- let driver, name = options.name || 'store';
13
+ constructor(options) {
14
+ let driver;
15
15
  switch ((options.driver || types_1.Driver.IndexedDB)) {
16
16
  case types_1.Driver.LocalStorage:
17
17
  driver = localforage_1.default.LOCALSTORAGE;
@@ -20,7 +20,7 @@ class Store {
20
20
  driver = localforage_1.default.INDEXEDDB;
21
21
  break;
22
22
  }
23
- this.instance = localforage_1.default.createInstance(Object.assign(options, { driver, name, storeName: name }));
23
+ this.instance = localforage_1.default.createInstance(Object.assign(options, { driver, storeName: options.name }));
24
24
  this.iterate = this.instance.iterate;
25
25
  this.keys = this.instance.keys;
26
26
  this.length = this.instance.length;
@@ -83,5 +83,5 @@ class Store {
83
83
  }
84
84
  }
85
85
  exports.default = {
86
- store: (options = {}) => new Store(options)
86
+ store: (options) => new Store(options)
87
87
  };
@@ -5,4 +5,7 @@ declare enum Driver {
5
5
  declare type Object = {
6
6
  [key: string]: any;
7
7
  };
8
- export { Driver, Object };
8
+ declare type Options = LocalForageOptions & {
9
+ name: string;
10
+ };
11
+ export { Driver, Object, Options };
package/package.json CHANGED
@@ -23,5 +23,5 @@
23
23
  "prepublishOnly": "npm run build"
24
24
  },
25
25
  "types": "./build/index.d.ts",
26
- "version": "0.1.13"
26
+ "version": "0.1.14"
27
27
  }
@@ -1,4 +1,4 @@
1
- import { Driver, Object } from './types';
1
+ import { Driver, Object, Options } from './types';
2
2
  import localforage from 'localforage';
3
3
 
4
4
 
@@ -9,9 +9,8 @@ class Store {
9
9
  length: LocalForage['length'];
10
10
 
11
11
 
12
- constructor(options: LocalForageOptions = {}) {
13
- let driver,
14
- name = options.name || 'store';
12
+ constructor(options: Options) {
13
+ let driver;
15
14
 
16
15
  switch ((options.driver || Driver.IndexedDB) as Driver) {
17
16
  case Driver.LocalStorage:
@@ -23,7 +22,7 @@ class Store {
23
22
  }
24
23
 
25
24
  this.instance = localforage.createInstance(
26
- Object.assign(options, { driver, name, storeName: name })
25
+ Object.assign(options, { driver, storeName: options.name })
27
26
  );
28
27
  this.iterate = this.instance.iterate;
29
28
  this.keys = this.instance.keys;
@@ -112,5 +111,5 @@ class Store {
112
111
 
113
112
 
114
113
  export default {
115
- store: (options: LocalForageOptions = {}): Store => new Store(options)
114
+ store: (options: Options): Store => new Store(options)
116
115
  };
@@ -5,5 +5,7 @@ enum Driver {
5
5
 
6
6
  type Object = { [key: string]: any };
7
7
 
8
+ type Options = LocalForageOptions & { name: string };
8
9
 
9
- export { Driver, Object };
10
+
11
+ export { Driver, Object, Options };