@metamask/utils 8.2.0 → 8.3.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/assert.js +3 -3
  3. package/dist/assert.mjs +2 -2
  4. package/dist/base64.js +4 -4
  5. package/dist/base64.mjs +3 -3
  6. package/dist/bytes.js +4 -4
  7. package/dist/bytes.mjs +3 -3
  8. package/dist/checksum.js +5 -5
  9. package/dist/checksum.mjs +4 -4
  10. package/dist/{chunk-ZRNIY7OW.js → chunk-4D6XQBHA.js} +4 -4
  11. package/dist/chunk-4NIRTM4M.js +23 -0
  12. package/dist/chunk-4NIRTM4M.js.map +1 -0
  13. package/dist/{chunk-VL5DYXC5.mjs → chunk-52OU772R.mjs} +2 -2
  14. package/dist/chunk-5AVWINSB.js +1 -0
  15. package/dist/chunk-622IOGVI.mjs +1 -0
  16. package/dist/{chunk-65KBH4FZ.mjs → chunk-6C35XQOF.mjs} +2 -2
  17. package/dist/{chunk-WRBN6DWM.js → chunk-6NZW4WK4.js} +3 -3
  18. package/dist/{chunk-VBYRLAP6.js → chunk-6ZDHSOUV.js} +3 -3
  19. package/dist/{chunk-CSDMTDND.mjs → chunk-74DGVJVE.mjs} +2 -2
  20. package/dist/chunk-B7LIM2PK.mjs +23 -0
  21. package/dist/chunk-B7LIM2PK.mjs.map +1 -0
  22. package/dist/{chunk-WQDTPIQK.js → chunk-BFQDMI3M.js} +12 -12
  23. package/dist/{chunk-JCYFTGED.js → chunk-DHVKFDHQ.js} +9 -9
  24. package/dist/{chunk-XYYGZF5Y.js → chunk-E4C7EW4R.js} +3 -3
  25. package/dist/{chunk-N53OILN6.mjs → chunk-GZS3IQBZ.mjs} +2 -2
  26. package/dist/{chunk-DMPG3H3G.js → chunk-IZC266HS.js} +7 -13
  27. package/dist/chunk-IZC266HS.js.map +1 -0
  28. package/dist/{chunk-HLDWS2JR.mjs → chunk-NQMRFZHB.mjs} +2 -2
  29. package/dist/{chunk-2CY4F77D.mjs → chunk-O3EIM33O.mjs} +3 -3
  30. package/dist/{chunk-5WQRFJVQ.js → chunk-OLLG4H35.js} +11 -11
  31. package/dist/{chunk-YQJBIHC7.js → chunk-QEPVHEP7.js} +20 -20
  32. package/dist/{chunk-G66TREC6.mjs → chunk-ROQSKDP5.mjs} +2 -2
  33. package/dist/{chunk-VSEW3V2L.mjs → chunk-S3UHBN2Z.mjs} +3 -3
  34. package/dist/{chunk-BKR45GQY.mjs → chunk-VA2DRBDE.mjs} +2 -2
  35. package/dist/chunk-VFXTVNXN.js +44 -0
  36. package/dist/{chunk-7S5AWFX7.mjs → chunk-XYGUOY6N.mjs} +7 -13
  37. package/dist/{chunk-7S5AWFX7.mjs.map → chunk-XYGUOY6N.mjs.map} +1 -1
  38. package/dist/coercers.js +5 -5
  39. package/dist/coercers.mjs +4 -4
  40. package/dist/errors.js +2 -2
  41. package/dist/errors.mjs +1 -1
  42. package/dist/fs.js +3 -3
  43. package/dist/fs.mjs +2 -2
  44. package/dist/hex.js +4 -4
  45. package/dist/hex.mjs +3 -3
  46. package/dist/index.js +15 -11
  47. package/dist/index.mjs +14 -10
  48. package/dist/json.js +4 -4
  49. package/dist/json.mjs +3 -3
  50. package/dist/node.js +16 -12
  51. package/dist/node.mjs +15 -11
  52. package/dist/number.js +5 -5
  53. package/dist/number.mjs +4 -4
  54. package/dist/promise.js +8 -0
  55. package/dist/promise.js.map +1 -0
  56. package/dist/promise.mjs +8 -0
  57. package/dist/promise.mjs.map +1 -0
  58. package/dist/types/index.d.ts +1 -0
  59. package/dist/types/index.d.ts.map +1 -1
  60. package/dist/types/promise.d.ts +35 -0
  61. package/dist/types/promise.d.ts.map +1 -0
  62. package/dist/versions.js +4 -4
  63. package/dist/versions.mjs +3 -3
  64. package/package.json +2 -2
  65. package/dist/chunk-2TBCL6EF.js +0 -1
  66. package/dist/chunk-4JNG5UTO.js +0 -44
  67. package/dist/chunk-DMPG3H3G.js.map +0 -1
  68. package/dist/chunk-DYMCEQIV.mjs +0 -1
  69. /package/dist/{chunk-ZRNIY7OW.js.map → chunk-4D6XQBHA.js.map} +0 -0
  70. /package/dist/{chunk-VL5DYXC5.mjs.map → chunk-52OU772R.mjs.map} +0 -0
  71. /package/dist/{chunk-2TBCL6EF.js.map → chunk-5AVWINSB.js.map} +0 -0
  72. /package/dist/{chunk-DYMCEQIV.mjs.map → chunk-622IOGVI.mjs.map} +0 -0
  73. /package/dist/{chunk-65KBH4FZ.mjs.map → chunk-6C35XQOF.mjs.map} +0 -0
  74. /package/dist/{chunk-WRBN6DWM.js.map → chunk-6NZW4WK4.js.map} +0 -0
  75. /package/dist/{chunk-VBYRLAP6.js.map → chunk-6ZDHSOUV.js.map} +0 -0
  76. /package/dist/{chunk-CSDMTDND.mjs.map → chunk-74DGVJVE.mjs.map} +0 -0
  77. /package/dist/{chunk-WQDTPIQK.js.map → chunk-BFQDMI3M.js.map} +0 -0
  78. /package/dist/{chunk-JCYFTGED.js.map → chunk-DHVKFDHQ.js.map} +0 -0
  79. /package/dist/{chunk-XYYGZF5Y.js.map → chunk-E4C7EW4R.js.map} +0 -0
  80. /package/dist/{chunk-N53OILN6.mjs.map → chunk-GZS3IQBZ.mjs.map} +0 -0
  81. /package/dist/{chunk-HLDWS2JR.mjs.map → chunk-NQMRFZHB.mjs.map} +0 -0
  82. /package/dist/{chunk-2CY4F77D.mjs.map → chunk-O3EIM33O.mjs.map} +0 -0
  83. /package/dist/{chunk-5WQRFJVQ.js.map → chunk-OLLG4H35.js.map} +0 -0
  84. /package/dist/{chunk-YQJBIHC7.js.map → chunk-QEPVHEP7.js.map} +0 -0
  85. /package/dist/{chunk-G66TREC6.mjs.map → chunk-ROQSKDP5.mjs.map} +0 -0
  86. /package/dist/{chunk-VSEW3V2L.mjs.map → chunk-S3UHBN2Z.mjs.map} +0 -0
  87. /package/dist/{chunk-BKR45GQY.mjs.map → chunk-VA2DRBDE.mjs.map} +0 -0
  88. /package/dist/{chunk-4JNG5UTO.js.map → chunk-VFXTVNXN.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [8.3.0]
10
+ ### Added
11
+ - Add `createDeferredPromise` ([#164](https://github.com/MetaMask/utils/pull/164))
12
+
13
+ ## [8.2.1]
14
+ ### Fixed
15
+ - Fix issue with source maps where line numbers were incorrect for src/error.ts ([#156](https://github.com/MetaMask/utils/pull/156))
16
+
9
17
  ## [8.2.0]
10
18
  ### Added
11
19
  - Add struct utils for validating JSON objects with optional values ([#136](https://github.com/MetaMask/utils/pull/136))
@@ -204,7 +212,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
204
212
  ### Added
205
213
  - Initial release
206
214
 
207
- [Unreleased]: https://github.com/MetaMask/utils/compare/v8.2.0...HEAD
215
+ [Unreleased]: https://github.com/MetaMask/utils/compare/v8.3.0...HEAD
216
+ [8.3.0]: https://github.com/MetaMask/utils/compare/v8.2.1...v8.3.0
217
+ [8.2.1]: https://github.com/MetaMask/utils/compare/v8.2.0...v8.2.1
208
218
  [8.2.0]: https://github.com/MetaMask/utils/compare/v8.1.0...v8.2.0
209
219
  [8.1.0]: https://github.com/MetaMask/utils/compare/v8.0.0...v8.1.0
210
220
  [8.0.0]: https://github.com/MetaMask/utils/compare/v7.1.0...v8.0.0
package/dist/assert.js CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
7
- require('./chunk-DMPG3H3G.js');
6
+ var _chunk6ZDHSOUVjs = require('./chunk-6ZDHSOUV.js');
7
+ require('./chunk-IZC266HS.js');
8
8
  require('./chunk-QVEKZRZ2.js');
9
9
  require('./chunk-3W5G4CYI.js');
10
10
 
@@ -12,5 +12,5 @@ require('./chunk-3W5G4CYI.js');
12
12
 
13
13
 
14
14
 
15
- exports.AssertionError = _chunkVBYRLAP6js.AssertionError; exports.assert = _chunkVBYRLAP6js.assert; exports.assertExhaustive = _chunkVBYRLAP6js.assertExhaustive; exports.assertStruct = _chunkVBYRLAP6js.assertStruct;
15
+ exports.AssertionError = _chunk6ZDHSOUVjs.AssertionError; exports.assert = _chunk6ZDHSOUVjs.assert; exports.assertExhaustive = _chunk6ZDHSOUVjs.assertExhaustive; exports.assertStruct = _chunk6ZDHSOUVjs.assertStruct;
16
16
  //# sourceMappingURL=assert.js.map
package/dist/assert.mjs CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  assert,
4
4
  assertExhaustive,
5
5
  assertStruct
6
- } from "./chunk-CSDMTDND.mjs";
7
- import "./chunk-7S5AWFX7.mjs";
6
+ } from "./chunk-74DGVJVE.mjs";
7
+ import "./chunk-XYGUOY6N.mjs";
8
8
  import "./chunk-H4YFDLB7.mjs";
9
9
  import "./chunk-X66SUIEF.mjs";
10
10
  export {
package/dist/base64.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkWRBN6DWMjs = require('./chunk-WRBN6DWM.js');
4
- require('./chunk-VBYRLAP6.js');
5
- require('./chunk-DMPG3H3G.js');
3
+ var _chunk6NZW4WK4js = require('./chunk-6NZW4WK4.js');
4
+ require('./chunk-6ZDHSOUV.js');
5
+ require('./chunk-IZC266HS.js');
6
6
  require('./chunk-QVEKZRZ2.js');
7
7
  require('./chunk-3W5G4CYI.js');
8
8
 
9
9
 
10
- exports.base64 = _chunkWRBN6DWMjs.base64;
10
+ exports.base64 = _chunk6NZW4WK4js.base64;
11
11
  //# sourceMappingURL=base64.js.map
package/dist/base64.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  base64
3
- } from "./chunk-HLDWS2JR.mjs";
4
- import "./chunk-CSDMTDND.mjs";
5
- import "./chunk-7S5AWFX7.mjs";
3
+ } from "./chunk-NQMRFZHB.mjs";
4
+ import "./chunk-74DGVJVE.mjs";
5
+ import "./chunk-XYGUOY6N.mjs";
6
6
  import "./chunk-H4YFDLB7.mjs";
7
7
  import "./chunk-X66SUIEF.mjs";
8
8
  export {
package/dist/bytes.js CHANGED
@@ -16,9 +16,9 @@
16
16
 
17
17
 
18
18
 
19
- var _chunkYQJBIHC7js = require('./chunk-YQJBIHC7.js');
20
- require('./chunk-VBYRLAP6.js');
21
- require('./chunk-DMPG3H3G.js');
19
+ var _chunkQEPVHEP7js = require('./chunk-QEPVHEP7.js');
20
+ require('./chunk-6ZDHSOUV.js');
21
+ require('./chunk-IZC266HS.js');
22
22
  require('./chunk-QVEKZRZ2.js');
23
23
  require('./chunk-3W5G4CYI.js');
24
24
 
@@ -39,5 +39,5 @@ require('./chunk-3W5G4CYI.js');
39
39
 
40
40
 
41
41
 
42
- exports.assertIsBytes = _chunkYQJBIHC7js.assertIsBytes; exports.base64ToBytes = _chunkYQJBIHC7js.base64ToBytes; exports.bigIntToBytes = _chunkYQJBIHC7js.bigIntToBytes; exports.bytesToBase64 = _chunkYQJBIHC7js.bytesToBase64; exports.bytesToBigInt = _chunkYQJBIHC7js.bytesToBigInt; exports.bytesToHex = _chunkYQJBIHC7js.bytesToHex; exports.bytesToNumber = _chunkYQJBIHC7js.bytesToNumber; exports.bytesToSignedBigInt = _chunkYQJBIHC7js.bytesToSignedBigInt; exports.bytesToString = _chunkYQJBIHC7js.bytesToString; exports.concatBytes = _chunkYQJBIHC7js.concatBytes; exports.createDataView = _chunkYQJBIHC7js.createDataView; exports.hexToBytes = _chunkYQJBIHC7js.hexToBytes; exports.isBytes = _chunkYQJBIHC7js.isBytes; exports.numberToBytes = _chunkYQJBIHC7js.numberToBytes; exports.signedBigIntToBytes = _chunkYQJBIHC7js.signedBigIntToBytes; exports.stringToBytes = _chunkYQJBIHC7js.stringToBytes; exports.valueToBytes = _chunkYQJBIHC7js.valueToBytes;
42
+ exports.assertIsBytes = _chunkQEPVHEP7js.assertIsBytes; exports.base64ToBytes = _chunkQEPVHEP7js.base64ToBytes; exports.bigIntToBytes = _chunkQEPVHEP7js.bigIntToBytes; exports.bytesToBase64 = _chunkQEPVHEP7js.bytesToBase64; exports.bytesToBigInt = _chunkQEPVHEP7js.bytesToBigInt; exports.bytesToHex = _chunkQEPVHEP7js.bytesToHex; exports.bytesToNumber = _chunkQEPVHEP7js.bytesToNumber; exports.bytesToSignedBigInt = _chunkQEPVHEP7js.bytesToSignedBigInt; exports.bytesToString = _chunkQEPVHEP7js.bytesToString; exports.concatBytes = _chunkQEPVHEP7js.concatBytes; exports.createDataView = _chunkQEPVHEP7js.createDataView; exports.hexToBytes = _chunkQEPVHEP7js.hexToBytes; exports.isBytes = _chunkQEPVHEP7js.isBytes; exports.numberToBytes = _chunkQEPVHEP7js.numberToBytes; exports.signedBigIntToBytes = _chunkQEPVHEP7js.signedBigIntToBytes; exports.stringToBytes = _chunkQEPVHEP7js.stringToBytes; exports.valueToBytes = _chunkQEPVHEP7js.valueToBytes;
43
43
  //# sourceMappingURL=bytes.js.map
package/dist/bytes.mjs CHANGED
@@ -16,9 +16,9 @@ import {
16
16
  signedBigIntToBytes,
17
17
  stringToBytes,
18
18
  valueToBytes
19
- } from "./chunk-BKR45GQY.mjs";
20
- import "./chunk-CSDMTDND.mjs";
21
- import "./chunk-7S5AWFX7.mjs";
19
+ } from "./chunk-VA2DRBDE.mjs";
20
+ import "./chunk-74DGVJVE.mjs";
21
+ import "./chunk-XYGUOY6N.mjs";
22
22
  import "./chunk-H4YFDLB7.mjs";
23
23
  import "./chunk-X66SUIEF.mjs";
24
24
  export {
package/dist/checksum.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXYYGZF5Yjs = require('./chunk-XYYGZF5Y.js');
4
- require('./chunk-WRBN6DWM.js');
5
- require('./chunk-VBYRLAP6.js');
6
- require('./chunk-DMPG3H3G.js');
3
+ var _chunkE4C7EW4Rjs = require('./chunk-E4C7EW4R.js');
4
+ require('./chunk-6NZW4WK4.js');
5
+ require('./chunk-6ZDHSOUV.js');
6
+ require('./chunk-IZC266HS.js');
7
7
  require('./chunk-QVEKZRZ2.js');
8
8
  require('./chunk-3W5G4CYI.js');
9
9
 
10
10
 
11
- exports.ChecksumStruct = _chunkXYYGZF5Yjs.ChecksumStruct;
11
+ exports.ChecksumStruct = _chunkE4C7EW4Rjs.ChecksumStruct;
12
12
  //# sourceMappingURL=checksum.js.map
package/dist/checksum.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ChecksumStruct
3
- } from "./chunk-N53OILN6.mjs";
4
- import "./chunk-HLDWS2JR.mjs";
5
- import "./chunk-CSDMTDND.mjs";
6
- import "./chunk-7S5AWFX7.mjs";
3
+ } from "./chunk-GZS3IQBZ.mjs";
4
+ import "./chunk-NQMRFZHB.mjs";
5
+ import "./chunk-74DGVJVE.mjs";
6
+ import "./chunk-XYGUOY6N.mjs";
7
7
  import "./chunk-H4YFDLB7.mjs";
8
8
  import "./chunk-X66SUIEF.mjs";
9
9
  export {
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
3
+ var _chunk6ZDHSOUVjs = require('./chunk-6ZDHSOUV.js');
4
4
 
5
5
  // src/versions.ts
6
6
 
@@ -38,10 +38,10 @@ function isValidSemVerRange(versionRange) {
38
38
  return _superstruct.is.call(void 0, versionRange, VersionRangeStruct);
39
39
  }
40
40
  function assertIsSemVerVersion(version) {
41
- _chunkVBYRLAP6js.assertStruct.call(void 0, version, VersionStruct);
41
+ _chunk6ZDHSOUVjs.assertStruct.call(void 0, version, VersionStruct);
42
42
  }
43
43
  function assertIsSemVerRange(range) {
44
- _chunkVBYRLAP6js.assertStruct.call(void 0, range, VersionRangeStruct);
44
+ _chunk6ZDHSOUVjs.assertStruct.call(void 0, range, VersionRangeStruct);
45
45
  }
46
46
  function gtVersion(version1, version2) {
47
47
  return _semver.gt.call(void 0, version1, version2);
@@ -66,4 +66,4 @@ function satisfiesVersionRange(version, versionRange) {
66
66
 
67
67
 
68
68
  exports.VersionStruct = VersionStruct; exports.VersionRangeStruct = VersionRangeStruct; exports.isValidSemVerVersion = isValidSemVerVersion; exports.isValidSemVerRange = isValidSemVerRange; exports.assertIsSemVerVersion = assertIsSemVerVersion; exports.assertIsSemVerRange = assertIsSemVerRange; exports.gtVersion = gtVersion; exports.gtRange = gtRange; exports.satisfiesVersionRange = satisfiesVersionRange;
69
- //# sourceMappingURL=chunk-ZRNIY7OW.js.map
69
+ //# sourceMappingURL=chunk-4D6XQBHA.js.map
@@ -0,0 +1,23 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/promise.ts
2
+ function createDeferredPromise({
3
+ suppressUnhandledRejection = false
4
+ } = {}) {
5
+ let resolve;
6
+ let reject;
7
+ const promise = new Promise(
8
+ (innerResolve, innerReject) => {
9
+ resolve = innerResolve;
10
+ reject = innerReject;
11
+ }
12
+ );
13
+ if (suppressUnhandledRejection) {
14
+ promise.catch((_error) => {
15
+ });
16
+ }
17
+ return { promise, resolve, reject };
18
+ }
19
+
20
+
21
+
22
+ exports.createDeferredPromise = createDeferredPromise;
23
+ //# sourceMappingURL=chunk-4NIRTM4M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/promise.ts"],"names":[],"mappings":";AAgCO,SAAS,sBAAqC;AAAA,EACnD,6BAA6B;AAC/B,IAEI,CAAC,GAA4B;AAC/B,MAAI;AACJ,MAAI;AACJ,QAAM,UAAU,IAAI;AAAA,IAClB,CACE,cACA,gBACG;AACH,gBAAU;AACV,eAAS;AAAA,IACX;AAAA,EACF;AAEA,MAAI,4BAA4B;AAC9B,YAAQ,MAAM,CAAC,WAAW;AAAA,IAE1B,CAAC;AAAA,EACH;AAGA,SAAO,EAAE,SAAS,SAAS,OAAO;AACpC","sourcesContent":["/**\n * A deferred Promise.\n *\n * A deferred Promise is one that can be resolved or rejected independently of\n * the Promise construction.\n * @template Result - The result type of the Promise.\n */\nexport type DeferredPromise<Result = void> = {\n /**\n * The Promise that has been deferred.\n */\n promise: Promise<Result>;\n /**\n * A function that resolves the Promise.\n */\n resolve: (result: Result) => void;\n /**\n * A function that rejects the Promise.\n */\n reject: (error: unknown) => void;\n};\n\n/**\n * Create a defered Promise.\n *\n * @param args - The arguments.\n * @param args.suppressUnhandledRejection - This option adds an empty error handler\n * to the Promise to suppress the UnhandledPromiseRejection error. This can be\n * useful if the deferred Promise is sometimes intentionally not used.\n * @returns A deferred Promise.\n * @template Result - The result type of the Promise.\n */\nexport function createDeferredPromise<Result = void>({\n suppressUnhandledRejection = false,\n}: {\n suppressUnhandledRejection?: boolean;\n} = {}): DeferredPromise<Result> {\n let resolve: DeferredPromise<Result>['resolve'];\n let reject: DeferredPromise<Result>['reject'];\n const promise = new Promise<Result>(\n (\n innerResolve: DeferredPromise<Result>['resolve'],\n innerReject: DeferredPromise<Result>['reject'],\n ) => {\n resolve = innerResolve;\n reject = innerReject;\n },\n );\n\n if (suppressUnhandledRejection) {\n promise.catch((_error) => {\n // This handler is used to suppress the UnhandledPromiseRejection error\n });\n }\n\n // @ts-expect-error We know that these are assigned, but TypeScript doesn't\n return { promise, resolve, reject };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isErrorWithCode,
3
3
  wrapError
4
- } from "./chunk-7S5AWFX7.mjs";
4
+ } from "./chunk-XYGUOY6N.mjs";
5
5
 
6
6
  // src/fs.ts
7
7
  import fs from "fs";
@@ -119,4 +119,4 @@ export {
119
119
  forceRemove,
120
120
  createSandbox
121
121
  };
122
- //# sourceMappingURL=chunk-VL5DYXC5.mjs.map
122
+ //# sourceMappingURL=chunk-52OU772R.mjs.map
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=chunk-5AVWINSB.js.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-622IOGVI.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assertStruct
3
- } from "./chunk-CSDMTDND.mjs";
3
+ } from "./chunk-74DGVJVE.mjs";
4
4
  import {
5
5
  hasProperty
6
6
  } from "./chunk-H4YFDLB7.mjs";
@@ -254,4 +254,4 @@ export {
254
254
  assertIsJsonRpcError,
255
255
  getJsonRpcIdValidator
256
256
  };
257
- //# sourceMappingURL=chunk-65KBH4FZ.mjs.map
257
+ //# sourceMappingURL=chunk-6C35XQOF.mjs.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
3
+ var _chunk6ZDHSOUVjs = require('./chunk-6ZDHSOUV.js');
4
4
 
5
5
  // src/base64.ts
6
6
  var _superstruct = require('superstruct');
@@ -11,7 +11,7 @@ var base64 = (struct, options = {}) => {
11
11
  if (characterSet === "base64") {
12
12
  letters = String.raw`[A-Za-z0-9+\/]`;
13
13
  } else {
14
- _chunkVBYRLAP6js.assert.call(void 0, characterSet === "base64url");
14
+ _chunk6ZDHSOUVjs.assert.call(void 0, characterSet === "base64url");
15
15
  letters = String.raw`[-_A-Za-z0-9]`;
16
16
  }
17
17
  let re;
@@ -32,4 +32,4 @@ var base64 = (struct, options = {}) => {
32
32
 
33
33
 
34
34
  exports.base64 = base64;
35
- //# sourceMappingURL=chunk-WRBN6DWM.js.map
35
+ //# sourceMappingURL=chunk-6NZW4WK4.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkDMPG3H3Gjs = require('./chunk-DMPG3H3G.js');
3
+ var _chunkIZC266HSjs = require('./chunk-IZC266HS.js');
4
4
 
5
5
  // src/assert.ts
6
6
  var _superstruct = require('superstruct');
@@ -8,7 +8,7 @@ function isConstructable(fn) {
8
8
  return Boolean(typeof _optionalChain([fn, 'optionalAccess', _ => _.prototype, 'optionalAccess', _2 => _2.constructor, 'optionalAccess', _3 => _3.name]) === "string");
9
9
  }
10
10
  function getErrorMessageWithoutTrailingPeriod(error) {
11
- return _chunkDMPG3H3Gjs.getErrorMessage.call(void 0, error).replace(/\.$/u, "");
11
+ return _chunkIZC266HSjs.getErrorMessage.call(void 0, error).replace(/\.$/u, "");
12
12
  }
13
13
  function getError(ErrorWrapper, message) {
14
14
  if (isConstructable(ErrorWrapper)) {
@@ -56,4 +56,4 @@ function assertExhaustive(_object) {
56
56
 
57
57
 
58
58
  exports.AssertionError = AssertionError; exports.assert = assert; exports.assertStruct = assertStruct; exports.assertExhaustive = assertExhaustive;
59
- //# sourceMappingURL=chunk-VBYRLAP6.js.map
59
+ //# sourceMappingURL=chunk-6ZDHSOUV.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getErrorMessage
3
- } from "./chunk-7S5AWFX7.mjs";
3
+ } from "./chunk-XYGUOY6N.mjs";
4
4
 
5
5
  // src/assert.ts
6
6
  import { assert as assertSuperstruct } from "superstruct";
@@ -56,4 +56,4 @@ export {
56
56
  assertStruct,
57
57
  assertExhaustive
58
58
  };
59
- //# sourceMappingURL=chunk-CSDMTDND.mjs.map
59
+ //# sourceMappingURL=chunk-74DGVJVE.mjs.map
@@ -0,0 +1,23 @@
1
+ // src/promise.ts
2
+ function createDeferredPromise({
3
+ suppressUnhandledRejection = false
4
+ } = {}) {
5
+ let resolve;
6
+ let reject;
7
+ const promise = new Promise(
8
+ (innerResolve, innerReject) => {
9
+ resolve = innerResolve;
10
+ reject = innerReject;
11
+ }
12
+ );
13
+ if (suppressUnhandledRejection) {
14
+ promise.catch((_error) => {
15
+ });
16
+ }
17
+ return { promise, resolve, reject };
18
+ }
19
+
20
+ export {
21
+ createDeferredPromise
22
+ };
23
+ //# sourceMappingURL=chunk-B7LIM2PK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/promise.ts"],"sourcesContent":["/**\n * A deferred Promise.\n *\n * A deferred Promise is one that can be resolved or rejected independently of\n * the Promise construction.\n * @template Result - The result type of the Promise.\n */\nexport type DeferredPromise<Result = void> = {\n /**\n * The Promise that has been deferred.\n */\n promise: Promise<Result>;\n /**\n * A function that resolves the Promise.\n */\n resolve: (result: Result) => void;\n /**\n * A function that rejects the Promise.\n */\n reject: (error: unknown) => void;\n};\n\n/**\n * Create a defered Promise.\n *\n * @param args - The arguments.\n * @param args.suppressUnhandledRejection - This option adds an empty error handler\n * to the Promise to suppress the UnhandledPromiseRejection error. This can be\n * useful if the deferred Promise is sometimes intentionally not used.\n * @returns A deferred Promise.\n * @template Result - The result type of the Promise.\n */\nexport function createDeferredPromise<Result = void>({\n suppressUnhandledRejection = false,\n}: {\n suppressUnhandledRejection?: boolean;\n} = {}): DeferredPromise<Result> {\n let resolve: DeferredPromise<Result>['resolve'];\n let reject: DeferredPromise<Result>['reject'];\n const promise = new Promise<Result>(\n (\n innerResolve: DeferredPromise<Result>['resolve'],\n innerReject: DeferredPromise<Result>['reject'],\n ) => {\n resolve = innerResolve;\n reject = innerReject;\n },\n );\n\n if (suppressUnhandledRejection) {\n promise.catch((_error) => {\n // This handler is used to suppress the UnhandledPromiseRejection error\n });\n }\n\n // @ts-expect-error We know that these are assigned, but TypeScript doesn't\n return { promise, resolve, reject };\n}\n"],"mappings":";AAgCO,SAAS,sBAAqC;AAAA,EACnD,6BAA6B;AAC/B,IAEI,CAAC,GAA4B;AAC/B,MAAI;AACJ,MAAI;AACJ,QAAM,UAAU,IAAI;AAAA,IAClB,CACE,cACA,gBACG;AACH,gBAAU;AACV,eAAS;AAAA,IACX;AAAA,EACF;AAEA,MAAI,4BAA4B;AAC9B,YAAQ,MAAM,CAAC,WAAW;AAAA,IAE1B,CAAC;AAAA,EACH;AAGA,SAAO,EAAE,SAAS,SAAS,OAAO;AACpC;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
3
 
4
- var _chunkDMPG3H3Gjs = require('./chunk-DMPG3H3G.js');
4
+ var _chunkIZC266HSjs = require('./chunk-IZC266HS.js');
5
5
 
6
6
  // src/fs.ts
7
7
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
@@ -11,7 +11,7 @@ async function readFile(filePath) {
11
11
  try {
12
12
  return await _fs2.default.promises.readFile(filePath, "utf8");
13
13
  } catch (error) {
14
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0, error, `Could not read file '${filePath}'`);
14
+ throw _chunkIZC266HSjs.wrapError.call(void 0, error, `Could not read file '${filePath}'`);
15
15
  }
16
16
  }
17
17
  async function writeFile(filePath, content) {
@@ -19,7 +19,7 @@ async function writeFile(filePath, content) {
19
19
  await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
20
20
  await _fs2.default.promises.writeFile(filePath, content);
21
21
  } catch (error) {
22
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0, error, `Could not write file '${filePath}'`);
22
+ throw _chunkIZC266HSjs.wrapError.call(void 0, error, `Could not write file '${filePath}'`);
23
23
  }
24
24
  }
25
25
  async function readJsonFile(filePath, {
@@ -29,7 +29,7 @@ async function readJsonFile(filePath, {
29
29
  const content = await _fs2.default.promises.readFile(filePath, "utf8");
30
30
  return parser.parse(content);
31
31
  } catch (error) {
32
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0, error, `Could not read JSON file '${filePath}'`);
32
+ throw _chunkIZC266HSjs.wrapError.call(void 0, error, `Could not read JSON file '${filePath}'`);
33
33
  }
34
34
  }
35
35
  async function writeJsonFile(filePath, jsonValue, {
@@ -41,7 +41,7 @@ async function writeJsonFile(filePath, jsonValue, {
41
41
  const json = prettify ? stringifier.stringify(jsonValue, null, " ") : stringifier.stringify(jsonValue);
42
42
  await _fs2.default.promises.writeFile(filePath, json);
43
43
  } catch (error) {
44
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0, error, `Could not write JSON file '${filePath}'`);
44
+ throw _chunkIZC266HSjs.wrapError.call(void 0, error, `Could not write JSON file '${filePath}'`);
45
45
  }
46
46
  }
47
47
  async function fileExists(filePath) {
@@ -49,10 +49,10 @@ async function fileExists(filePath) {
49
49
  const stats = await _fs2.default.promises.stat(filePath);
50
50
  return stats.isFile();
51
51
  } catch (error) {
52
- if (_chunkDMPG3H3Gjs.isErrorWithCode.call(void 0, error) && error.code === "ENOENT") {
52
+ if (_chunkIZC266HSjs.isErrorWithCode.call(void 0, error) && error.code === "ENOENT") {
53
53
  return false;
54
54
  }
55
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0, error, `Could not determine if file exists '${filePath}'`);
55
+ throw _chunkIZC266HSjs.wrapError.call(void 0, error, `Could not determine if file exists '${filePath}'`);
56
56
  }
57
57
  }
58
58
  async function directoryExists(directoryPath) {
@@ -60,10 +60,10 @@ async function directoryExists(directoryPath) {
60
60
  const stats = await _fs2.default.promises.stat(directoryPath);
61
61
  return stats.isDirectory();
62
62
  } catch (error) {
63
- if (_chunkDMPG3H3Gjs.isErrorWithCode.call(void 0, error) && error.code === "ENOENT") {
63
+ if (_chunkIZC266HSjs.isErrorWithCode.call(void 0, error) && error.code === "ENOENT") {
64
64
  return false;
65
65
  }
66
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0,
66
+ throw _chunkIZC266HSjs.wrapError.call(void 0,
67
67
  error,
68
68
  `Could not determine if directory exists '${directoryPath}'`
69
69
  );
@@ -73,7 +73,7 @@ async function ensureDirectoryStructureExists(directoryPath) {
73
73
  try {
74
74
  await _fs2.default.promises.mkdir(directoryPath, { recursive: true });
75
75
  } catch (error) {
76
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0,
76
+ throw _chunkIZC266HSjs.wrapError.call(void 0,
77
77
  error,
78
78
  `Could not create directory structure '${directoryPath}'`
79
79
  );
@@ -86,7 +86,7 @@ async function forceRemove(entryPath) {
86
86
  force: true
87
87
  });
88
88
  } catch (error) {
89
- throw _chunkDMPG3H3Gjs.wrapError.call(void 0, error, `Could not remove file or directory '${entryPath}'`);
89
+ throw _chunkIZC266HSjs.wrapError.call(void 0, error, `Could not remove file or directory '${entryPath}'`);
90
90
  }
91
91
  }
92
92
  function createSandbox(projectName) {
@@ -119,4 +119,4 @@ function createSandbox(projectName) {
119
119
 
120
120
 
121
121
  exports.readFile = readFile; exports.writeFile = writeFile; exports.readJsonFile = readJsonFile; exports.writeJsonFile = writeJsonFile; exports.fileExists = fileExists; exports.directoryExists = directoryExists; exports.ensureDirectoryStructureExists = ensureDirectoryStructureExists; exports.forceRemove = forceRemove; exports.createSandbox = createSandbox;
122
- //# sourceMappingURL=chunk-WQDTPIQK.js.map
122
+ //# sourceMappingURL=chunk-BFQDMI3M.js.map
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkYQJBIHC7js = require('./chunk-YQJBIHC7.js');
5
+ var _chunkQEPVHEP7js = require('./chunk-QEPVHEP7.js');
6
6
 
7
7
 
8
- var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
8
+ var _chunk6ZDHSOUVjs = require('./chunk-6ZDHSOUV.js');
9
9
 
10
10
  // src/coercers.ts
11
11
 
@@ -18,20 +18,20 @@ var _chunkVBYRLAP6js = require('./chunk-VBYRLAP6.js');
18
18
 
19
19
 
20
20
  var _superstruct = require('superstruct');
21
- var NumberLikeStruct = _superstruct.union.call(void 0, [_superstruct.number.call(void 0, ), _superstruct.bigint.call(void 0, ), _superstruct.string.call(void 0, ), _chunkYQJBIHC7js.StrictHexStruct]);
21
+ var NumberLikeStruct = _superstruct.union.call(void 0, [_superstruct.number.call(void 0, ), _superstruct.bigint.call(void 0, ), _superstruct.string.call(void 0, ), _chunkQEPVHEP7js.StrictHexStruct]);
22
22
  var NumberCoercer = _superstruct.coerce.call(void 0, _superstruct.number.call(void 0, ), NumberLikeStruct, Number);
23
23
  var BigIntCoercer = _superstruct.coerce.call(void 0, _superstruct.bigint.call(void 0, ), NumberLikeStruct, BigInt);
24
- var BytesLikeStruct = _superstruct.union.call(void 0, [_chunkYQJBIHC7js.StrictHexStruct, _superstruct.instance.call(void 0, Uint8Array)]);
24
+ var BytesLikeStruct = _superstruct.union.call(void 0, [_chunkQEPVHEP7js.StrictHexStruct, _superstruct.instance.call(void 0, Uint8Array)]);
25
25
  var BytesCoercer = _superstruct.coerce.call(void 0,
26
26
  _superstruct.instance.call(void 0, Uint8Array),
27
- _superstruct.union.call(void 0, [_chunkYQJBIHC7js.StrictHexStruct]),
28
- _chunkYQJBIHC7js.hexToBytes
27
+ _superstruct.union.call(void 0, [_chunkQEPVHEP7js.StrictHexStruct]),
28
+ _chunkQEPVHEP7js.hexToBytes
29
29
  );
30
- var HexCoercer = _superstruct.coerce.call(void 0, _chunkYQJBIHC7js.StrictHexStruct, _superstruct.instance.call(void 0, Uint8Array), _chunkYQJBIHC7js.bytesToHex);
30
+ var HexCoercer = _superstruct.coerce.call(void 0, _chunkQEPVHEP7js.StrictHexStruct, _superstruct.instance.call(void 0, Uint8Array), _chunkQEPVHEP7js.bytesToHex);
31
31
  function createNumber(value) {
32
32
  try {
33
33
  const result = _superstruct.create.call(void 0, value, NumberCoercer);
34
- _chunkVBYRLAP6js.assert.call(void 0,
34
+ _chunk6ZDHSOUVjs.assert.call(void 0,
35
35
  Number.isFinite(result),
36
36
  `Expected a number-like value, got "${value}".`
37
37
  );
@@ -92,4 +92,4 @@ function createHex(value) {
92
92
 
93
93
 
94
94
  exports.createNumber = createNumber; exports.createBigInt = createBigInt; exports.createBytes = createBytes; exports.createHex = createHex;
95
- //# sourceMappingURL=chunk-JCYFTGED.js.map
95
+ //# sourceMappingURL=chunk-DHVKFDHQ.js.map
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkWRBN6DWMjs = require('./chunk-WRBN6DWM.js');
3
+ var _chunk6NZW4WK4js = require('./chunk-6NZW4WK4.js');
4
4
 
5
5
  // src/checksum.ts
6
6
  var _superstruct = require('superstruct');
7
7
  var ChecksumStruct = _superstruct.size.call(void 0,
8
- _chunkWRBN6DWMjs.base64.call(void 0, _superstruct.string.call(void 0, ), { paddingRequired: true }),
8
+ _chunk6NZW4WK4js.base64.call(void 0, _superstruct.string.call(void 0, ), { paddingRequired: true }),
9
9
  44,
10
10
  44
11
11
  );
@@ -13,4 +13,4 @@ var ChecksumStruct = _superstruct.size.call(void 0,
13
13
 
14
14
 
15
15
  exports.ChecksumStruct = ChecksumStruct;
16
- //# sourceMappingURL=chunk-XYYGZF5Y.js.map
16
+ //# sourceMappingURL=chunk-E4C7EW4R.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  base64
3
- } from "./chunk-HLDWS2JR.mjs";
3
+ } from "./chunk-NQMRFZHB.mjs";
4
4
 
5
5
  // src/checksum.ts
6
6
  import { size, string } from "superstruct";
@@ -13,4 +13,4 @@ var ChecksumStruct = size(
13
13
  export {
14
14
  ChecksumStruct
15
15
  };
16
- //# sourceMappingURL=chunk-N53OILN6.mjs.map
16
+ //# sourceMappingURL=chunk-GZS3IQBZ.mjs.map
@@ -28,18 +28,12 @@ function getErrorMessage(error) {
28
28
  }
29
29
  function wrapError(originalError, message) {
30
30
  if (isError(originalError)) {
31
- const error = Error.length === 2 ? (
32
- // This branch is getting tested by using the Node version that
33
- // supports `cause` on the Error constructor.
34
- // istanbul ignore next
35
- // Also, for some reason `tsserver` is not complaining that the
36
- // Error constructor doesn't support a second argument in the editor,
37
- // but `tsc` does. I'm not sure why, but we disable this in the
38
- // meantime.
39
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
- // @ts-ignore
41
- new Error(message, { cause: originalError })
42
- ) : new (0, _ponycause.ErrorWithCause)(message, { cause: originalError });
31
+ let error;
32
+ if (Error.length === 2) {
33
+ error = new Error(message, { cause: originalError });
34
+ } else {
35
+ error = new (0, _ponycause.ErrorWithCause)(message, { cause: originalError });
36
+ }
43
37
  if (isErrorWithCode(originalError)) {
44
38
  error.code = originalError.code;
45
39
  }
@@ -58,4 +52,4 @@ function wrapError(originalError, message) {
58
52
 
59
53
 
60
54
  exports.isErrorWithCode = isErrorWithCode; exports.isErrorWithMessage = isErrorWithMessage; exports.isErrorWithStack = isErrorWithStack; exports.getErrorMessage = getErrorMessage; exports.wrapError = wrapError;
61
- //# sourceMappingURL=chunk-DMPG3H3G.js.map
55
+ //# sourceMappingURL=chunk-IZC266HS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,sBAAsB;AAY/B,SAAS,QAAQ,OAAgC;AAC/C,SACE,iBAAiB,SAChB,SAAS,KAAK,KAAK,MAAM,YAAY,SAAS;AAEnD;AAUO,SAAS,gBAAgB,OAA2C;AACzE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AAClE;AASO,SAAS,mBACd,OAC8B;AAC9B,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa;AACrE;AASO,SAAS,iBAAiB,OAA4C;AAC3E,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW;AACnE;AAWO,SAAS,gBAAgB,OAAwB;AACtD,MAAI,mBAAmB,KAAK,KAAK,OAAO,MAAM,YAAY,UAAU;AAClE,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,kBAAkB,KAAK,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,KAAK;AACrB;AAeO,SAAS,UACd,eACA,SAC2B;AAC3B,MAAI,QAAQ,aAAa,GAAG;AAC1B,QAAI;AACJ,QAAI,MAAM,WAAW,GAAG;AAMtB,cAAQ,IAAI,MAAM,SAAS,EAAE,OAAO,cAAc,CAAC;AAAA,IACrD,OAAO;AAGL,cAAQ,IAAI,eAAe,SAAS,EAAE,OAAO,cAAc,CAAC;AAAA,IAC9D;AAEA,QAAI,gBAAgB,aAAa,GAAG;AAClC,YAAM,OAAO,cAAc;AAAA,IAC7B;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,SAAS,GAAG;AACtB,WAAO,IAAI,MAAM,GAAG,OAAO,aAAa,CAAC,KAAK,OAAO,EAAE;AAAA,EACzD;AAEA,SAAO,IAAI,MAAM,OAAO,aAAa,CAAC;AACxC","sourcesContent":["import { ErrorWithCause } from 'pony-cause';\n\nimport { isNullOrUndefined, isObject } from './misc';\n\n/**\n * Type guard for determining whether the given value is an instance of Error.\n * For errors generated via `fs.promises`, `error instanceof Error` won't work,\n * so we have to come up with another way of testing.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nfunction isError(error: unknown): error is Error {\n return (\n error instanceof Error ||\n (isObject(error) && error.constructor.name === 'Error')\n );\n}\n\n/**\n * Type guard for determining whether the given value is an error object with a\n * `code` property such as the type of error that Node throws for filesystem\n * operations, etc.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nexport function isErrorWithCode(error: unknown): error is { code: string } {\n return typeof error === 'object' && error !== null && 'code' in error;\n}\n\n/**\n * Type guard for determining whether the given value is an error object with a\n * `message` property, such as an instance of Error.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nexport function isErrorWithMessage(\n error: unknown,\n): error is { message: string } {\n return typeof error === 'object' && error !== null && 'message' in error;\n}\n\n/**\n * Type guard for determining whether the given value is an error object with a\n * `stack` property, such as an instance of Error.\n *\n * @param error - The object to check.\n * @returns A boolean.\n */\nexport function isErrorWithStack(error: unknown): error is { stack: string } {\n return typeof error === 'object' && error !== null && 'stack' in error;\n}\n\n/**\n * Attempts to obtain the message from a possible error object, defaulting to an\n * empty string if it is impossible to do so.\n *\n * @param error - The possible error to get the message from.\n * @returns The message if `error` is an object with a `message` property;\n * the string version of `error` if it is not `undefined` or `null`; otherwise\n * an empty string.\n */\nexport function getErrorMessage(error: unknown): string {\n if (isErrorWithMessage(error) && typeof error.message === 'string') {\n return error.message;\n }\n\n if (isNullOrUndefined(error)) {\n return '';\n }\n\n return String(error);\n}\n\n/**\n * Builds a new error object, linking it to the original error via the `cause`\n * property if it is an Error.\n *\n * This function is useful to reframe error messages in general, but is\n * _critical_ when interacting with any of Node's filesystem functions as\n * provided via `fs.promises`, because these do not produce stack traces in the\n * case of an I/O error (see <https://github.com/nodejs/node/issues/30944>).\n *\n * @param originalError - The error to be wrapped (something throwable).\n * @param message - The desired message of the new error.\n * @returns A new error object.\n */\nexport function wrapError<Throwable>(\n originalError: Throwable,\n message: string,\n): Error & { code?: string } {\n if (isError(originalError)) {\n let error: Error & { code?: string };\n if (Error.length === 2) {\n // for some reason `tsserver` is not complaining that the\n // Error constructor doesn't support a second argument in the editor,\n // but `tsc` does. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n error = new Error(message, { cause: originalError });\n } else {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n error = new ErrorWithCause(message, { cause: originalError });\n }\n\n if (isErrorWithCode(originalError)) {\n error.code = originalError.code;\n }\n\n return error;\n }\n\n if (message.length > 0) {\n return new Error(`${String(originalError)}: ${message}`);\n }\n\n return new Error(String(originalError));\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assert
3
- } from "./chunk-CSDMTDND.mjs";
3
+ } from "./chunk-74DGVJVE.mjs";
4
4
 
5
5
  // src/base64.ts
6
6
  import { pattern } from "superstruct";
@@ -32,4 +32,4 @@ var base64 = (struct, options = {}) => {
32
32
  export {
33
33
  base64
34
34
  };
35
- //# sourceMappingURL=chunk-HLDWS2JR.mjs.map
35
+ //# sourceMappingURL=chunk-NQMRFZHB.mjs.map
@@ -2,10 +2,10 @@ import {
2
2
  StrictHexStruct,
3
3
  bytesToHex,
4
4
  hexToBytes
5
- } from "./chunk-BKR45GQY.mjs";
5
+ } from "./chunk-VA2DRBDE.mjs";
6
6
  import {
7
7
  assert
8
- } from "./chunk-CSDMTDND.mjs";
8
+ } from "./chunk-74DGVJVE.mjs";
9
9
 
10
10
  // src/coercers.ts
11
11
  import {
@@ -92,4 +92,4 @@ export {
92
92
  createBytes,
93
93
  createHex
94
94
  };
95
- //# sourceMappingURL=chunk-2CY4F77D.mjs.map
95
+ //# sourceMappingURL=chunk-O3EIM33O.mjs.map