diff --git a/package.json b/package.json index cccb6d694ee..b0625c81088 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "files": [ "packages/ERTP/**/*.{js,ts}", "packages/inter-protocol/**/*.{js,ts}", + "packages/store/**/*.{js,ts}", "packages/vats/**/*.{js,ts}" ], "options": { diff --git a/packages/store/src/legacy/legacyMap.js b/packages/store/src/legacy/legacyMap.js index a0b9346acd4..82bd73e8783 100644 --- a/packages/store/src/legacy/legacyMap.js +++ b/packages/store/src/legacy/legacyMap.js @@ -3,35 +3,37 @@ import { q, Fail } from '@agoric/assert'; import '../types.js'; /** - * This module and its fraternal sibling legacyWeakMap exist only to - * ease a transition to the modern `store` system, are deprecated, - * and will eventually disappear. They are needed for now to support - * some of the uses of the old behavior that are not compatible with - * the new. The constraint imposed by the new is that only passables can - * be used as values, and only keys (roughly, structures, aka comparables) - * can be used as values. + * This module and its fraternal sibling legacyWeakMap exist only to ease a + * transition to the modern `store` system, are deprecated, and will eventually + * disappear. They are needed for now to support some of the uses of the old + * behavior that are not compatible with the new. The constraint imposed by the + * new is that only passables can be used as values, and only keys (roughly, + * structures, aka comparables) can be used as values. * * See https://github.com/Agoric/agoric-sdk/pull/3567 + * * TODO Once that PR is merged, link to the documents rather than the PRs. * * Each of these non-conforming uses should be marked with a + * * ```js * // Legacy because... * ``` - * comment explaining the problem inhibiting conversion to the new - * system. Some of these problems as of this writing: - * * A promiseKit used as a value, even though a promiseKit is not - * a passable. Solutions are to make it a passable, or to convert - * the container back to a conventional JavaScript Map. - * * A mutable array used as a value, that is subsequently mutated. - * Freezing the array wouldn't work of course because it would break - * the subsequent mutation. Using a far object wrapping an array would - * likely work fine. + * + * comment explaining the problem inhibiting conversion to the new system. Some + * of these problems as of this writing: + * + * - A promiseKit used as a value, even though a promiseKit is not a passable. + * Solutions are to make it a passable, or to convert the container back to a + * conventional JavaScript Map. + * - A mutable array used as a value, that is subsequently mutated. Freezing the + * array wouldn't work of course because it would break the subsequent + * mutation. Using a far object wrapping an array would likely work fine. * * @deprecated switch to ScalarMap if possible, Map otherwise * @template K,V * @param {string} [tag] - tag for debugging - * @returns {LegacyMap} + * @returns {LegacyMap} */ export const makeLegacyMap = (tag = 'key') => { const m = new Map(); diff --git a/packages/store/src/legacy/legacyWeakMap.js b/packages/store/src/legacy/legacyWeakMap.js index 1f9e9a9241e..26337e07c12 100644 --- a/packages/store/src/legacy/legacyWeakMap.js +++ b/packages/store/src/legacy/legacyWeakMap.js @@ -7,7 +7,7 @@ import '../types.js'; * @deprecated switch to ScalarWeakMap if possible, WeakMap otherwise * @template K,V * @param {string} [tag] - tag for debugging - * @returns {LegacyWeakMap} + * @returns {LegacyWeakMap} */ export const makeLegacyWeakMap = (tag = 'key') => { /** @type {WeakMap} */ diff --git a/packages/store/src/stores/scalarMapStore.js b/packages/store/src/stores/scalarMapStore.js index d9dd8a35cf3..4440e2dc81c 100644 --- a/packages/store/src/stores/scalarMapStore.js +++ b/packages/store/src/stores/scalarMapStore.js @@ -20,12 +20,12 @@ const { quote: q } = assert; /** * @template {Key} K * @template {Passable} V - * @param {Map} jsmap + * @param {Map} jsmap * @param {(k: K, v: V) => void} assertKVOkToAdd * @param {(k: K, v: V) => void} assertKVOkToSet - * @param {((k: K) => void)} [assertKeyOkToDelete] + * @param {(k: K) => void} [assertKeyOkToDelete] * @param {string} [tag] - * @returns {MapStore} + * @returns {MapStore} */ export const makeMapStoreMethods = ( jsmap, @@ -77,7 +77,7 @@ export const makeMapStoreMethods = ( /** * @param {Pattern} [keyPatt] * @param {Pattern} [valuePatt] - * @returns {Iterable<[K,V]>} + * @returns {Iterable<[K, V]>} */ const entries = (keyPatt = undefined, valuePatt = undefined) => mapIterable(keys(keyPatt, valuePatt), k => [ @@ -117,13 +117,13 @@ export const makeMapStoreMethods = ( }; /** - * Distinguishes between adding a new key (init) and updating or - * referencing a key (get, set, delete). + * Distinguishes between adding a new key (init) and updating or referencing a + * key (get, set, delete). * - * `init` is only allowed if the key does not already exist. `Get`, - * `set` and `delete` are only allowed if the key does already exist. + * `init` is only allowed if the key does not already exist. `Get`, `set` and + * `delete` are only allowed if the key does already exist. * - * This is a *scalar* map in that the keys can only be atomic values, primitives + * This is a _scalar_ map in that the keys can only be atomic values, primitives * or remotables. Other storeMaps will accept, for example, copyArrays and * copyRecords, as keys and look them up based on equality of their contents. * @@ -131,7 +131,7 @@ export const makeMapStoreMethods = ( * @template {Passable} V * @param {string} [tag] - the column name for the key * @param {StoreOptions} [options] - * @returns {MapStore} + * @returns {MapStore} */ export const makeScalarMapStore = ( tag = 'key', diff --git a/packages/store/src/stores/scalarSetStore.js b/packages/store/src/stores/scalarSetStore.js index eee55dd36fd..11146e5f28c 100644 --- a/packages/store/src/stores/scalarSetStore.js +++ b/packages/store/src/stores/scalarSetStore.js @@ -74,13 +74,13 @@ export const makeSetStoreMethods = ( }; /** - * Distinguishes between adding a new key (init) and updating or - * referencing a key (get, set, delete). + * Distinguishes between adding a new key (init) and updating or referencing a + * key (get, set, delete). * - * `init` is only allowed if the key does not already exist. `Get`, - * `set` and `delete` are only allowed if the key does already exist. + * `init` is only allowed if the key does not already exist. `Get`, `set` and + * `delete` are only allowed if the key does already exist. * - * This is a *scalar* set in that the keys can only be atomic values, primitives + * This is a _scalar_ set in that the keys can only be atomic values, primitives * or remotables. Other storeSets will accept, for example, copyArrays and * copyRecords, as keys and look them up based on equality of their contents. * diff --git a/packages/store/src/stores/scalarWeakMapStore.js b/packages/store/src/stores/scalarWeakMapStore.js index 2634d878477..9bd3db54823 100644 --- a/packages/store/src/stores/scalarWeakMapStore.js +++ b/packages/store/src/stores/scalarWeakMapStore.js @@ -11,7 +11,7 @@ const { quote: q, Fail } = assert; * @param {(k: K, v: V) => void} assertKVOkToSet * @param {(k: K) => void} [assertKeyOkToDelete] * @param {string} [keyName] - * @returns {WeakMapStore} + * @returns {WeakMapStore} */ export const makeWeakMapStoreMethods = ( jsmap, @@ -75,22 +75,22 @@ export const makeWeakMapStoreMethods = ( }; /** - * This is a *scalar* mapStore in that the keys can only be atomic values: - * primitives or remotables. - * Other mapStores will accept, for example, copyArrays and - * copyRecords as keys and look them up based on equality of their contents. + * This is a _scalar_ mapStore in that the keys can only be atomic values: + * primitives or remotables. Other mapStores will accept, for example, + * copyArrays and copyRecords as keys and look them up based on equality of + * their contents. * * TODO For now, this scalarWeakMap accepts only remotables, reflecting the - * constraints of the underlying JavaScript WeakMap it uses internally. But - * it should accept the primitives as well, storing them in a separate internal + * constraints of the underlying JavaScript WeakMap it uses internally. But it + * should accept the primitives as well, storing them in a separate internal * map. What makes it "weak" is that it provides no API for enumerating what's - * there. Though note that this would only enables collection of the - * remotables, since the other primitives may always reappear. + * there. Though note that this would only enables collection of the remotables, + * since the other primitives may always reappear. * * @template K,V * @param {string} [tag] - tag for debugging * @param {StoreOptions} [options] - * @returns {WeakMapStore} + * @returns {WeakMapStore} */ export const makeScalarWeakMapStore = ( tag = 'key', diff --git a/packages/store/src/stores/scalarWeakSetStore.js b/packages/store/src/stores/scalarWeakSetStore.js index 6b99330446c..4a256ba9207 100644 --- a/packages/store/src/stores/scalarWeakSetStore.js +++ b/packages/store/src/stores/scalarWeakSetStore.js @@ -58,16 +58,16 @@ export const makeWeakSetStoreMethods = ( }; /** - * This is a *scalar* set in that the keys can only be atomic values, primitives + * This is a _scalar_ set in that the keys can only be atomic values, primitives * or remotables. Other storeSets will accept, for example, copyArrays and * copyRecords, as keys and look them up based on equality of their contents. * * TODO For now, this scalarWeakSet accepts only remotables, reflecting the - * constraints of the underlying JavaScript WeakSet it uses internally. But - * it should accept the primitives as well, storing them in a separate internal + * constraints of the underlying JavaScript WeakSet it uses internally. But it + * should accept the primitives as well, storing them in a separate internal * set. What makes it "weak" is that it provides no API for enumerating what's - * there. Though note that this would only enables collection of the - * remotables, since the other primitives may always appear. + * there. Though note that this would only enables collection of the remotables, + * since the other primitives may always appear. * * @template K * @param {string} [tag] - tag for debugging diff --git a/packages/store/src/stores/store-utils.js b/packages/store/src/stores/store-utils.js index f27d611d84c..2b1bd95f241 100644 --- a/packages/store/src/stores/store-utils.js +++ b/packages/store/src/stores/store-utils.js @@ -3,24 +3,24 @@ import { M, matches } from '@endo/patterns'; const { Fail, quote: q } = assert; +// TODO: Undate `@endo/patterns` to export the original, and delete the +// reimplementation here. /** - * Should behave identically to the one in `@endo/patterns`, but - * reimplemented for now because `@endo/patterns` forgot to export this one. - * This one is simple enough that I prefer a reimplementation to a deep import. - * TODO: Undate `@endo/patterns` to export the original, and delete the - * reimplementation here. + * Should behave identically to the one in `@endo/patterns`, but reimplemented + * for now because `@endo/patterns` forgot to export this one. This one is + * simple enough that I prefer a reimplementation to a deep import. * * @param {Passable} s * @returns {s is CopySet} */ export const isCopySet = s => matches(s, M.set()); +// TODO: Undate `@endo/patterns` to export the original, and delete the +// reimplementation here. /** - * Should behave identically to the one in `@endo/patterns`, but - * reimplemented for now because `@endo/patterns` forgot to export this one. - * This one is simple enough that I prefer a reimplementation to a deep import. - * TODO: Undate `@endo/patterns` to export the original, and delete the - * reimplementation here. + * Should behave identically to the one in `@endo/patterns`, but reimplemented + * for now because `@endo/patterns` forgot to export this one. This one is + * simple enough that I prefer a reimplementation to a deep import. * * @param {Passable} m * @returns {m is CopyMap} @@ -43,7 +43,7 @@ export const isCopyMap = m => matches(m, M.map()); * @param {(k: K, v?: V) => void} assertOkToAdd * @param {(k: K) => void} [assertOkToDelete] * @param {string} [keyName] - * @returns {CurrentKeysKit} + * @returns {CurrentKeysKit} */ export const makeCurrentKeysKit = ( getRawKeys, @@ -107,13 +107,12 @@ export const makeCurrentKeysKit = ( harden(makeCurrentKeysKit); /** - * Call `provideLazy` to get or make the value associated with the key. - * If there already is one, return that. Otherwise, - * call `makeValue(key)`, remember it as the value for - * that key, and return it. + * Call `provideLazy` to get or make the value associated with the key. If there + * already is one, return that. Otherwise, call `makeValue(key)`, remember it as + * the value for that key, and return it. * * @template K,V - * @param {WeakMapStore} mapStore + * @param {WeakMapStore} mapStore * @param {K} key * @param {(key: K) => V} makeValue * @returns {V} @@ -127,12 +126,11 @@ export const provideLazy = (mapStore, key, makeValue) => { harden(provideLazy); /** - * Helper for use cases in which the maker function is async. - * For two provideLazy calls with the same key, one may be making when the - * other call starts and it would make again. - * (Then there'd be a collision when the second tries to store - * the key.) This prevents that race condition by immediately storing a Promise - * for the maker in an ephemeral store. + * Helper for use cases in which the maker function is async. For two + * provideLazy calls with the same key, one may be making when the other call + * starts and it would make again. (Then there'd be a collision when the second + * tries to store the key.) This prevents that race condition by immediately + * storing a Promise for the maker in an ephemeral store. * * When the `store` argument is durable storage, note that it's possible for * termination to happen after the make completes and before it reaches durable @@ -147,17 +145,16 @@ export const makeAtomicProvider = store => { const pending = new Map(); /** - * Call `provideAsync` to get or make the value associated with the key, - * when the maker is asynchronous. - * If there already is one, return that. Otherwise, - * call `makeValue(key)`, remember it as the value for - * that key, and return it. + * Call `provideAsync` to get or make the value associated with the key, when + * the maker is asynchronous. If there already is one, return that. Otherwise, + * call `makeValue(key)`, remember it as the value for that key, and return + * it. * * @param {K} key - * @param {(key: K) => Promise} makeValue make the value for the store - * if it hasn't been made yet or the last make failed + * @param {(key: K) => Promise} makeValue make the value for the store if + * it hasn't been made yet or the last make failed * @param {(key: K, value: V) => Promise} [finishValue] runs exactly - * once after a new value is added to the store + * once after a new value is added to the store * @returns {Promise} */ const provideAsync = (key, makeValue, finishValue) => { diff --git a/packages/store/src/types.js b/packages/store/src/types.js index 8a9dac5ef6d..2d48326843c 100644 --- a/packages/store/src/types.js +++ b/packages/store/src/types.js @@ -12,111 +12,105 @@ // ///////////////////////////////////////////////////////////////////////////// // Placeholder redundant types, to be imported from `@endo/patterns` instead. -/** - * @typedef {Passable} Key - * TODO placeholder. Figure out how to import from `@endo/patterns` instead - */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead +/** @typedef {Passable} Key */ -/** - * @typedef {Passable} Pattern - * TODO placeholder. Figure out how to import from `@endo/patterns` instead - */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead +/** @typedef {Passable} Pattern */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead /** * @template {Key} [K=Key] * @typedef {CopyTagged & { - * [Symbol.toStringTag]: 'copySet', - * payload: Array, + * [Symbol.toStringTag]: 'copySet'; + * payload: K[]; * }} CopySet - * TODO placeholder. Figure out how to import from `@endo/patterns` instead */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead /** * @template {Key} [K=Key] * @typedef {CopyTagged & { - * [Symbol.toStringTag]: 'copyBag', - * payload: Array<[K, bigint]>, + * [Symbol.toStringTag]: 'copyBag'; + * payload: [K, bigint][]; * }} CopyBag - * TODO placeholder. Figure out how to import from `@endo/patterns` instead */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead /** * @template {Key} [K=Key] * @template {Passable} [V=Passable] * @typedef {CopyTagged & { - * [Symbol.toStringTag]: 'copyMap', - * payload: { keys: Array, values: Array }, + * [Symbol.toStringTag]: 'copyMap'; + * payload: { keys: K[]; values: V[] }; * }} CopyMap - * TODO placeholder. Figure out how to import from `@endo/patterns` instead */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead /** * @typedef {object} GuardMakers - * @property {>(interfaceName: string, - * methodGuards: M, - * options?: {sloppy?: boolean} + * @property {>( + * interfaceName: string, + * methodGuards: M, + * options?: { sloppy?: boolean }, * ) => InterfaceGuard} interface - * TODO placeholder. Figure out how to import from `@endo/patterns` instead - * - * @property {(...argGuards: ArgGuard[]) => MethodGuardMaker} call Guard a synchronous call - * - * @property {(...argGuards: ArgGuard[]) => MethodGuardMaker} callWhen Guard an async call - * + * @property {(...argGuards: ArgGuard[]) => MethodGuardMaker} call Guard a + * synchronous call + * @property {(...argGuards: ArgGuard[]) => MethodGuardMaker} callWhen Guard an + * async call * @property {(argGuard: ArgGuard) => ArgGuard} await Guard an await */ -/** - * @typedef {(...args: any[]) => any} Method - * TODO placeholder. Figure out how to import from `@endo/patterns` instead - */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead +/** @typedef {(...args: any[]) => any} Method */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead /** * @typedef {{ - * klass: 'Interface', - * interfaceName: string, - * methodGuards: Record - * sloppy?: boolean + * klass: 'Interface'; + * interfaceName: string; + * methodGuards: Record; + * sloppy?: boolean; * }} InterfaceGuard - * TODO placeholder. Figure out how to import from `@endo/patterns` instead */ -/** - * @typedef {any} MethodGuardMaker - * TODO placeholder. Figure out how to import from `@endo/patterns` instead - */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead +/** @typedef {any} MethodGuardMaker */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead /** - * @typedef {{ klass: 'methodGuard', callKind: 'sync' | 'async', returnGuard: unknown }} MethodGuard - * TODO placeholder. Figure out how to import from `@endo/patterns` instead + * @typedef {{ + * klass: 'methodGuard'; + * callKind: 'sync' | 'async'; + * returnGuard: unknown; + * }} MethodGuard */ -/** - * @typedef {any} ArgGuard - * TODO placeholder. Figure out how to import from `@endo/patterns` instead - */ +// TODO placeholder. Figure out how to import from `@endo/patterns` instead +/** @typedef {any} ArgGuard */ // ///////////////////////////////////////////////////////////////////////////// /** - * @typedef {object} StoreOptions - * Of the dimensions on which KeyedStores can differ, we only represent a few - * of them as standard options. A given store maker should document which - * options it supports, as well as its positions on dimensions for which it - * does not support options. - * @property {boolean} [longLived=true] Which way to optimize a weak store. True means - * that we expect this weak store to outlive most of its keys, in which - * case we internally may use a JavaScript `WeakMap`. Otherwise we internally - * may use a JavaScript `Map`. - * Defaults to true, so please mark short lived stores explicitly. - * @property {boolean} [durable=false] The contents of this store survive termination - * of its containing process, allowing for restart or upgrade but at the cost - * of forbidding storage of references to ephemeral data. Defaults to false. - * @property {boolean} [fakeDurable=false] This store pretends to be a durable store - * but does not enforce that the things stored in it actually be themselves - * durable (whereas an actual durable store would forbid storage of such - * items). This is in service of allowing incremental transition to use of - * durable stores, to enable normal operation and testing when some stuff - * intended to eventually be durable has not yet been made durable. A store + * @typedef {object} StoreOptions Of the dimensions on which KeyedStores can + * differ, we only represent a few of them as standard options. A given store + * maker should document which options it supports, as well as its positions + * on dimensions for which it does not support options. + * @property {boolean} [longLived=true] Which way to optimize a weak store. True + * means that we expect this weak store to outlive most of its keys, in which + * case we internally may use a JavaScript `WeakMap`. Otherwise we internally + * may use a JavaScript `Map`. Defaults to true, so please mark short lived + * stores explicitly. + * @property {boolean} [durable=false] The contents of this store survive + * termination of its containing process, allowing for restart or upgrade but + * at the cost of forbidding storage of references to ephemeral data. Defaults + * to false. + * @property {boolean} [fakeDurable=false] This store pretends to be a durable + * store but does not enforce that the things stored in it actually be + * themselves durable (whereas an actual durable store would forbid storage of + * such items). This is in service of allowing incremental transition to use + * of durable stores, to enable normal operation and testing when some stuff + * intended to eventually be durable has not yet been made durable. A store * marked as fakeDurable will appear to operate normally but any attempt to * upgrade its containing vat will fail with an error. * @property {Pattern} [keyShape] @@ -125,46 +119,42 @@ /** * Most store methods are in one of three categories - * * lookup methods (`has`,`get`) - * * update methods (`add`,`init`,`set`,`delete`,`addAll`) - * * query methods (`snapshot`,`keys`,`values`,`entries`,`getSize`) - * * query-update methods (`clear`) * - * WeakStores have the lookup and update methods but not the query - * or query-update methods. - * Non-weak Stores are like their corresponding WeakStores, but with the - * additional query and query-update methods. + * - lookup methods (`has`,`get`) + * - update methods (`add`,`init`,`set`,`delete`,`addAll`) + * - query methods (`snapshot`,`keys`,`values`,`entries`,`getSize`) + * - query-update methods (`clear`) + * + * WeakStores have the lookup and update methods but not the query or + * query-update methods. Non-weak Stores are like their corresponding + * WeakStores, but with the additional query and query-update methods. */ /** * @template {Key & object} [K=Key] * @typedef {object} WeakSetStore - * @property {(key: K) => boolean} has - * Check if a key exists. The key can be any JavaScript value, though the - * answer will always be false for keys that cannot be found in this store. - * @property {(key: K) => void} add - * Add the key to the set if it is not already there. Do nothing silently if - * already there. - * The key must be one allowed by this store. For example a scalar store only - * allows primitives and remotables. - * @property {(key: K) => void} delete - * Remove the key. Throws if not found. + * @property {(key: K) => boolean} has Check if a key exists. The key can be any + * JavaScript value, though the answer will always be false for keys that + * cannot be found in this store. + * @property {(key: K) => void} add Add the key to the set if it is not already + * there. Do nothing silently if already there. The key must be one allowed by + * this store. For example a scalar store only allows primitives and + * remotables. + * @property {(key: K) => void} delete Remove the key. Throws if not found. * @property {(keys: CopySet | Iterable) => void} addAll */ /** * @template {Key} [K=Key] * @typedef {object} SetStore - * @property {(key: K) => boolean} has - * Check if a key exists. The key can be any JavaScript value, though the - * answer will always be false for keys that cannot be found in this store. - * @property {(key: K) => void} add - * Add the key to the set if it is not already there. Do nothing silently if - * already there. - * The key must be one allowed by this store. For example a scalar store only - * allows primitives and remotables. - * @property {(key: K) => void} delete - * Remove the key. Throws if not found. + * @property {(key: K) => boolean} has Check if a key exists. The key can be any + * JavaScript value, though the answer will always be false for keys that + * cannot be found in this store. + * @property {(key: K) => void} add Add the key to the set if it is not already + * there. Do nothing silently if already there. The key must be one allowed by + * this store. For example a scalar store only allows primitives and + * remotables. + * @property {(key: K) => void} delete Remove the key. Throws if not found. * @property {(keys: CopySet | Iterable) => void} addAll * @property {(keyPatt?: Pattern) => Iterable} keys * @property {(keyPatt?: Pattern) => Iterable} values @@ -177,47 +167,38 @@ * @template {Key & object} [K=Key] * @template {Passable} [V=Passable] * @typedef {object} WeakMapStore - * @property {(key: K) => boolean} has - * Check if a key exists. The key can be any JavaScript value, though the - * answer will always be false for keys that cannot be found in this store. - * @property {(key: K) => V} get - * Return a value for the key. Throws if not found. - * @property {(key: K, value: V) => void} init - * Initialize the key only if it doesn't already exist. - * The key must be one allowed by this store. For example a scalar store only - * allows primitives and remotables. - * @property {(key: K, value: V) => void} set - * Set the key. Throws if not found. - * @property {(key: K) => void} delete - * Remove the key. Throws if not found. - * @property {(entries: CopyMap | Iterable<[K,V]>) => void} addAll + * @property {(key: K) => boolean} has Check if a key exists. The key can be any + * JavaScript value, though the answer will always be false for keys that + * cannot be found in this store. + * @property {(key: K) => V} get Return a value for the key. Throws if not + * found. + * @property {(key: K, value: V) => void} init Initialize the key only if it + * doesn't already exist. The key must be one allowed by this store. For + * example a scalar store only allows primitives and remotables. + * @property {(key: K, value: V) => void} set Set the key. Throws if not found. + * @property {(key: K) => void} delete Remove the key. Throws if not found. + * @property {(entries: CopyMap | Iterable<[K, V]>) => void} addAll */ /** * @template {Key} [K=Key] * @template {Passable} [V=Passable] * @typedef {object} MapStore - * @property {(key: K) => boolean} has - * Check if a key exists. The key can be any JavaScript value, though the - * answer will always be false for keys that cannot be found in this map - * @property {(key: K) => V} get - * Return a value for the key. Throws if not found. - * @property {(key: K, value: V) => void} init - * Initialize the key only if it doesn't already exist. - * The key must be one allowed by this store. For example a scalar store only - * allows primitives and remotables. - * @property {(key: K, value: V) => void} set - * Set the key. Throws if not found. - * @property {(key: K) => void} delete - * Remove the key. Throws if not found. - * @property {(entries: CopyMap | Iterable<[K,V]>) => void} addAll + * @property {(key: K) => boolean} has Check if a key exists. The key can be any + * JavaScript value, though the answer will always be false for keys that + * cannot be found in this map + * @property {(key: K) => V} get Return a value for the key. Throws if not + * found. + * @property {(key: K, value: V) => void} init Initialize the key only if it + * doesn't already exist. The key must be one allowed by this store. For + * example a scalar store only allows primitives and remotables. + * @property {(key: K, value: V) => void} set Set the key. Throws if not found. + * @property {(key: K) => void} delete Remove the key. Throws if not found. + * @property {(entries: CopyMap | Iterable<[K, V]>) => void} addAll * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable} keys * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable} values - * @property {( - * keyPatt?: Pattern, - * valuePatt?: Pattern - * ) => Iterable<[K,V]>} entries - * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => CopyMap} snapshot + * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<[K, V]>} entries + * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => CopyMap} snapshot * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => number} getSize * @property {(keyPatt?: Pattern, valuePatt?: Pattern) => void} clear */ @@ -226,39 +207,31 @@ /** * @template K,V - * @typedef {object} LegacyWeakMap - * LegacyWeakMap is deprecated. Use WeakMapStore instead if possible. - * @property {(key: K) => boolean} has - * Check if a key exists - * @property {(key: K) => V} get - * Return a value for the key. Throws if not found. - * @property {(key: K, value: V) => void} init - * Initialize the key only if it - * doesn't already exist - * @property {(key: K, value: V) => void} set - * Set the key. Throws if not found. - * @property {(key: K) => void} delete - * Remove the key. Throws if not found. + * @typedef {object} LegacyWeakMap LegacyWeakMap is deprecated. Use WeakMapStore + * instead if possible. + * @property {(key: K) => boolean} has Check if a key exists + * @property {(key: K) => V} get Return a value for the key. Throws if not + * found. + * @property {(key: K, value: V) => void} init Initialize the key only if it + * doesn't already exist + * @property {(key: K, value: V) => void} set Set the key. Throws if not found. + * @property {(key: K) => void} delete Remove the key. Throws if not found. */ /** * @template K,V - * @typedef {object} LegacyMap - * LegacyMap is deprecated. Use MapStore instead if possible. - * @property {(key: K) => boolean} has - * Check if a key exists - * @property {(key: K) => V} get - * Return a value for the key. Throws if not found. - * @property {(key: K, value: V) => void} init - * Initialize the key only if it - * doesn't already exist - * @property {(key: K, value: V) => void} set - * Set the key. Throws if not found. - * @property {(key: K) => void} delete - * Remove the key. Throws if not found. + * @typedef {object} LegacyMap LegacyMap is deprecated. Use MapStore instead if + * possible. + * @property {(key: K) => boolean} has Check if a key exists + * @property {(key: K) => V} get Return a value for the key. Throws if not + * found. + * @property {(key: K, value: V) => void} init Initialize the key only if it + * doesn't already exist + * @property {(key: K, value: V) => void} set Set the key. Throws if not found. + * @property {(key: K) => void} delete Remove the key. Throws if not found. * @property {() => Iterable} keys * @property {() => Iterable} values - * @property {() => Iterable<[K,V]>} entries + * @property {() => Iterable<[K, V]>} entries * @property {() => number} getSize * @property {() => void} clear */