@agoric/vow 0.1.1-dev-cc6a9e5.0 → 0.1.1-dev-986371e.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/vow",
3
- "version": "0.1.1-dev-cc6a9e5.0+cc6a9e5",
3
+ "version": "0.1.1-dev-986371e.0+986371e",
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-cc6a9e5.0+cc6a9e5",
24
- "@agoric/internal": "0.3.3-dev-cc6a9e5.0+cc6a9e5",
23
+ "@agoric/base-zone": "0.1.1-dev-986371e.0+986371e",
24
+ "@agoric/internal": "0.3.3-dev-986371e.0+986371e",
25
25
  "@endo/env-options": "^1.1.4",
26
26
  "@endo/errors": "^1.2.2",
27
27
  "@endo/eventual-send": "^1.2.2",
@@ -56,5 +56,5 @@
56
56
  "typeCoverage": {
57
57
  "atLeast": 90.06
58
58
  },
59
- "gitHead": "cc6a9e544b7f488aa43aa548c4a2e0ff144d59ea"
59
+ "gitHead": "986371e75546ceae2f5dab5ea8b91eb81ba07e3c"
60
60
  }
package/src/when.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["when.js"],"names":[],"mappings":"AAQO,8EAUQ,CAAC,EACA,QAAQ,eACR,QAAQ,qBACX,CAAC,yBACO,QAAQ,CAAC,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,sCAC9C,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,kBAC/C,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAmD1C;mBAIa,UAAU,CAAC,OAAO,QAAQ,CAAC;uCA5EO,YAAY;6BAAZ,YAAY"}
1
+ {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["when.js"],"names":[],"mappings":"AAQO,8EA+DQ,CAAC,EACA,QAAQ,eACR,QAAQ,qBACX,CAAC,yBACO,QAAQ,CAAC,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,sCAC9C,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,kBAC/C,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAc1C;mBAIa,UAAU,CAAC,OAAO,QAAQ,CAAC;uCA5FO,YAAY;6BAAZ,YAAY"}
package/src/when.js CHANGED
@@ -17,14 +17,10 @@ export const makeWhen = (
17
17
  * @see {@link ../../README.md}
18
18
  *
19
19
  * @template T
20
- * @template [TResult1=EUnwrap<T>]
21
- * @template [TResult2=never]
22
20
  * @param {T} specimenP value to unwrap
23
- * @param {(value: EUnwrap<T>) => TResult1 | PromiseLike<TResult1>} [onFulfilled]
24
- * @param {(reason: any) => TResult2 | PromiseLike<TResult2>} [onRejected]
25
- * @returns {Promise<TResult1 | TResult2>}
21
+ * @returns {Promise<EUnwrap<T>>}
26
22
  */
27
- const when = async (specimenP, onFulfilled, onRejected) => {
23
+ const unwrap = async specimenP => {
28
24
  // Ensure we don't run until a subsequent turn.
29
25
  await null;
30
26
 
@@ -63,10 +59,30 @@ export const makeWhen = (
63
59
  }
64
60
 
65
61
  const unwrapped = /** @type {EUnwrap<T>} */ (result);
62
+ return unwrapped;
63
+ };
64
+
65
+ /**
66
+ * Shorten `specimenP` until we achieve a final result.
67
+ *
68
+ * Does not survive upgrade (even if specimenP is a durable Vow).
69
+ *
70
+ * @see {@link ../../README.md}
71
+ *
72
+ * @template T
73
+ * @template [TResult1=EUnwrap<T>]
74
+ * @template [TResult2=never]
75
+ * @param {T} specimenP value to unwrap
76
+ * @param {(value: EUnwrap<T>) => TResult1 | PromiseLike<TResult1>} [onFulfilled]
77
+ * @param {(reason: any) => TResult2 | PromiseLike<TResult2>} [onRejected]
78
+ * @returns {Promise<TResult1 | TResult2>}
79
+ */
80
+ const when = (specimenP, onFulfilled, onRejected) => {
81
+ const unwrapped = unwrap(specimenP);
66
82
 
67
83
  // We've extracted the final result.
68
84
  if (onFulfilled == null && onRejected == null) {
69
- return /** @type {TResult1} */ (unwrapped);
85
+ return /** @type {Promise<TResult1>} */ (unwrapped);
70
86
  }
71
87
  return basicE.resolve(unwrapped).then(onFulfilled, onRejected);
72
88
  };