@agoric/vow 0.1.1-dev-3d662f8.0 → 0.1.1-dev-1cd6408.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-3d662f8.0+3d662f8",
3
+ "version": "0.1.1-dev-1cd6408.0+1cd6408",
4
4
  "description": "Remote (shortening and disconnection-tolerant) Promise-likes",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  "lint:types": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@agoric/base-zone": "0.1.1-dev-3d662f8.0+3d662f8",
23
+ "@agoric/base-zone": "0.1.1-dev-1cd6408.0+1cd6408",
24
24
  "@endo/env-options": "^1.1.1",
25
25
  "@endo/eventual-send": "^1.1.2",
26
26
  "@endo/pass-style": "^1.2.0",
@@ -28,7 +28,7 @@
28
28
  "@endo/promise-kit": "^1.0.4"
29
29
  },
30
30
  "devDependencies": {
31
- "@agoric/internal": "0.3.3-dev-3d662f8.0+3d662f8",
31
+ "@agoric/internal": "0.3.3-dev-1cd6408.0+1cd6408",
32
32
  "@endo/far": "^1.0.4",
33
33
  "@endo/init": "^1.0.4",
34
34
  "ava": "^5.3.0"
@@ -49,5 +49,5 @@
49
49
  "typeCoverage": {
50
50
  "atLeast": 88.27
51
51
  },
52
- "gitHead": "3d662f8942693391430a675dad4e68b9867a5e89"
52
+ "gitHead": "1cd6408e27271160227f8aaa12d9771ea73a1da1"
53
53
  }
