@endo/promise-kit 0.2.49 → 0.2.51

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.2.51](https://github.com/endojs/endo/compare/@endo/promise-kit@0.2.50...@endo/promise-kit@0.2.51) (2022-10-24)
7
+
8
+ **Note:** Version bump only for package @endo/promise-kit
9
+
10
+
11
+
12
+
13
+
14
+ ### [0.2.50](https://github.com/endojs/endo/compare/@endo/promise-kit@0.2.49...@endo/promise-kit@0.2.50) (2022-10-19)
15
+
16
+ **Note:** Version bump only for package @endo/promise-kit
17
+
18
+
19
+
20
+
21
+
6
22
  ### [0.2.49](https://github.com/endojs/endo/compare/@endo/promise-kit@0.2.48...@endo/promise-kit@0.2.49) (2022-09-27)
7
23
 
8
24
  **Note:** Version bump only for package @endo/promise-kit
package/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * makePromiseKit() builds a Promise object, and returns a record
3
+ * containing the promise itself, as well as separate facets for resolving
4
+ * and rejecting it.
5
+ *
6
+ * @template T
7
+ * @returns {import('./src/types.js').PromiseKit<T>}
8
+ */
9
+ export function makePromiseKit<T>(): import("./src/types.js").PromiseKit<T>;
10
+ /**
11
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
12
+ * or rejected.
13
+ *
14
+ * Unlike `Promise.race` it cleans up after itself so a non-resolved value doesn't hold onto
15
+ * the result promise.
16
+ *
17
+ * @template T
18
+ * @param {Iterable<T>} values An iterable of Promises.
19
+ * @returns {Promise<Awaited<T>>} A new Promise.
20
+ */
21
+ export function racePromises<T>(values: Iterable<T>): Promise<Awaited<T>>;
22
+ export * from "./src/is-promise.js";
23
+ export * from "./src/types.js";
24
+ //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  /* global globalThis */
2
- // @ts-check
3
2
 
4
3
  /// <reference types="ses"/>
5
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@endo/promise-kit",
3
- "version": "0.2.49",
3
+ "version": "0.2.51",
4
4
  "description": "Helper for making promises",
5
5
  "keywords": [
6
6
  "promise"
@@ -25,6 +25,9 @@
25
25
  },
26
26
  "scripts": {
27
27
  "build": "exit 0",
28
+ "clean": "tsc --build jsconfig.build.json --clean",
29
+ "prepack": "tsc --build jsconfig.build.json",
30
+ "postpack": "yarn clean",
28
31
  "cover": "c8 ava",
29
32
  "lint": "yarn lint:types && yarn lint:js",
30
33
  "lint-check": "yarn lint",
@@ -35,11 +38,12 @@
35
38
  "test:xs": "exit 0"
36
39
  },
37
40
  "dependencies": {
38
- "ses": "^0.15.23"
41
+ "ses": "^0.17.0"
39
42
  },
40
43
  "devDependencies": {
41
44
  "@endo/eslint-config": "^0.5.1",
42
- "@endo/ses-ava": "^0.2.33",
45
+ "@endo/ses-ava": "^0.2.35",
46
+ "@types/node": ">=14.0",
43
47
  "ava": "^3.12.1",
44
48
  "babel-eslint": "^10.0.3",
45
49
  "c8": "^7.7.3",
@@ -80,5 +84,5 @@
80
84
  "engines": {
81
85
  "node": ">=11.0"
82
86
  },
83
- "gitHead": "2d3f1a5c472aaef102e8919cbf8d0c53238d155f"
87
+ "gitHead": "8fb324d8f13a0c6939dc0c1feb831f72298f1853"
84
88
  }
package/shim.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shim.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Determine if the argument is a Promise.
3
+ *
4
+ * @param {unknown} maybePromise The value to examine
5
+ * @returns {maybePromise is Promise} Whether it is a promise
6
+ */
7
+ export function isPromise(maybePromise: unknown): maybePromise is Promise<any>;
8
+ //# sourceMappingURL=is-promise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-promise.d.ts","sourceRoot":"","sources":["is-promise.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wCAHW,OAAO,gCAKjB"}
package/src/is-promise.js CHANGED
@@ -1,5 +1,3 @@
1
- // @ts-check
2
-
3
1
  /**
4
2
  * Determine if the argument is a Promise.
5
3
  *
@@ -0,0 +1,27 @@
1
+ export { race as memoRace };
2
+ export type Deferred<T = any> = {
3
+ resolve: (value?: import("./types.js").ERef<T> | undefined) => void;
4
+ reject: (err?: any) => void;
5
+ };
6
+ export type PromiseMemoRecord = never | {
7
+ settled: false;
8
+ deferreds: Set<Deferred>;
9
+ } | {
10
+ settled: true;
11
+ deferreds?: undefined;
12
+ };
13
+ /**
14
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
15
+ * or rejected.
16
+ *
17
+ * Unlike `Promise.race` it cleans up after itself so a non-resolved value doesn't hold onto
18
+ * the result promise.
19
+ *
20
+ * @template T
21
+ * @template {PromiseConstructor} [P=PromiseConstructor]
22
+ * @this {P}
23
+ * @param {Iterable<T>} values An iterable of Promises.
24
+ * @returns {Promise<Awaited<T>>} A new Promise.
25
+ */
26
+ declare function race<T, P extends PromiseConstructor = PromiseConstructor>(this: P, values: Iterable<T>): Promise<Awaited<T>>;
27
+ //# sourceMappingURL=memo-race.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memo-race.d.ts","sourceRoot":"","sources":["memo-race.js"],"names":[],"mappings":";;mEAmCyD,IAAI;mBACxC,GAAG,KAAM,IAAI;;gCAIpB,KAAK,GACb;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,IAAI,QAAQ,CAAC,CAAA;CAAC,GAC1C;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAC;AAgE1C;;;;;;;;;;;;GAYG;AACH,+HA8BC"}
package/src/memo-race.js CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
  /*
3
2
  Initial version authored by Brian Kim:
4
3
  https://github.com/nodejs/node/issues/17469#issuecomment-685216777
@@ -0,0 +1,8 @@
1
+ export function makeReleasingExecutorKit<T>(): Pick<import("./types.js").PromiseKit<T>, "resolve" | "reject"> & {
2
+ executor: PromiseExecutor<T>;
3
+ };
4
+ /**
5
+ * The promise executor
6
+ */
7
+ export type PromiseExecutor<T> = (resolve: (value: import('./types.js').ERef<T>) => void, reject: (reason: any) => void) => any;
8
+ //# sourceMappingURL=promise-executor-kit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-executor-kit.d.ts","sourceRoot":"","sources":["promise-executor-kit.js"],"names":[],"mappings":"AAiBO;;EAmCN;;;;mDA/CkB,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,mBACpC,GAAG,KAAK,IAAI"}
@@ -1,5 +1,3 @@
1
- // @ts-check
2
-
3
1
  /// <reference types="ses"/>
4
2
 
5
3
  /**
package/src/types.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A reified Promise
3
+ */
4
+ export type PromiseKit<T> = {
5
+ resolve: (value: ERef<T>) => void;
6
+ reject: (reason: any) => void;
7
+ promise: Promise<T>;
8
+ };
9
+ /**
10
+ * PromiseRecord is deprecated in favor of PromiseKit.
11
+ */
12
+ export type PromiseRecord<T> = PromiseKit<T>;
13
+ /**
14
+ * A reference of some kind for to an object of type T. It may be a direct
15
+ * reference to a local T. It may be a local presence for a remote T. It may
16
+ * be a promise for a local or remote T. Or it may even be a thenable
17
+ * (a promise-like non-promise with a "then" method) for a T.
18
+ */
19
+ export type ERef<T> = T | PromiseLike<T>;
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";;;;qBAGsB,KAAK,CAAC,CAAC,KAAK,IAAI;qBACf,GAAG,KAAK,IAAI;aACrB,QAAQ,CAAC,CAAC;;;;;+BAOX,WAAW,CAAC,CAAC;;;;;;;sBAKb,CAAC,GAAG,YAAY,CAAC,CAAC"}