node-consul-service 1.0.17 → 1.0.18

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.
@@ -2,7 +2,7 @@ interface LinkSchema {
2
2
  filed: string;
3
3
  service: string;
4
4
  path: string;
5
- cacheGetter?: (id: string) => Promise<any>;
5
+ cacheGetter?: (ids: string[]) => Promise<(any | null)[]>;
6
6
  }
7
7
  export declare function dataLink(data: any[], schema: LinkSchema[]): Promise<any[]>;
8
8
  export {};
package/dist/index.cjs.js CHANGED
@@ -19422,14 +19422,15 @@ async function dataLink(data, schema) {
19422
19422
  let cacheMap = new Map();
19423
19423
  let idsToFetch = uniqueIds;
19424
19424
  if (cacheGetter) {
19425
- const cacheResults = await Promise.all(uniqueIds.map((id) => cacheGetter(id)));
19425
+ const cacheResults = await cacheGetter(uniqueIds);
19426
19426
  idsToFetch = [];
19427
19427
  cacheResults.forEach((item, index) => {
19428
+ const id = uniqueIds[index];
19428
19429
  if (item) {
19429
- cacheMap.set(uniqueIds[index], item);
19430
+ cacheMap.set(id, item);
19430
19431
  }
19431
19432
  else {
19432
- idsToFetch.push(uniqueIds[index]);
19433
+ idsToFetch.push(id);
19433
19434
  }
19434
19435
  });
19435
19436
  }
package/dist/index.esm.js CHANGED
@@ -19420,14 +19420,15 @@ async function dataLink(data, schema) {
19420
19420
  let cacheMap = new Map();
19421
19421
  let idsToFetch = uniqueIds;
19422
19422
  if (cacheGetter) {
19423
- const cacheResults = await Promise.all(uniqueIds.map((id) => cacheGetter(id)));
19423
+ const cacheResults = await cacheGetter(uniqueIds);
19424
19424
  idsToFetch = [];
19425
19425
  cacheResults.forEach((item, index) => {
19426
+ const id = uniqueIds[index];
19426
19427
  if (item) {
19427
- cacheMap.set(uniqueIds[index], item);
19428
+ cacheMap.set(id, item);
19428
19429
  }
19429
19430
  else {
19430
- idsToFetch.push(uniqueIds[index]);
19431
+ idsToFetch.push(id);
19431
19432
  }
19432
19433
  });
19433
19434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",