@agoric/vow 0.1.1-dev-303a9f2.0 → 0.1.1-dev-b953651.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 +4 -4
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/vow-utils.d.ts +5 -2
- package/src/vow-utils.d.ts.map +1 -1
- package/src/vow-utils.js +36 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vow",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-b953651.0+b953651",
|
|
4
4
|
"description": "Remote (shortening and disconnection-tolerant) Promise-likes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"lint:types": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
24
|
-
"@agoric/internal": "0.3.3-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-b953651.0+b953651",
|
|
24
|
+
"@agoric/internal": "0.3.3-dev-b953651.0+b953651",
|
|
25
25
|
"@endo/env-options": "^1.1.4",
|
|
26
26
|
"@endo/eventual-send": "^1.2.2",
|
|
27
27
|
"@endo/pass-style": "^1.4.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"typeCoverage": {
|
|
55
55
|
"atLeast": 89.34
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "b95365108e7b1db73148bd742d46cae30890683b"
|
|
58
58
|
}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
export * from './tools.js';
|
|
3
3
|
export { default as makeE } from './E.js';
|
|
4
|
-
export { VowShape } from './vow-utils.js';
|
|
4
|
+
export { VowShape, toPassableCap } from './vow-utils.js';
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line import/export
|
|
7
7
|
export * from './types.js';
|
package/src/vow-utils.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export { basicE };
|
|
2
2
|
export const VowShape: import("@endo/patterns").Matcher;
|
|
3
|
-
export function isVow(specimen:
|
|
3
|
+
export function isVow(specimen: unknown): specimen is Vow;
|
|
4
4
|
export function getVowPayload<T>(specimen: any): VowPayload<T> | undefined;
|
|
5
|
+
export function toPassableCap(k: PassableCap | Vow): PassableCap;
|
|
5
6
|
import { E as basicE } from '@endo/eventual-send';
|
|
6
|
-
import type {
|
|
7
|
+
import type { Vow } from './types.js';
|
|
8
|
+
import type { VowPayload } from './types.js';
|
|
9
|
+
import type { PassableCap } from '@endo/pass-style';
|
|
7
10
|
//# sourceMappingURL=vow-utils.d.ts.map
|
package/src/vow-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vow-utils.d.ts","sourceRoot":"","sources":["vow-utils.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"vow-utils.d.ts","sourceRoot":"","sources":["vow-utils.js"],"names":[],"mappings":";AAYA,wDAKE;AAMK,gCAHI,OAAO,mBAImC;AAc9C,8BAFiB,CAAC,YADd,GAAG,6BAUb;AAoBM,iEAQN;4BAxE2B,qBAAqB;yBAMf,YAAY;gCAAZ,YAAY;iCADhB,kBAAkB"}
|
package/src/vow-utils.js
CHANGED
|
@@ -3,7 +3,10 @@ import { E as basicE } from '@endo/eventual-send';
|
|
|
3
3
|
import { isPassable } from '@endo/pass-style';
|
|
4
4
|
import { M, matches } from '@endo/patterns';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* @import {PassableCap} from '@endo/pass-style'
|
|
8
|
+
* @import {VowPayload, Vow} from './types.js'
|
|
9
|
+
*/
|
|
7
10
|
|
|
8
11
|
export { basicE };
|
|
9
12
|
|
|
@@ -14,6 +17,10 @@ export const VowShape = M.tagged(
|
|
|
14
17
|
}),
|
|
15
18
|
);
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @param {unknown} specimen
|
|
22
|
+
* @returns {specimen is Vow}
|
|
23
|
+
*/
|
|
17
24
|
export const isVow = specimen =>
|
|
18
25
|
isPassable(specimen) && matches(specimen, VowShape);
|
|
19
26
|
harden(isVow);
|
|
@@ -38,3 +45,31 @@ export const getVowPayload = specimen => {
|
|
|
38
45
|
return vow.payload;
|
|
39
46
|
};
|
|
40
47
|
harden(getVowPayload);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* For when you have a Vow or a `PassableCap` (`RemotableObject` or
|
|
51
|
+
* passable `Promise`) and you need `PassableCap`,
|
|
52
|
+
* typically to serve as a key in a `Map`, `WeakMap`, `Store`, or `WeakStore`.
|
|
53
|
+
*
|
|
54
|
+
* Relies on, and encapsulates, the current "V0" representation of a vow
|
|
55
|
+
* as containing a unique remotable shortener.
|
|
56
|
+
*
|
|
57
|
+
* Note: if `k` is not a `Vow`, `toPassableCap` does no enforcement that `k`
|
|
58
|
+
* is already a `PassableCap`. Rather, it just acts as an identity function
|
|
59
|
+
* returning `k` without further checking. The types only describe the
|
|
60
|
+
* intended use. (If warranted, we may later add such enforcement, so please
|
|
61
|
+
* do not rely on either the presence or absence of such enforcement.)
|
|
62
|
+
*
|
|
63
|
+
* @param {PassableCap | Vow} k
|
|
64
|
+
* @returns {PassableCap}
|
|
65
|
+
*/
|
|
66
|
+
export const toPassableCap = k => {
|
|
67
|
+
const payload = getVowPayload(k);
|
|
68
|
+
if (payload === undefined) {
|
|
69
|
+
return /** @type {PassableCap} */ (k);
|
|
70
|
+
}
|
|
71
|
+
const { vowV0 } = payload;
|
|
72
|
+
// vowMap.set(vowV0, h);
|
|
73
|
+
return vowV0;
|
|
74
|
+
};
|
|
75
|
+
harden(toPassableCap);
|