package/src/E.d.ts CHANGED
@@ -44,15 +44,15 @@ export type EProxy = ReturnType<(<A = {}, U extends (x: any) => Promise<any> = (
44
44
  * unwrapped(x).then(onfulfilled, onrejected)
45
45
  *
46
46
  * @template T
47
- * @template [TResult1=Unwrap<T>]
47
+ * @template [TResult1=import('./types.js').Unwrap<T>]
48
48
  * @template [TResult2=never]
49
49
  * @param {ERef<T>} x value to convert to a handled promise
50
- * @param {(value: Unwrap<T>) => ERef<TResult1>} [onfulfilled]
50
+ * @param {(value: import('./types.js').Unwrap<T>) => ERef<TResult1>} [onfulfilled]
51
51
  * @param {(reason: any) => ERef<TResult2>} [onrejected]
52
52
  * @returns {Promise<TResult1 | TResult2>}
53
53
  * @readonly
54
54
  */
55
- readonly when: <T_4, TResult1 = Unwrap<T_4>, TResult2 = never>(x: ERef<T_4>, onfulfilled?: ((value: Unwrap<T_4>) => ERef<TResult1>) | undefined, onrejected?: ((reason: any) => ERef<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
55
+ readonly when: <T_4, TResult1 = import("./types.js").Unwrap<T_4>, TResult2 = never>(x: ERef<T_4>, onfulfilled?: ((value: import("./types.js").Unwrap<T_4>) => ERef<TResult1>) | undefined, onrejected?: ((reason: any) => ERef<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
56
56
  } & A)>;
57
57
  /**
58
58
  * `DataOnly<T>` means to return a record type `T2` consisting only of
@@ -60,7 +60,7 @@ export type EProxy = ReturnType<(<A = {}, U extends (x: any) => Promise<any> = (
60
60
  */
61
61
  export type DataOnly<T> = Omit<T, FilteredKeys<T, Callable>>;
62
62
  export type ERef<T> = PromiseLike<T> | T;
63
- export type ECallable<T extends Callable> = ReturnType<T> extends PromiseLike<infer U> ? T : (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
63
+ export type ECallable<T extends Callable> = (...args: Parameters<T>) => Promise<import('./types.js').Unwrap<ReturnType<T>>>;
64
64
  export type EMethods<T> = { readonly [P in keyof T]: T[P] extends Callable ? ECallable<T[P]> : never; };
65
65
  export type EGetters<T> = { readonly [P in keyof T]: T[P] extends PromiseLike<infer U> ? T[P] : Promise<Awaited<T[P]>>; };
66
66
  export type ESendOnlyCallable<T extends Callable> = (...args: Parameters<T>) => Promise<void>;
@@ -86,9 +86,8 @@ export type PickCallable<T> = T extends Callable ? (...args: Parameters<T>) => R
86
86
  /**
87
87
  * `RemoteFunctions<T>` means to return the functions and properties that are remotely callable.
88
88
  */
89
- export type RemoteFunctions<T> = T extends import("@endo/eventual-send").RemotableBrand<infer L, infer R> ? PickCallable<R> : Awaited<T> extends import("@endo/eventual-send").RemotableBrand<infer L_1, infer R_1> ? PickCallable<R_1> : Awaited<T> extends import("./types").Vow<infer U> ? RemoteFunctions<U> : T extends PromiseLike<infer U_1> ? Awaited<T> : T;
90
- export type Unwrap<T> = T extends PromiseLike<infer U> ? Unwrap<U> : T extends import("./types").Vow<infer U_1> ? Unwrap<U_1> : T;
91
- export type LocalRecord<T> = T extends import("@endo/eventual-send").RemotableBrand<infer L, infer R> ? L : Awaited<T> extends import("@endo/eventual-send").RemotableBrand<infer L_1, infer R_1> ? L_1 : Awaited<T> extends import("./types").Vow<infer U> ? LocalRecord<U> : T extends PromiseLike<infer U_1> ? Awaited<T> : T;
89
+ export type RemoteFunctions<T> = T extends import("@endo/eventual-send").RemotableBrand<infer L, infer R> ? PickCallable<R> : Awaited<T> extends import("@endo/eventual-send").RemotableBrand<infer L_1, infer R_1> ? PickCallable<R_1> : Awaited<T> extends import("./types.js").Vow<infer U> ? RemoteFunctions<U> : T extends PromiseLike<infer U_1> ? Awaited<T> : T;
90
+ export type LocalRecord<T> = T extends import("@endo/eventual-send").RemotableBrand<infer L, infer R> ? L : Awaited<T> extends import("@endo/eventual-send").RemotableBrand<infer L_1, infer R_1> ? L_1 : Awaited<T> extends import("./types.js").Vow<infer U> ? LocalRecord<U> : T extends PromiseLike<infer U_1> ? Awaited<T> : T;
92
91
  /**
93
92
  * Type for an object that must only be invoked with E. It supports a given
94
93
  * interface but declares all the functions as asyncable.
@@ -143,14 +142,14 @@ declare function makeE<A = {}, U extends (x: any) => Promise<any> = (x: any) =>
143
142
  * unwrapped(x).then(onfulfilled, onrejected)
144
143
  *
145
144
  * @template T
146
- * @template [TResult1=Unwrap<T>]
145
+ * @template [TResult1=import('./types.js').Unwrap<T>]
147
146
  * @template [TResult2=never]
148
147
  * @param {ERef<T>} x value to convert to a handled promise
149
- * @param {(value: Unwrap<T>) => ERef<TResult1>} [onfulfilled]
148
+ * @param {(value: import('./types.js').Unwrap<T>) => ERef<TResult1>} [onfulfilled]
150
149
  * @param {(reason: any) => ERef<TResult2>} [onrejected]
151
150
  * @returns {Promise<TResult1 | TResult2>}
152
151
  * @readonly
153
152
  */
154
- readonly when: <T_4, TResult1 = Unwrap<T_4>, TResult2 = never>(x: ERef<T_4>, onfulfilled?: ((value: Unwrap<T_4>) => ERef<TResult1>) | undefined, onrejected?: ((reason: any) => ERef<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
153
+ readonly when: <T_4, TResult1 = import("./types.js").Unwrap<T_4>, TResult2 = never>(x: ERef<T_4>, onfulfilled?: ((value: import("./types.js").Unwrap<T_4>) => ERef<TResult1>) | undefined, onrejected?: ((reason: any) => ERef<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
155
154
  } & A;
156
155
  //# sourceMappingURL=E.d.ts.map
package/src/E.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"E.d.ts","sourceRoot":"","sources":["E.js"],"names":[],"mappings":";iCASwB,GAAG,EAAE,KAAK,GAAG;qBAyRvB;;;;;;;IA7EN;;;;;;;;;;OAUG;;IASH;;;;;;;;OAQG;;IAGH;;;;;;;;OAQG;;IASH;;;;;;;;;;;;OAYG;;OAkBoB;;;;;0BAOlB,KAAK,CAAC,EAAE,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;sBAMlC,YAAY,CAAC,CAAC,GAAG,CAAC;uGAQZ,WAAW,CAAC,CAAC,KAAK,QAAQ,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC;;;8DAwB7C,WAAW,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC;;4CAczC,CACZ,CAAK,SAAS,QAAQ,GACd,kBAAkB,CAAC,CAAC,GAAG,iBAAiB,SAAS,CAAC,CAAC,CAAC,GACpD,iBAAiB,SAAS,CAAC,CAAC,CAAC,CAClC;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,GAAG,SAAS,SAAS,CAAC,CAAC,CAAC,GACpC,SAAS,SAAS,CAAC,CAAC,CAAC,CAC1B;;;;;;;;;;;;;;;;6DAyBe,WAAW,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC;;;;;;;;;;sDA4C/B,WAAW,CAAC,CAAC,KAAK,KAAK,QAAQ,MAAM,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAvPxE;;;;;;;GAOG;AACH,6CANkB,GAAG,KAAK,QAAQ,GAAG,CAAC,OAAS,GAAG,KAAK,QAAQ,GAAG,CAAC,kBACxD,OAAO,qBAAqB,EAAE,yBAAyB;;;;IA4B1D;;;;;;;;;;OAUG;;IASH;;;;;;;;OAQG;;IAGH;;;;;;;;OAQG;;IASH;;;;;;;;;;;;OAYG;sNAHiB,GAAG;MAiB9B"}
package/src/E.js CHANGED
@@ -263,10 +263,10 @@ const makeE = (
263
263
  * unwrapped(x).then(onfulfilled, onrejected)
264
264
  *
265
265
  * @template T
266
- * @template [TResult1=Unwrap<T>]
266
+ * @template [TResult1=import('./types.js').Unwrap<T>]
267
267
  * @template [TResult2=never]
268
268
  * @param {ERef<T>} x value to convert to a handled promise
269
- * @param {(value: Unwrap<T>) => ERef<TResult1>} [onfulfilled]
269
+ * @param {(value: import('./types.js').Unwrap<T>) => ERef<TResult1>} [onfulfilled]
270
270
  * @param {(reason: any) => ERef<TResult2>} [onrejected]
271
271
  * @returns {Promise<TResult1 | TResult2>}
272
272
  * @readonly
@@ -307,9 +307,7 @@ export default makeE;
307
307
  /**
308
308
  * @template {Callable} T
309
309
  * @typedef {(
310
- * ReturnType<T> extends PromiseLike<infer U> // if function returns a promise
311
- * ? T // return the function
312
- * : (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>> // make it return a promise
310
+ * (...args: Parameters<T>) => Promise<import('./types.js').Unwrap<ReturnType<T>>>
313
311
  * )} ECallable
314
312
  */
315
313
 
@@ -399,7 +397,7 @@ export default makeE;
399
397
  * ? PickCallable<R> // then return the callable properties of R
400
398
  * : Awaited<T> extends import('@endo/eventual-send').RemotableBrand<infer L, infer R> // otherwise, if the final resolution of T is some remote interface R
401
399
  * ? PickCallable<R> // then return the callable properties of R
402
- * : Awaited<T> extends import('./types').Vow<infer U>
400
+ * : Awaited<T> extends import('./types.js').Vow<infer U>
403
401
  * ? RemoteFunctions<U> // then extract the remotable functions of U
404
402
  * : T extends PromiseLike<infer U> // otherwise, if T is a promise
405
403
  * ? Awaited<T> // then return resolved value T
@@ -407,13 +405,6 @@ export default makeE;
407
405
  * )} RemoteFunctions
408
406
  */
409
407
 
410
- /**
411
- * @template T
412
- * @typedef {T extends PromiseLike<infer U> ? Unwrap<U> :
413
- * T extends import('./types').Vow<infer U> ? Unwrap<U> :
414
- * T} Unwrap
415
- */
416
-
417
408
  /**
418
409
  * @template T
419
410
  * @typedef {(
@@ -421,7 +412,7 @@ export default makeE;
421
412
  * ? L
422
413
  * : Awaited<T> extends import('@endo/eventual-send').RemotableBrand<infer L, infer R>
423
414
  * ? L
424
- * : Awaited<T> extends import('./types').Vow<infer U>
415
+ * : Awaited<T> extends import('./types.js').Vow<infer U>
425
416
  * ? LocalRecord<U>
426
417
  * : T extends PromiseLike<infer U>
427
418
  * ? Awaited<T>
package/src/tools.d.ts CHANGED
@@ -2,7 +2,7 @@ export function prepareVowTools(zone: import('@agoric/base-zone').Zone, powers?:
2
2
  isRetryableReason?: ((reason: any) => boolean) | undefined;
3
3
  watchPromise?: ((p: PromiseLike<any>, watcher: import('./watch-promise.js').PromiseWatcher, ...args: unknown[]) => void) | undefined;
4
4
  } | undefined): {
5
- when: <T = any, TResult1 = import("./E.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("./E.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
5
+ when: <T, TResult1 = import("./types.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("./types.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
6
6
  watch: <T_1 = any, TResult1_1 = T_1, TResult2_1 = T_1>(specimenP: import("./types.js").ERef<T_1 | import("./types.js").Vow<T_1>>, watcher?: import("./types.js").Watcher<T_1, TResult1_1, TResult2_1> | undefined, watcherContext?: unknown) => import("./types.js").Vow<TResult1_1 | TResult2_1>;
7
7
  makeVowKit: <T_2>() => import("./types.js").VowKit<T_2>;
8
8
  allVows: (vows: any) => import("./types.js").Vow<any>;
package/src/types.d.ts CHANGED
@@ -1,10 +1,28 @@
1
- export type PromiseVow<T> = PromiseLike<T | Vow<T>>;
2
- export type ERef<T> = import('./E').ERef<T>;
1
+ export type Callable = (...args: any[]) => any;
3
2
  /**
4
- * Creates a type that accepts both near and marshalled references that were
5
- * returned from `Remotable` or `Far`, and also promises for such references.
3
+ * Return type of a function that may
4
+ * return a promise or a vow.
6
5
  */
7
- export type FarRef<Primary, Local = import("./E").DataOnly<Primary>> = ERef<Local & import('@endo/eventual-send').RemotableBrand<Local, Primary>>;
6
+ export type PromiseVow<T> = Promise<T | Vow<T>>;
7
+ export type ERef<T> = T | PromiseLike<T>;
8
+ /**
9
+ * Whether T is a primitive type.
10
+ */
11
+ export type IsPrimitive<T> = (T extends bigint ? true : T extends boolean ? true : T extends null ? true : T extends number ? true : T extends string ? true : T extends symbol ? true : T extends undefined ? true : false);
12
+ /**
13
+ * Recursively extract the non-callable properties of T.
14
+ */
15
+ export type DataOnly<T> = IsPrimitive<T> extends true ? T : T extends Callable ? never : { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]>; };
16
+ /**
17
+ * Follow the chain of vow shortening to the end, returning the final value.
18
+ * This is used within E, so we must narrow the type to its remote form.
19
+ */
20
+ export type Unwrap<T> = T extends PromiseLike<infer U> ? Unwrap<U> : T extends Vow<infer U_1> ? Unwrap<U_1> : IsPrimitive<T> extends true ? T : T extends import("@endo/eventual-send").RemotableBrand<infer Local, infer Primary> ? Local & T : T;
21
+ /**
22
+ * A type that doesn't assume its parameter is local, but is
23
+ * satisfied with both local and remote references.
24
+ */
25
+ export type Remote<Primary, Local = DataOnly<Primary>> = Primary | import('@endo/eventual-send').RemotableBrand<Local, Primary>;
8
26
  /**
9
27
  * The first version of the vow implementation
10
28
  * object. CAVEAT: These methods must never be changed or added to, to provide
@@ -21,7 +39,7 @@ export type VowV0<T = any> = {
21
39
  shorten: () => Promise<T>;
22
40
  };
23
41
  export type VowPayload<T = any> = {
24
- vowV0: import('@endo/eventual-send').FarRef<VowV0<T>>;
42
+ vowV0: Remote<VowV0<T>>;
25
43
  };
26
44
  export type Vow<T = any> = import('@endo/pass-style').CopyTagged<'Vow', VowPayload<T>>;
27
45
  export type VowKit<T = any> = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"4BAKa,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;sBAKvB,OAAO,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;;;;;uEASrB,KAAK,KAAK,GAAG,OAAO,qBAAqB,EAAE,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;aAUzE,MAAM,QAAQ,CAAC,CAAC;;;WAShB,OAAO,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;;2BAK/C,OAAO,kBAAkB,EAAE,UAAU,CACjD,KAAS,EAAE,WAAW,CAAC,CAAC,CACrB;8BAKS;IACZ,GAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAChB,QAAY,EAAE,YAAY,CAAC,CAAC,CAAC;CAC1B;qCAKS;IACZ,GAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAChB,QAAY,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7B,OAAW,EAAE,QAAQ,CAAC,CAAC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C;IAChB,QAAY,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7B,OAAW,EAAE,QAAQ,CAAC,CAAC,CAAA;CACpB;;oBAK2B,CAAC,GAAG,WAAW,CAAC,CAAC,GAAG,IAAI;oBAAkB,GAAG,GAAG,IAAI;;;2BAQ7D,CAAC,KAAK,IAAI,QAAQ,CAAC,GAAG,WAAW,QAAQ,CAAC,GAAG,QAAQ;2BACpD,GAAG,KAAK,IAAI,QAAQ,CAAC,GAAG,WAAW,QAAQ,CAAC,GAAG,QAAQ;;gCAKjE,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,GAAG,OAAO,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC"}
package/src/types.js CHANGED
@@ -1,23 +1,64 @@
1
1
  // @ts-check
2
2
  export {};
3
3
 
4
+ /** @typedef {(...args: any[]) => any} Callable */
5
+
4
6
  /**
5
7
  * @template T
6
- * @typedef {PromiseLike<T | Vow<T>>} PromiseVow
8
+ * @typedef {Promise<T | Vow<T>>} PromiseVow Return type of a function that may
9
+ * return a promise or a vow.
7
10
  */
8
11
 
9
12
  /**
10
13
  * @template T
11
- * @typedef {import('./E').ERef<T>} ERef
14
+ * @typedef {T | PromiseLike<T>} ERef
12
15
  */
13
16
 
14
17
  /**
15
- * Creates a type that accepts both near and marshalled references that were
16
- * returned from `Remotable` or `Far`, and also promises for such references.
17
- *
18
+ * @template T
19
+ * @typedef {(
20
+ * T extends bigint ? true :
21
+ * T extends boolean ? true :
22
+ * T extends null ? true :
23
+ * T extends number ? true :
24
+ * T extends string ? true :
25
+ * T extends symbol ? true :
26
+ * T extends undefined ? true :
27
+ * false
28
+ * )} IsPrimitive Whether T is a primitive type.
29
+ */
30
+
31
+ /**
32
+ * @template T
33
+ * @typedef {(
34
+ * IsPrimitive<T> extends true ? T :
35
+ * T extends Callable ? never :
36
+ * { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> }
37
+ * )} DataOnly Recursively extract the non-callable properties of T.
38
+ */
39
+
40
+ /**
41
+ * Follow the chain of vow shortening to the end, returning the final value.
42
+ * This is used within E, so we must narrow the type to its remote form.
43
+ * @template T
44
+ * @typedef {(
45
+ * T extends PromiseLike<infer U> ? Unwrap<U> :
46
+ * T extends import('./types').Vow<infer U> ? Unwrap<U> :
47
+ * IsPrimitive<T> extends true ? T :
48
+ * T extends import('@endo/eventual-send').RemotableBrand<infer Local, infer Primary> ? Local & T :
49
+ * T
50
+ * )} Unwrap
51
+ */
52
+
53
+ /**
54
+ * A type that accepts both near and marshalled references that were
55
+ * returned from `Remotable` or `Far`.
18
56
  * @template Primary The type of the primary reference.
19
- * @template [Local=import('./E').DataOnly<Primary>] The local properties of the object.
20
- * @typedef {ERef<Local & import('@endo/eventual-send').RemotableBrand<Local, Primary>>} FarRef
57
+ * @template [Local=DataOnly<Primary>] The local properties of the object.
58
+ * @typedef {Primary |
59
+ * import('@endo/eventual-send').RemotableBrand<Local, Primary>
60
+ * } Remote A type that doesn't assume its parameter is local, but is
61
+ * satisfied with both local and remote references.
21
62
  */
22
63
 
23
64
  /**
@@ -36,7 +77,7 @@ export {};
36
77
  /**
37
78
  * @template [T=any]
38
79
  * @typedef {object} VowPayload
39
- * @property {import('@endo/eventual-send').FarRef<VowV0<T>>} vowV0
80
+ * @property {Remote<VowV0<T>>} vowV0
40
81
  */
41
82
 
42
83
  /**
package/src/when.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export function makeWhen(isRetryableReason?: ((reason: any) => boolean) | undefined): <T = any, TResult1 = import("./E.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("./E.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
1
+ export function makeWhen(isRetryableReason?: ((reason: any) => boolean) | undefined): <T, TResult1 = import("./types.js").Unwrap<T>, TResult2 = never>(specimenP: T, onFulfilled?: ((value: import("./types.js").Unwrap<T>) => TResult1 | PromiseLike<TResult1>) | undefined, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined) => Promise<TResult1 | TResult2>;
2
2
  export type When = ReturnType<typeof makeWhen>;
3
3
  //# sourceMappingURL=when.d.ts.map
package/src/when.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["when.js"],"names":[],"mappings":"AAMO,uDAFa,GAAG,KAAK,OAAO,6NAWb,GAAG,oFAoCxB;mBAIa,WAAW,eAAe,CAAC"}
1
+ {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["when.js"],"names":[],"mappings":"AAMO,uDAFa,GAAG,KAAK,OAAO,+NAWb,GAAG,oFAmCxB;mBAIa,WAAW,eAAe,CAAC"}
package/src/when.js CHANGED
@@ -8,18 +8,17 @@ export const makeWhen = (isRetryableReason = () => false) => {
8
8
  /**
9
9
  * Shorten `specimenP` until we achieve a final result.
10
10
  *
11
- * @template [T=any]
12
- * @template [TResult1=import('./E.js').Unwrap<T>]
11
+ * @template T
12
+ * @template [TResult1=import('./types.js').Unwrap<T>]
13
13
  * @template [TResult2=never]
14
14
  * @param {T} specimenP value to unwrap
15
- * @param {(value: import('./E.js').Unwrap<T>) => TResult1 | PromiseLike<TResult1>} [onFulfilled]
15
+ * @param {(value: import('./types.js').Unwrap<T>) => TResult1 | PromiseLike<TResult1>} [onFulfilled]
16
16
  * @param {(reason: any) => TResult2 | PromiseLike<TResult2>} [onRejected]
17
17
  * @returns {Promise<TResult1 | TResult2>}
18
18
  */
19
19
  const when = async (specimenP, onFulfilled, onRejected) => {
20
20
  // Ensure we don't run until a subsequent turn.
21
21
  await null;
22
- Promise.prototype.then;
23
22
 
24
23
  // Ensure we have a presence that won't be disconnected later.
25
24
  let result = await specimenP;
@@ -38,7 +37,7 @@ export const makeWhen = (isRetryableReason = () => false) => {
38
37
  payload = getVowPayload(result);
39
38
  }
40
39
 
41
- const unwrapped = /** @type {import('./E.js').Unwrap<T>} */ (result);
40
+ const unwrapped = /** @type {import('./types.js').Unwrap<T>} */ (result);
42
41
 
43
42
  // We've extracted the final result.
44
43
  if (onFulfilled == null && onRejected == null) {