@agoric/cache 0.3.3-dev-727e4af.0 → 0.3.3-dev-96c9ff5.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/package.json +10 -10
- package/src/cache.js +6 -2
- package/src/store.js +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cache",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-96c9ff5.0+96c9ff5",
|
|
4
4
|
"description": "Agoric's simple cache interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"author": "Agoric",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agoric/internal": "0.3.3-dev-
|
|
23
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
24
|
-
"@agoric/store": "0.9.3-dev-
|
|
25
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
26
|
-
"@endo/far": "^1.1.
|
|
27
|
-
"@endo/marshal": "^1.
|
|
22
|
+
"@agoric/internal": "0.3.3-dev-96c9ff5.0+96c9ff5",
|
|
23
|
+
"@agoric/notifier": "0.6.3-dev-96c9ff5.0+96c9ff5",
|
|
24
|
+
"@agoric/store": "0.9.3-dev-96c9ff5.0+96c9ff5",
|
|
25
|
+
"@agoric/vat-data": "0.5.3-dev-96c9ff5.0+96c9ff5",
|
|
26
|
+
"@endo/far": "^1.1.2",
|
|
27
|
+
"@endo/marshal": "^1.5.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
30
|
+
"@agoric/zoe": "0.26.3-dev-96c9ff5.0+96c9ff5",
|
|
31
31
|
"ava": "^5.3.0",
|
|
32
32
|
"c8": "^9.1.0"
|
|
33
33
|
},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"timeout": "20m"
|
|
48
48
|
},
|
|
49
49
|
"typeCoverage": {
|
|
50
|
-
"atLeast":
|
|
50
|
+
"atLeast": 94.12
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "96c9ff577fe14cebeb5a38543ba7f8598ffcd0c7"
|
|
53
53
|
}
|
package/src/cache.js
CHANGED
|
@@ -4,9 +4,13 @@ import { E, Far } from '@endo/far';
|
|
|
4
4
|
|
|
5
5
|
import { makeScalarStoreCoordinator } from './store.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
9
|
+
*/
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* @typedef {{ [x: PropertyKey]: any } | string | symbol | bigint | null |
|
|
9
|
-
* undefined | number | ((oldValue: any) => ERef<
|
|
13
|
+
* undefined | number | ((oldValue: any) => ERef<Passable>)} Update a `newValue`
|
|
10
14
|
* to update to. If a function, then it should take an oldValue and return a
|
|
11
15
|
* `newValue` or promise for `newValue`
|
|
12
16
|
*/
|
|
@@ -19,7 +23,7 @@ export const makeCache = (coordinator = makeScalarStoreCoordinator()) => {
|
|
|
19
23
|
* The ground state for a cache key value is `undefined`. It is impossible to
|
|
20
24
|
* distinguish a set value of `undefined` from an unset key
|
|
21
25
|
*
|
|
22
|
-
* @param {
|
|
26
|
+
* @param {Passable} key the cache key (any key type acceptable to the cache)
|
|
23
27
|
* @param {[] | [Update] | [Update, Pattern]} optUpdateGuardPattern an optional
|
|
24
28
|
*/
|
|
25
29
|
const cache = (key, ...optUpdateGuardPattern) => {
|
package/src/store.js
CHANGED
|
@@ -7,7 +7,7 @@ import { withGroundState, makeState } from './state.js';
|
|
|
7
7
|
/** @import {Passable} from '@endo/pass-style' */
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @param {(obj:
|
|
10
|
+
* @param {(obj: Passable) => Passable} [sanitize]
|
|
11
11
|
* @returns {(key: Passable) => Promise<string>}
|
|
12
12
|
*/
|
|
13
13
|
const makeKeyToString = (sanitize = obj => obj) => {
|
|
@@ -36,16 +36,16 @@ const makeKeyToString = (sanitize = obj => obj) => {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @param {string} keyStr
|
|
39
|
-
* @param {(oldValue:
|
|
39
|
+
* @param {(oldValue: Passable) => Passable} txn
|
|
40
40
|
* @param {Pattern} guardPattern
|
|
41
|
-
* @param {(obj:
|
|
41
|
+
* @param {(obj: Passable) => Passable} sanitize Process keys and values with
|
|
42
42
|
* this function before storing them
|
|
43
43
|
* @param {{
|
|
44
44
|
* get(key: string): import('./state.js').State;
|
|
45
45
|
* set(key: string, value: import('./state.js').State): void;
|
|
46
46
|
* init(key: string, value: import('./state.js').State): void;
|
|
47
47
|
* }} stateStore
|
|
48
|
-
* @returns {Promise<
|
|
48
|
+
* @returns {Promise<Passable>} the value of the updated state
|
|
49
49
|
*/
|
|
50
50
|
const applyCacheTransaction = async (
|
|
51
51
|
keyStr,
|
|
@@ -112,6 +112,7 @@ const applyCacheTransaction = async (
|
|
|
112
112
|
* @returns {Promise<string>}
|
|
113
113
|
*/
|
|
114
114
|
const stringifyStateStore = async (stateStore, marshaller) => {
|
|
115
|
+
/** @type {Passable} */
|
|
115
116
|
const obj = {};
|
|
116
117
|
for (const [key, value] of stateStore.entries()) {
|
|
117
118
|
obj[key] = E(marshaller).toCapData(value);
|
|
@@ -126,7 +127,7 @@ const stringifyStateStore = async (stateStore, marshaller) => {
|
|
|
126
127
|
* currently enforce any cache eviction, but that would be a useful feature.
|
|
127
128
|
*
|
|
128
129
|
* @param {MapStore<string, import('./state.js').State>} [stateStore]
|
|
129
|
-
* @param {(obj:
|
|
130
|
+
* @param {(obj: Passable) => Passable} [sanitize] Process keys and values with
|
|
130
131
|
* this function before storing them. Defaults to deeplyFulfilled.
|
|
131
132
|
*/
|
|
132
133
|
export const makeScalarStoreCoordinator = (
|