@agoric/store 0.9.3-u14.0 → 0.9.3-u17.0
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/README.md +3 -33
- package/exported.js +1 -1
- package/package.json +19 -14
- package/src/index.js +24 -8
- package/src/legacy/legacyMap.js +23 -20
- package/src/legacy/legacyWeakMap.js +6 -4
- package/src/stores/scalarMapStore.js +17 -14
- package/src/stores/scalarSetStore.js +13 -9
- package/src/stores/scalarWeakMapStore.js +32 -17
- package/src/stores/scalarWeakSetStore.js +26 -13
- package/src/stores/store-utils.js +48 -41
- package/src/types.js +139 -223
- package/CHANGELOG.md +0 -722
|
@@ -1,34 +1,41 @@
|
|
|
1
|
+
import { Fail, q } from '@endo/errors';
|
|
1
2
|
import { Far } from '@endo/marshal';
|
|
2
3
|
import { M, matches } from '@endo/patterns';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @import {RankCompare} from '@endo/marshal';
|
|
7
|
+
* @import {MapStore, WeakMapStore} from '../types.js';
|
|
8
|
+
* @import {Passable} from '@endo/pass-style';
|
|
9
|
+
* @import {Key} from '@endo/patterns';
|
|
10
|
+
*/
|
|
5
11
|
|
|
12
|
+
// TODO: Undate `@endo/patterns` to export the original, and delete the
|
|
13
|
+
// reimplementation here.
|
|
6
14
|
/**
|
|
7
|
-
* Should behave identically to the one in `@endo/patterns`, but
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* TODO: Undate `@endo/patterns` to export the original, and delete the
|
|
11
|
-
* reimplementation here.
|
|
15
|
+
* Should behave identically to the one in `@endo/patterns`, but reimplemented
|
|
16
|
+
* for now because `@endo/patterns` forgot to export this one. This one is
|
|
17
|
+
* simple enough that I prefer a reimplementation to a deep import.
|
|
12
18
|
*
|
|
13
|
-
* @param {
|
|
19
|
+
* @param {unknown} s
|
|
14
20
|
* @returns {s is CopySet}
|
|
15
21
|
*/
|
|
16
22
|
export const isCopySet = s => matches(s, M.set());
|
|
17
23
|
|
|
24
|
+
// TODO: Undate `@endo/patterns` to export the original, and delete the
|
|
25
|
+
// reimplementation here.
|
|
18
26
|
/**
|
|
19
|
-
* Should behave identically to the one in `@endo/patterns`, but
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* TODO: Undate `@endo/patterns` to export the original, and delete the
|
|
23
|
-
* reimplementation here.
|
|
27
|
+
* Should behave identically to the one in `@endo/patterns`, but reimplemented
|
|
28
|
+
* for now because `@endo/patterns` forgot to export this one. This one is
|
|
29
|
+
* simple enough that I prefer a reimplementation to a deep import.
|
|
24
30
|
*
|
|
25
|
-
* @param {
|
|
31
|
+
* @param {unknown} m
|
|
26
32
|
* @returns {m is CopyMap}
|
|
27
33
|
*/
|
|
28
34
|
export const isCopyMap = m => matches(m, M.map());
|
|
29
35
|
|
|
30
36
|
/**
|
|
31
|
-
* @template K
|
|
37
|
+
* @template {Key} K
|
|
38
|
+
* @template {Passable} V
|
|
32
39
|
* @typedef {object} CurrentKeysKit
|
|
33
40
|
* @property {(k: K, v?: V) => void} assertUpdateOnAdd
|
|
34
41
|
* @property {(k: K) => void} assertUpdateOnDelete
|
|
@@ -36,14 +43,15 @@ export const isCopyMap = m => matches(m, M.map());
|
|
|
36
43
|
*/
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
|
-
* @template K
|
|
46
|
+
* @template {Key} K
|
|
47
|
+
* @template {Passable} V
|
|
40
48
|
* @param {() => Iterable<K>} getRawKeys
|
|
41
49
|
* @param {(k: K) => boolean} checkHas
|
|
42
50
|
* @param {RankCompare} compare
|
|
43
51
|
* @param {(k: K, v?: V) => void} assertOkToAdd
|
|
44
52
|
* @param {(k: K) => void} [assertOkToDelete]
|
|
45
53
|
* @param {string} [keyName]
|
|
46
|
-
* @returns {CurrentKeysKit<K,V>}
|
|
54
|
+
* @returns {CurrentKeysKit<K, V>}
|
|
47
55
|
*/
|
|
48
56
|
export const makeCurrentKeysKit = (
|
|
49
57
|
getRawKeys,
|
|
@@ -107,13 +115,13 @@ export const makeCurrentKeysKit = (
|
|
|
107
115
|
harden(makeCurrentKeysKit);
|
|
108
116
|
|
|
109
117
|
/**
|
|
110
|
-
* Call `provideLazy` to get or make the value associated with the key.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* that key, and return it.
|
|
118
|
+
* Call `provideLazy` to get or make the value associated with the key. If there
|
|
119
|
+
* already is one, return that. Otherwise, call `makeValue(key)`, remember it as
|
|
120
|
+
* the value for that key, and return it.
|
|
114
121
|
*
|
|
115
|
-
* @template K
|
|
116
|
-
* @
|
|
122
|
+
* @template {Key} K
|
|
123
|
+
* @template {Passable} V
|
|
124
|
+
* @param {WeakMapStore<K, V>} mapStore
|
|
117
125
|
* @param {K} key
|
|
118
126
|
* @param {(key: K) => V} makeValue
|
|
119
127
|
* @returns {V}
|
|
@@ -127,19 +135,18 @@ export const provideLazy = (mapStore, key, makeValue) => {
|
|
|
127
135
|
harden(provideLazy);
|
|
128
136
|
|
|
129
137
|
/**
|
|
130
|
-
* Helper for use cases in which the maker function is async.
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* for the maker in an ephemeral store.
|
|
138
|
+
* Helper for use cases in which the maker function is async. For two
|
|
139
|
+
* provideLazy calls with the same key, one may be making when the other call
|
|
140
|
+
* starts and it would make again. (Then there'd be a collision when the second
|
|
141
|
+
* tries to store the key.) This prevents that race condition by immediately
|
|
142
|
+
* storing a Promise for the maker in an ephemeral store.
|
|
136
143
|
*
|
|
137
144
|
* When the `store` argument is durable storage, note that it's possible for
|
|
138
145
|
* termination to happen after the make completes and before it reaches durable
|
|
139
146
|
* storage.
|
|
140
147
|
*
|
|
141
|
-
* @template K
|
|
142
|
-
* @template V
|
|
148
|
+
* @template {Key} K
|
|
149
|
+
* @template {Passable} V
|
|
143
150
|
* @param {WeakMapStore<K, V>} store
|
|
144
151
|
*/
|
|
145
152
|
export const makeAtomicProvider = store => {
|
|
@@ -147,17 +154,16 @@ export const makeAtomicProvider = store => {
|
|
|
147
154
|
const pending = new Map();
|
|
148
155
|
|
|
149
156
|
/**
|
|
150
|
-
* Call `provideAsync` to get or make the value associated with the key,
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* that key, and return it.
|
|
157
|
+
* Call `provideAsync` to get or make the value associated with the key, when
|
|
158
|
+
* the maker is asynchronous. If there already is one, return that. Otherwise,
|
|
159
|
+
* call `makeValue(key)`, remember it as the value for that key, and return
|
|
160
|
+
* it.
|
|
155
161
|
*
|
|
156
162
|
* @param {K} key
|
|
157
|
-
* @param {(key: K) => Promise<V>} makeValue make the value for the store
|
|
158
|
-
*
|
|
163
|
+
* @param {(key: K) => Promise<V>} makeValue make the value for the store if
|
|
164
|
+
* it hasn't been made yet or the last make failed
|
|
159
165
|
* @param {(key: K, value: V) => Promise<void>} [finishValue] runs exactly
|
|
160
|
-
*
|
|
166
|
+
* once after a new value is added to the store
|
|
161
167
|
* @returns {Promise<V>}
|
|
162
168
|
*/
|
|
163
169
|
const provideAsync = (key, makeValue, finishValue) => {
|
|
@@ -190,13 +196,14 @@ export const makeAtomicProvider = store => {
|
|
|
190
196
|
};
|
|
191
197
|
harden(makeAtomicProvider);
|
|
192
198
|
/**
|
|
193
|
-
* @template K
|
|
194
|
-
* @template V
|
|
199
|
+
* @template {Key} K
|
|
200
|
+
* @template {Passable} V
|
|
195
201
|
* @typedef {ReturnType<typeof makeAtomicProvider<K, V>>} AtomicProvider<K, V>
|
|
196
202
|
*/
|
|
197
203
|
|
|
198
204
|
/**
|
|
199
|
-
* @template K
|
|
205
|
+
* @template {Key} K
|
|
206
|
+
* @template {Passable} V
|
|
200
207
|
* @param {MapStore<K, V[]>} mapStore
|
|
201
208
|
* @param {K} key
|
|
202
209
|
* @param {V} item
|
package/src/types.js
CHANGED
|
@@ -1,264 +1,180 @@
|
|
|
1
|
-
/// <reference types="ses"/>
|
|
1
|
+
/// <reference types="ses" />
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/** @typedef {import('@endo/marshal').CopyTagged} CopyTagged */
|
|
6
|
-
/** @template T @typedef {import('@endo/marshal').CopyRecord<T>} CopyRecord */
|
|
7
|
-
/** @template T @typedef {import('@endo/marshal').CopyArray<T>} CopyArray */
|
|
8
|
-
/** @typedef {import('@endo/marshal').Checker} Checker */
|
|
9
|
-
/** @typedef {import('@endo/marshal/src/rankOrder').RankCompare} RankCompare */
|
|
10
|
-
/** @typedef {import('@endo/marshal/src/rankOrder').RankComparison} RankComparison */
|
|
11
|
-
|
|
12
|
-
// /////////////////////////////////////////////////////////////////////////////
|
|
13
|
-
// Placeholder redundant types, to be imported from `@endo/patterns` instead.
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Passable} Key
|
|
17
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {Passable} Pattern
|
|
22
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @template {Key} [K=Key]
|
|
27
|
-
* @typedef {CopyTagged & {
|
|
28
|
-
* [Symbol.toStringTag]: 'copySet',
|
|
29
|
-
* payload: Array<K>,
|
|
30
|
-
* }} CopySet
|
|
31
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @template {Key} [K=Key]
|
|
36
|
-
* @typedef {CopyTagged & {
|
|
37
|
-
* [Symbol.toStringTag]: 'copyBag',
|
|
38
|
-
* payload: Array<[K, bigint]>,
|
|
39
|
-
* }} CopyBag
|
|
40
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
41
|
-
*/
|
|
3
|
+
// Ensure this is a module.
|
|
4
|
+
export {};
|
|
42
5
|
|
|
43
6
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @template {Passable} [V=Passable]
|
|
46
|
-
* @typedef {CopyTagged & {
|
|
47
|
-
* [Symbol.toStringTag]: 'copyMap',
|
|
48
|
-
* payload: { keys: Array<K>, values: Array<V> },
|
|
49
|
-
* }} CopyMap
|
|
50
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @typedef {object} GuardMakers
|
|
55
|
-
* @property {<M extends Record<any, any>>(interfaceName: string,
|
|
56
|
-
* methodGuards: M,
|
|
57
|
-
* options?: {sloppy?: boolean}
|
|
58
|
-
* ) => InterfaceGuard} interface
|
|
59
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
60
|
-
*
|
|
61
|
-
* @property {(...argGuards: ArgGuard[]) => MethodGuardMaker} call Guard a synchronous call
|
|
7
|
+
* Note TODO https://github.com/endojs/endo/issues/1488
|
|
62
8
|
*
|
|
63
|
-
* @
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @typedef {
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* }} InterfaceGuard
|
|
80
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @typedef {any} MethodGuardMaker
|
|
85
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @typedef {{ klass: 'methodGuard', callKind: 'sync' | 'async', returnGuard: unknown }} MethodGuard
|
|
90
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @typedef {any} ArgGuard
|
|
95
|
-
* TODO placeholder. Figure out how to import from `@endo/patterns` instead
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
// /////////////////////////////////////////////////////////////////////////////
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @typedef {object} StoreOptions
|
|
102
|
-
* Of the dimensions on which KeyedStores can differ, we only represent a few
|
|
103
|
-
* of them as standard options. A given store maker should document which
|
|
104
|
-
* options it supports, as well as its positions on dimensions for which it
|
|
105
|
-
* does not support options.
|
|
106
|
-
* @property {boolean} [longLived=true] Which way to optimize a weak store. True means
|
|
107
|
-
* that we expect this weak store to outlive most of its keys, in which
|
|
108
|
-
* case we internally may use a JavaScript `WeakMap`. Otherwise we internally
|
|
109
|
-
* may use a JavaScript `Map`.
|
|
110
|
-
* Defaults to true, so please mark short lived stores explicitly.
|
|
111
|
-
* @property {boolean} [durable=false] The contents of this store survive termination
|
|
9
|
+
* @import {Passable, RemotableObject} from '@endo/pass-style'
|
|
10
|
+
* @import {CopySet, CopyMap, Pattern} from '@endo/patterns'
|
|
11
|
+
* @import {Key} from '@endo/patterns'
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} StoreOptions Of the dimensions on which KeyedStores can
|
|
16
|
+
* differ, we only represent a few of them as standard options. A given store
|
|
17
|
+
* maker should document which options it supports, as well as its positions
|
|
18
|
+
* on dimensions for which it does not support options.
|
|
19
|
+
* @property {boolean} [longLived] Which way to optimize a weak store. True
|
|
20
|
+
* means that we expect this weak store to outlive most of its keys, in which
|
|
21
|
+
* case we internally may use a JavaScript `WeakMap`. Otherwise we internally
|
|
22
|
+
* may use a JavaScript `Map`. Defaults to true, so please mark short lived
|
|
23
|
+
* stores explicitly.
|
|
24
|
+
* @property {boolean} [durable] The contents of this store survive termination
|
|
112
25
|
* of its containing process, allowing for restart or upgrade but at the cost
|
|
113
|
-
* of forbidding storage of references to ephemeral data.
|
|
114
|
-
* @property {boolean} [fakeDurable
|
|
26
|
+
* of forbidding storage of references to ephemeral data. Defaults to false.
|
|
27
|
+
* @property {boolean} [fakeDurable] This store pretends to be a durable store
|
|
115
28
|
* but does not enforce that the things stored in it actually be themselves
|
|
116
29
|
* durable (whereas an actual durable store would forbid storage of such
|
|
117
|
-
* items).
|
|
30
|
+
* items). This is in service of allowing incremental transition to use of
|
|
118
31
|
* durable stores, to enable normal operation and testing when some stuff
|
|
119
|
-
* intended to eventually be durable has not yet been made durable.
|
|
32
|
+
* intended to eventually be durable has not yet been made durable. A store
|
|
120
33
|
* marked as fakeDurable will appear to operate normally but any attempt to
|
|
121
|
-
* upgrade its containing vat will fail with an error.
|
|
34
|
+
* upgrade its containing vat will fail with an error. Defaults to false.
|
|
122
35
|
* @property {Pattern} [keyShape]
|
|
123
36
|
* @property {Pattern} [valueShape]
|
|
124
37
|
*/
|
|
125
38
|
|
|
126
39
|
/**
|
|
127
40
|
* Most store methods are in one of three categories
|
|
128
|
-
* * lookup methods (`has`,`get`)
|
|
129
|
-
* * update methods (`add`,`init`,`set`,`delete`,`addAll`)
|
|
130
|
-
* * query methods (`snapshot`,`keys`,`values`,`entries`,`getSize`)
|
|
131
|
-
* * query-update methods (`clear`)
|
|
132
41
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* @
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @property {(key: K) => void}
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
* @
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* @property {(key: K) =>
|
|
167
|
-
*
|
|
168
|
-
*
|
|
42
|
+
* - lookup methods (`has`,`get`)
|
|
43
|
+
* - update methods (`add`,`init`,`set`,`delete`,`addAll`)
|
|
44
|
+
* - query methods (`snapshot`,`keys`,`values`,`entries`,`getSize`)
|
|
45
|
+
* - query-update methods (`clear`)
|
|
46
|
+
*
|
|
47
|
+
* WeakStores have the lookup and update methods but not the query or
|
|
48
|
+
* query-update methods. Non-weak Stores are like their corresponding
|
|
49
|
+
* WeakStores, but with the additional query and query-update methods.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
// TODO use Key for K
|
|
53
|
+
/**
|
|
54
|
+
* @template K
|
|
55
|
+
* @typedef {object} WeakSetStoreMethods
|
|
56
|
+
* @property {(key: K) => boolean} has Check if a key exists. The key can be any
|
|
57
|
+
* JavaScript value, though the answer will always be false for keys that
|
|
58
|
+
* cannot be found in this store.
|
|
59
|
+
* @property {(key: K) => void} add Add the key to the set if it is not already
|
|
60
|
+
* there. Do nothing silently if already there. The key must be one allowed by
|
|
61
|
+
* this store. For example a scalar store only allows primitives and
|
|
62
|
+
* remotables.
|
|
63
|
+
* @property {(key: K) => void} delete Remove the key. Throws if not found.
|
|
64
|
+
* @property {(keys: CopySet<any> | Iterable<K>) => void} addAll
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* @template K
|
|
68
|
+
* @typedef {RemotableObject & WeakSetStoreMethods<K>} WeakSetStore
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
// TODO use Key for K
|
|
72
|
+
/**
|
|
73
|
+
* @template K
|
|
74
|
+
* @typedef {object} SetStoreMethods
|
|
75
|
+
* @property {(key: K) => boolean} has Check if a key exists. The key can be any
|
|
76
|
+
* JavaScript value, though the answer will always be false for keys that
|
|
77
|
+
* cannot be found in this store.
|
|
78
|
+
* @property {(key: K) => void} add Add the key to the set if it is not already
|
|
79
|
+
* there. Do nothing silently if already there. The key must be one allowed by
|
|
80
|
+
* this store. For example a scalar store only allows primitives and
|
|
81
|
+
* remotables.
|
|
82
|
+
* @property {(key: K) => void} delete Remove the key. Throws if not found.
|
|
83
|
+
* @property {(keys: CopySet<any> | Iterable<K>) => void} addAll
|
|
169
84
|
* @property {(keyPatt?: Pattern) => Iterable<K>} keys
|
|
170
85
|
* @property {(keyPatt?: Pattern) => Iterable<K>} values
|
|
171
|
-
* @property {(keyPatt?: Pattern) => CopySet<
|
|
86
|
+
* @property {(keyPatt?: Pattern) => CopySet<any>} snapshot
|
|
172
87
|
* @property {(keyPatt?: Pattern) => number} getSize
|
|
173
88
|
* @property {(keyPatt?: Pattern) => void} clear
|
|
174
89
|
*/
|
|
175
|
-
|
|
176
90
|
/**
|
|
177
|
-
* @template
|
|
178
|
-
* @
|
|
179
|
-
* @typedef {object} WeakMapStore
|
|
180
|
-
* @property {(key: K) => boolean} has
|
|
181
|
-
* Check if a key exists. The key can be any JavaScript value, though the
|
|
182
|
-
* answer will always be false for keys that cannot be found in this store.
|
|
183
|
-
* @property {(key: K) => V} get
|
|
184
|
-
* Return a value for the key. Throws if not found.
|
|
185
|
-
* @property {(key: K, value: V) => void} init
|
|
186
|
-
* Initialize the key only if it doesn't already exist.
|
|
187
|
-
* The key must be one allowed by this store. For example a scalar store only
|
|
188
|
-
* allows primitives and remotables.
|
|
189
|
-
* @property {(key: K, value: V) => void} set
|
|
190
|
-
* Set the key. Throws if not found.
|
|
191
|
-
* @property {(key: K) => void} delete
|
|
192
|
-
* Remove the key. Throws if not found.
|
|
193
|
-
* @property {(entries: CopyMap<K,V> | Iterable<[K,V]>) => void} addAll
|
|
91
|
+
* @template K
|
|
92
|
+
* @typedef {RemotableObject & SetStoreMethods<K>} SetStore
|
|
194
93
|
*/
|
|
195
94
|
|
|
95
|
+
// TODO use Key for K
|
|
96
|
+
// TODO use Passable for V
|
|
196
97
|
/**
|
|
197
|
-
* @template
|
|
198
|
-
* @template
|
|
199
|
-
* @typedef {object}
|
|
200
|
-
* @property {(key: K) => boolean} has
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @property {(key: K) => V} get
|
|
204
|
-
*
|
|
205
|
-
* @property {(key: K, value: V) => void} init
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* @property {(key: K
|
|
210
|
-
*
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
98
|
+
* @template K
|
|
99
|
+
* @template V
|
|
100
|
+
* @typedef {object} WeakMapStore
|
|
101
|
+
* @property {(key: K) => boolean} has Check if a key exists. The key can be any
|
|
102
|
+
* JavaScript value, though the answer will always be false for keys that
|
|
103
|
+
* cannot be found in this store.
|
|
104
|
+
* @property {(key: K) => V} get Return a value for the key. Throws if not
|
|
105
|
+
* found.
|
|
106
|
+
* @property {(key: K, value: V) => void} init Initialize the key only if it
|
|
107
|
+
* doesn't already exist. The key must be one allowed by this store. For
|
|
108
|
+
* example a scalar store only allows primitives and remotables.
|
|
109
|
+
* @property {(key: K, value: V) => void} set Set the key. Throws if not found.
|
|
110
|
+
* @property {(key: K) => void} delete Remove the key. Throws if not found.
|
|
111
|
+
* @property {(entries: CopyMap<any, any> | Iterable<[K, V]>) => void} addAll
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
// TODO use Key for K
|
|
115
|
+
// TODO use Passable for V
|
|
116
|
+
/**
|
|
117
|
+
* @template K
|
|
118
|
+
* @template V
|
|
119
|
+
* @typedef {object} MapStoreMethods
|
|
120
|
+
* @property {(key: K) => boolean} has Check if a key exists. The key can be any
|
|
121
|
+
* JavaScript value, though the answer will always be false for keys that
|
|
122
|
+
* cannot be found in this map
|
|
123
|
+
* @property {(key: K) => V} get Return a value for the key. Throws if not
|
|
124
|
+
* found.
|
|
125
|
+
* @property {(key: K, value: V) => void} init Initialize the key only if it
|
|
126
|
+
* doesn't already exist. The key must be one allowed by this store. For
|
|
127
|
+
* example a scalar store only allows primitives and remotables.
|
|
128
|
+
* @property {(key: K, value: V) => void} set Set the key. Throws if not found.
|
|
129
|
+
* @property {(key: K) => void} delete Remove the key. Throws if not found.
|
|
130
|
+
* @property {(entries: CopyMap<any, Passable> | Iterable<[K, V]>) => void} addAll
|
|
214
131
|
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<K>} keys
|
|
215
132
|
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<V>} values
|
|
133
|
+
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => Iterable<[K, V]>} entries
|
|
216
134
|
* @property {(
|
|
217
135
|
* keyPatt?: Pattern,
|
|
218
|
-
* valuePatt?: Pattern
|
|
219
|
-
* ) =>
|
|
220
|
-
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => CopyMap<K,V>} snapshot
|
|
136
|
+
* valuePatt?: Pattern,
|
|
137
|
+
* ) => CopyMap<any, Passable>} snapshot
|
|
221
138
|
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => number} getSize
|
|
222
139
|
* @property {(keyPatt?: Pattern, valuePatt?: Pattern) => void} clear
|
|
223
140
|
*/
|
|
224
|
-
|
|
225
|
-
// ///////////////////////// Deprecated Legacy /////////////////////////////////
|
|
226
|
-
|
|
227
141
|
/**
|
|
228
|
-
* @template K
|
|
229
|
-
* @
|
|
230
|
-
*
|
|
231
|
-
* @property {(key: K) => boolean} has
|
|
232
|
-
* Check if a key exists
|
|
233
|
-
* @property {(key: K) => V} get
|
|
234
|
-
* Return a value for the key. Throws if not found.
|
|
235
|
-
* @property {(key: K, value: V) => void} init
|
|
236
|
-
* Initialize the key only if it
|
|
237
|
-
* doesn't already exist
|
|
238
|
-
* @property {(key: K, value: V) => void} set
|
|
239
|
-
* Set the key. Throws if not found.
|
|
240
|
-
* @property {(key: K) => void} delete
|
|
241
|
-
* Remove the key. Throws if not found.
|
|
142
|
+
* @template [K=any]
|
|
143
|
+
* @template [V=any]
|
|
144
|
+
* @typedef {RemotableObject & MapStoreMethods<K, V>} MapStore
|
|
242
145
|
*/
|
|
243
146
|
|
|
147
|
+
// ///////////////////////// Deprecated Legacy /////////////////////////////////
|
|
148
|
+
|
|
244
149
|
/**
|
|
245
|
-
* @template K
|
|
246
|
-
* @
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* Check if a key exists
|
|
250
|
-
* @property {(key: K) => V} get
|
|
251
|
-
*
|
|
252
|
-
* @property {(key: K, value: V) => void} init
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* @property {(key: K
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
150
|
+
* @template K
|
|
151
|
+
* @template V
|
|
152
|
+
* @typedef {object} LegacyWeakMap LegacyWeakMap is deprecated. Use WeakMapStore
|
|
153
|
+
* instead if possible.
|
|
154
|
+
* @property {(key: K) => boolean} has Check if a key exists
|
|
155
|
+
* @property {(key: K) => V} get Return a value for the key. Throws if not
|
|
156
|
+
* found.
|
|
157
|
+
* @property {(key: K, value: V) => void} init Initialize the key only if it
|
|
158
|
+
* doesn't already exist
|
|
159
|
+
* @property {(key: K, value: V) => void} set Set the key. Throws if not found.
|
|
160
|
+
* @property {(key: K) => void} delete Remove the key. Throws if not found.
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @template K
|
|
165
|
+
* @template V
|
|
166
|
+
* @typedef {object} LegacyMap LegacyMap is deprecated. Use MapStore instead if
|
|
167
|
+
* possible.
|
|
168
|
+
* @property {(key: K) => boolean} has Check if a key exists
|
|
169
|
+
* @property {(key: K) => V} get Return a value for the key. Throws if not
|
|
170
|
+
* found.
|
|
171
|
+
* @property {(key: K, value: V) => void} init Initialize the key only if it
|
|
172
|
+
* doesn't already exist
|
|
173
|
+
* @property {(key: K, value: V) => void} set Set the key. Throws if not found.
|
|
174
|
+
* @property {(key: K) => void} delete Remove the key. Throws if not found.
|
|
259
175
|
* @property {() => Iterable<K>} keys
|
|
260
176
|
* @property {() => Iterable<V>} values
|
|
261
|
-
* @property {() => Iterable<[K,V]>} entries
|
|
177
|
+
* @property {() => Iterable<[K, V]>} entries
|
|
262
178
|
* @property {() => number} getSize
|
|
263
179
|
* @property {() => void} clear
|
|
264
180
|
*/
|