Skip to content

Commit

Permalink
fix(vats): ensure nameHub API returns arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 7, 2022
1 parent 956885c commit fac4476
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
25 changes: 16 additions & 9 deletions packages/vats/src/nameHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,26 @@ export const makeNameHubKit = () => {
return E(firstValue).lookup(...remaining);
},
entries() {
return mapIterable(keyToRecord.entries(), ([key, record]) => [
key,
record.promise || record.value,
]);
return [
...mapIterable(
keyToRecord.entries(),
([key, record]) => /** @type {[string, ERef<unknown>]} */ ([
key,
record.promise || record.value,
]),
),
];
},
values() {
return mapIterable(
keyToRecord.values(),
record => record.promise || record.value,
);
return [
...mapIterable(
keyToRecord.values(),
record => record.promise || record.value,
),
];
},
keys() {
return keyToRecord.keys();
return [...keyToRecord.keys()];
},
});

Expand Down
11 changes: 8 additions & 3 deletions packages/vats/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@

/**
* @typedef {Object} NameHub
*
* NOTE: We need to return arrays, not iterables, because even if marshal could
* allow passing a remote iterable, there would be an inordinate number of round
* trips for the contents of even the simplest nameHub.
*
* @property {(...path: Array<string>) => Promise<any>} lookup Look up a
* path of keys starting from the current NameHub. Wait on any reserved
* promises.
* @property {() => Iterable<[string, unknown]>} entries get all the entries
* @property {() => [string, unknown][]} entries get all the entries
* available in the current NameHub
* @property {() => Iterable<string>} keys get all names available in the
* @property {() => string[]} keys get all names available in the
* current NameHub
* @property {() => Iterable<unknown>} values get all values available in the
* @property {() => unknown[]} values get all values available in the
* current NameHub
*/

Expand Down

0 comments on commit fac4476

Please sign in to comment.