v-dict 1.0.8 → 1.0.9

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/dist/index.cjs CHANGED
@@ -76,14 +76,13 @@ function createDictManager(managerOptions = {}) {
76
76
  async function loadDict(options, mapRef) {
77
77
  const dataMap = toMap(lodashEs.cloneDeep(data));
78
78
  if (remote) {
79
- await (fetch == null ? void 0 : fetch(code, options).then((res) => {
80
- mapRef.value = toMap(res != null ? res : []);
81
- dataMap.forEach((value, key) => {
82
- if (mapRef.value.has(key)) {
83
- lodashEs.merge(mapRef.value.get(key), value);
84
- }
85
- });
86
- }));
79
+ const res = await (fetch == null ? void 0 : fetch(code, options));
80
+ mapRef.value = toMap(res != null ? res : []);
81
+ dataMap.forEach((value, key) => {
82
+ if (mapRef.value.has(key)) {
83
+ lodashEs.merge(mapRef.value.get(key), value);
84
+ }
85
+ });
87
86
  } else {
88
87
  mapRef.value = dataMap;
89
88
  }
@@ -116,10 +115,11 @@ function createDictManager(managerOptions = {}) {
116
115
  load();
117
116
  }
118
117
  function load(options) {
118
+ const oldP = loadPromise.value;
119
119
  loadPromise.value = createPromise();
120
120
  loadDict(lodashEs.merge({}, useDictOptions, options), mapRef).then(() => {
121
- var _a2;
122
- (_a2 = loadPromise.value) == null ? void 0 : _a2.resolve();
121
+ oldP.resolve();
122
+ loadPromise.value.resolve();
123
123
  });
124
124
  return loadPromise.value;
125
125
  }
package/dist/index.js CHANGED
@@ -74,14 +74,13 @@ function createDictManager(managerOptions = {}) {
74
74
  async function loadDict(options, mapRef) {
75
75
  const dataMap = toMap(cloneDeep(data));
76
76
  if (remote) {
77
- await (fetch == null ? void 0 : fetch(code, options).then((res) => {
78
- mapRef.value = toMap(res != null ? res : []);
79
- dataMap.forEach((value, key) => {
80
- if (mapRef.value.has(key)) {
81
- merge(mapRef.value.get(key), value);
82
- }
83
- });
84
- }));
77
+ const res = await (fetch == null ? void 0 : fetch(code, options));
78
+ mapRef.value = toMap(res != null ? res : []);
79
+ dataMap.forEach((value, key) => {
80
+ if (mapRef.value.has(key)) {
81
+ merge(mapRef.value.get(key), value);
82
+ }
83
+ });
85
84
  } else {
86
85
  mapRef.value = dataMap;
87
86
  }
@@ -114,10 +113,11 @@ function createDictManager(managerOptions = {}) {
114
113
  load();
115
114
  }
116
115
  function load(options) {
116
+ const oldP = loadPromise.value;
117
117
  loadPromise.value = createPromise();
118
118
  loadDict(merge({}, useDictOptions, options), mapRef).then(() => {
119
- var _a2;
120
- (_a2 = loadPromise.value) == null ? void 0 : _a2.resolve();
119
+ oldP.resolve();
120
+ loadPromise.value.resolve();
121
121
  });
122
122
  return loadPromise.value;
123
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v-dict",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "description": "Vue3 Dict Manager",
6
6
  "repository": {