@endo/promise-kit 1.1.12 → 1.2.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/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,+BAHa,CAAC,KACD,OAAO,gBAAgB,EAAE,UAAU,CAAC,CAAC,CAAC,CAQlD;AAOD;;;;;;;;;;GAUG;AACH,6BAJuC,CAAC,SAA1B,SAAS,OAAO,EAAE,GAAG,EAAG,UAC3B,CAAC,GACC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAIvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAaA;;;;;;;GAOG;AACH,+BAHa,CAAC,KACD,OAAO,gBAAgB,EAAE,UAAU,CAAC,CAAC,CAAC,CAQlD;AAOD;;;;;;;;;;GAUG;AACH,6BAJuC,CAAC,SAA1B,SAAS,OAAO,EAAE,GAAG,EAAG,UAC3B,CAAC,GACC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAIvC"}
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* global globalThis */
2
2
 
3
+ import harden from '@endo/harden';
3
4
  import { makeReleasingExecutorKit } from './src/promise-executor-kit.js';
4
5
  import { memoRace } from './src/memo-race.js';
5
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@endo/promise-kit",
3
- "version": "1.1.12",
3
+ "version": "1.2.0",
4
4
  "description": "Helper for making promises",
5
5
  "keywords": [
6
6
  "promise"
@@ -28,28 +28,23 @@
28
28
  "build": "exit 0",
29
29
  "prepack": "tsc --build tsconfig.build.json",
30
30
  "postpack": "git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\"",
31
- "cover": "c8 ava",
32
31
  "lint": "yarn lint:types && yarn lint:eslint",
33
32
  "lint-fix": "eslint --fix .",
34
33
  "lint:eslint": "eslint .",
35
34
  "lint:types": "tsc",
36
- "test": "ava",
35
+ "test": "yarn run -T ses-ava",
36
+ "test:c8": "c8 ${C8_OPTIONS:-} yarn run -T ses-ava",
37
37
  "test:xs": "exit 0"
38
38
  },
39
39
  "dependencies": {
40
- "ses": "^1.13.1"
40
+ "@endo/harden": "^1.1.0",
41
+ "ses": "^1.15.0"
41
42
  },
42
43
  "devDependencies": {
43
- "ava": "^6.1.3",
44
- "babel-eslint": "^10.1.0",
45
- "c8": "^7.14.0",
46
- "eslint": "^8.57.1",
47
- "eslint-config-airbnb-base": "^15.0.0",
48
- "eslint-config-prettier": "^9.1.0",
49
- "eslint-plugin-eslint-comments": "^3.2.0",
50
- "eslint-plugin-import": "^2.31.0",
51
- "prettier": "^3.5.3",
52
- "typescript": "~5.8.3"
44
+ "ava": "catalog:dev",
45
+ "c8": "catalog:dev",
46
+ "eslint": "catalog:dev",
47
+ "typescript": "~5.9.2"
53
48
  },
54
49
  "files": [
55
50
  "./*.d.ts",
@@ -70,11 +65,10 @@
70
65
  "plugin:@endo/internal"
71
66
  ]
72
67
  },
