From dd7156b3396de68620fc36a30fec0271c551a321 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Sat, 31 Oct 2020 00:05:32 -0700 Subject: [PATCH] fix: rename multicast iterable to multicaster --- packages/notifier/src/index.js | 2 +- ...{multicastIteratable.js => multicaster.js} | 48 +++++++++---------- packages/notifier/src/types.js | 10 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) rename packages/notifier/src/{multicastIteratable.js => multicaster.js} (70%) diff --git a/packages/notifier/src/index.js b/packages/notifier/src/index.js index 549a55b31b1a..936b6fbb7afe 100644 --- a/packages/notifier/src/index.js +++ b/packages/notifier/src/index.js @@ -1,3 +1,3 @@ export * from './notifier'; -export * from './multicastIteratable'; +export * from './multicaster'; export * from './asyncIterableAdaptor'; diff --git a/packages/notifier/src/multicastIteratable.js b/packages/notifier/src/multicaster.js similarity index 70% rename from packages/notifier/src/multicastIteratable.js rename to packages/notifier/src/multicaster.js index b1d6542d7359..12a0c07baff2 100644 --- a/packages/notifier/src/multicastIteratable.js +++ b/packages/notifier/src/multicaster.js @@ -10,9 +10,9 @@ import './types'; /** * @template T * @param {MulticastInternals} startP - * @returns {MulticastIterable} + * @returns {Multicaster} */ -const makeMulticastIterable = startP => { +const makeMulticaster = startP => { return harden({ // eslint-disable-next-line no-use-before-define [Symbol.asyncIterator]: () => makeMulticastIterator(startP), @@ -22,8 +22,8 @@ const makeMulticastIterable = startP => { getSharableInternals: () => startP, }); }; -harden(makeMulticastIterable); -export { makeMulticastIterable }; +harden(makeMulticaster); +export { makeMulticaster }; /** * @template T @@ -34,7 +34,7 @@ const makeMulticastIterator = tailP => { // To understand the implementation, start with // https://web.archive.org/web/20160404122250/http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#infinite_queue return harden({ - snapshot: () => makeMulticastIterable(tailP), + snapshot: () => makeMulticaster(tailP), [Symbol.asyncIterator]: () => makeMulticastIterator(tailP), next: () => { const resultP = E.G(tailP).head; @@ -45,15 +45,15 @@ const makeMulticastIterator = tailP => { }; /** - * `makeMulticastIterableKit()` makes an entanged `{updater, multicastIterable}` + * `makeMulticasterKit()` makes an entanged `{updater, multicaster}` * pair which purposely resembles `makeNotifierKit` making an entangled * `{updater, notifier}` pair. * * Both `updater`s have the same API with the same meaning --- to push a * sequence of non-final values, terminated with either a final successful * completion value or failure reason. In both cases, the other side of the - * pair---the `multicastIterable` or `notifier`---implements the JavaScript - * standard async iterator API, and so may be read using a JavaScript + * pair---the `multicaster` or `notifier`---implements the JavaScript + * standard async iteratable API, and so may be read using a JavaScript * `for-await-of` loop. * * In both cases, all the non-final values read will be non-final values pushed @@ -67,29 +67,29 @@ const makeMulticastIterator = tailP => { * `multicastIterator` returned here provides lossless access to the entire * stream of non-final values. (Both losslessly report termination.) * - * Of the `{updater, multicastIterable}` pair returned by `makeIterableKit()`, - * this initial `multicastIterable` represents the stream starting with the - * first update to the `updater`. Each multicast iterable makes any number of + * Of the `{updater, multicaster}` pair returned by `makeMulticasterKit()`, + * this initial `multicaster` represents the stream starting with the + * first update to the `updater`. Each multicaster makes any number of * multicast iterators, each of which advance independently starting at that * iterable's starting point. These multicast iterators also have a - * `snapshot()` method which will create a new multicast iterable capturing the + * `snapshot()` method which will create a new multicaster capturing the * iterator's current position as the new iterable's starting point. * - * As is conventional, the multicast iterator is also an multicast iterable that - * produces an multicast iterator. In this case, it produces a new multicast - * iterator that advances independently starting from the current position. + * As is conventional, the iterator is itself also an iterable. + * Here this means the multicast iterator is also a multicaster + * (a kind of iterable) that produces a multicast iterator. In this case, + * it produces a new multicast iterator that advances independently starting + * from the current position. * - * The internal representation ensure that elements that are no longer + * The internal representation ensures that elements that are no longer * observable are unreachable and can be gc'ed. * * @template T - * @returns {MulticastIteratorRecord} + * @returns {MulticasterRecord} */ -const makeMulticastIteratableKit = () => { +const makeMulticasterKit = () => { let rear; - const multicastIterable = makeMulticastIterable( - new HandledPromise(r => (rear = r)), - ); + const multicaster = makeMulticaster(new HandledPromise(r => (rear = r))); const updater = harden({ updateState: value => { @@ -118,7 +118,7 @@ const makeMulticastIteratableKit = () => { rear = undefined; }, }); - return harden({ updater, multicastIterable }); + return harden({ updater, multicaster }); }; -harden(makeMulticastIteratableKit); -export { makeMulticastIteratableKit }; +harden(makeMulticasterKit); +export { makeMulticasterKit }; diff --git a/packages/notifier/src/types.js b/packages/notifier/src/types.js index 23e012904e59..eae7bb3943c6 100644 --- a/packages/notifier/src/types.js +++ b/packages/notifier/src/types.js @@ -79,7 +79,7 @@ /** * @template T - * @typedef {AsyncIterable} MulticastIterable A form of AsyncIterable + * @typedef {AsyncIterable} Multicaster A form of AsyncIterable * supporting distributed and multicast usage. * * TODO How do I declare a symbol-named property in the JSDoc type syntax? @@ -89,7 +89,7 @@ * * @property {() => MulticastInternals} getSharableInternals Used to replicate * the multicast values at other sites. To manually create a local - * representative of a MulticastIterable, do + * representative of a Multicaster, do * ```js * localIterable = makeAsyncIterable(E(remoteIterable).getSharableInternals()); * ``` @@ -102,13 +102,13 @@ * @typedef {AsyncIterator & AsyncIterable} MulticastIterator * an AsyncIterator supporting distributed and multicast usage. * - * @property {() => MulticastIterable} snapshot + * @property {() => Multicaster} snapshot * */ /** * @template T - * @typedef {Object} MulticastIteratorRecord + * @typedef {Object} MulticasterRecord * @property {Updater} updater - * @property {MulticastIterable} multicastIterable + * @property {Multicaster} multicaster */