@inappstory/game-center-api 1.0.10 → 1.0.11

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.
@@ -1,6 +1,7 @@
1
1
  export declare class LocalDataMap<K, V> extends Map<K, V> {
2
2
  set(key: K, value: V): this;
3
3
  delete(key: K): boolean;
4
+ protected init(entries: [K, V][]): this;
4
5
  }
5
6
  export declare let gameLocalData: LocalDataMap<string, any>;
6
7
  export declare const initLocalData: () => Promise<void>;
package/lib/localData.js CHANGED
@@ -24,15 +24,19 @@ class LocalDataMap extends Map {
24
24
  }
25
25
  return removed;
26
26
  }
27
+ init(entries) {
28
+ entries.forEach(entrie => super.set(entrie[0], entrie[1]));
29
+ return this;
30
+ }
27
31
  }
28
32
  exports.LocalDataMap = LocalDataMap;
29
- exports.gameLocalData = new Map();
33
+ exports.gameLocalData = new LocalDataMap();
30
34
  let localDataCreated = false;
31
35
  const initLocalData = async () => {
32
36
  if (localDataCreated) {
33
37
  console.warn("Duplicate call of initLocalData. Skipping");
34
38
  }
35
- exports.gameLocalData = new LocalDataMap(Object.entries(await getClientLocalData()));
39
+ exports.gameLocalData.init(Object.entries(await getClientLocalData()));
36
40
  localDataCreated = true;
37
41
  };
38
42
  exports.initLocalData = initLocalData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/game-center-api",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "semver": "^7.3.8",