73
- "ava": {
74
- "files": [
75
- "test/**/*.test.*"
76
- ],
77
- "timeout": "2m"
68
+ "sesAvaConfigs": {
69
+ "lockdown": "../../ava-endo-lockdown.config.mjs",
70
+ "unsafe": "../../ava-endo-lockdown-unsafe.config.mjs",
71
+ "ses": "../../ava-ses-shims-only.config.mjs"
78
72
  },
79
73
  "engines": {
80
74
  "node": ">=11.0"
@@ -82,5 +76,5 @@
82
76
  "typeCoverage": {
83
77
  "atLeast": 90.9
84
78
  },
85
- "gitHead": "03b92fc383da5d8bb4ea993b90149a0db5799d0b"
79
+ "gitHead": "f91329e8616a19f131d009356a5f11ef11c839cc"
86
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"is-promise.d.ts","sourceRoot":"","sources":["is-promise.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wCAHW,OAAO,GACL,YAAY,gBAAW,CAInC"}
1
+ {"version":3,"file":"is-promise.d.ts","sourceRoot":"","sources":["is-promise.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wCAHW,OAAO,GACL,YAAY,gBAAW,CAInC"}
package/src/is-promise.js CHANGED
@@ -1,3 +1,5 @@
1
+ import harden from '@endo/harden';
2
+
1
3
  /**
2
4
  * Determine if the argument is a Promise.
3
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"memo-race.d.ts","sourceRoot":"","sources":["memo-race.js"],"names":[],"mappings":";qBAiCc,CAAC;aAED,CAAC,KAAK,CAAC,EAAE,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAM,IAAI;YAC/C,CAAC,GAAG,CAAC,EAAE,GAAG,KAAM,IAAI;;gCAIpB,KAAK,GACb;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;CAAC,GAC1C;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAC;AAgE1C;;;;;;;;;;;;GAYG;AACH,sBANuC,CAAC,SAA1B,SAAS,OAAO,EAAE,GAAG,EAAG,EACH,CAAC,SAAtB,kBAAmB,wCAEtB,CAAC,GACC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAiCvC"}
1
+ {"version":3,"file":"memo-race.d.ts","sourceRoot":"","sources":["memo-race.js"],"names":[],"mappings":";qBAiDc,CAAC;aAED,CAAC,KAAK,CAAC,EAAE,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAM,IAAI;YAC/C,CAAC,GAAG,CAAC,EAAE,GAAG,KAAM,IAAI;;gCAIpB,KAAK,GACb;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;CAAC,GAC1C;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAC;AAgE1C;;;;;;;;;;;;GAYG;AACH,sBANuC,CAAC,SAA1B,SAAS,OAAO,EAAE,GAAG,EAAG,EACH,CAAC,SAAtB,kBAAmB,wCAEtB,CAAC,GACC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAiCvC"}
package/src/memo-race.js CHANGED
@@ -28,7 +28,23 @@ OTHER DEALINGS IN THE SOFTWARE.
28
28
  For more information, please refer to <http://unlicense.org/>
29
29
  */
30
30
 
31
- const isObject = value => Object(value) === value;
31
+ import harden from '@endo/harden';
32
+
33
+ /**
34
+ * TODO Consolidate with `isPrimitive` that's currently in `@endo/pass-style`.
35
+ * Layering constraints make this tricky, which is why we haven't yet figured
36
+ * out how to do this.
37
+ *
38
+ * @type {(val: unknown) => val is (undefined
39
+ * | null
40
+ * | boolean
41
+ * | number
42
+ * | bigint
43
+ * | string
44
+ * | symbol)}
45
+ */
46
+ const isPrimitive = val =>
47
+ !val || (typeof val !== 'object' && typeof val !== 'function');
32
48
 
33
49
  /**
34
50
  * @template [T=any]
@@ -73,7 +89,7 @@ const markSettled = record => {
73
89
  * @returns {PromiseMemoRecord}
74
90
  */
75
91
  const getMemoRecord = value => {
76
- if (!isObject(value)) {
92
+ if (isPrimitive(value)) {
77
93
  // If the contender is a primitive, attempting to use it as a key in the
78
94
  // weakmap would throw an error. Luckily, it is safe to call
79
95
  // `Promise.resolve(contender).then` on a primitive value multiple times
@@ -1 +1 @@
1
- {"version":3,"file":"promise-executor-kit.d.ts","sourceRoot":"","sources":["promise-executor-kit.js"],"names":[],"mappings":"AAiBO,yCAHM,CAAC,KACD,IAAI,CAAC,OAAO,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,GAAG;IAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAAC,CAqC5G;;;;4BAjDY,CAAC,cAEH,CAAC,KAAK,EAAE,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,UAC7C,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI"}
1
+ {"version":3,"file":"promise-executor-kit.d.ts","sourceRoot":"","sources":["promise-executor-kit.js"],"names":[],"mappings":"AAkBO,yCAHM,CAAC,KACD,IAAI,CAAC,OAAO,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC,GAAG;IAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAAC,CAqC5G;;;;4BAjDY,CAAC,cAEH,CAAC,KAAK,EAAE,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,UAC7C,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI"}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="ses"/>
2
+ import harden from '@endo/harden';
2
3
 
3
4
  /**
4
5
  * @template T