@metamask/utils 8.3.0 → 8.5.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 (346) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/dist/assert.cjs +127 -0
  3. package/dist/assert.cjs.map +1 -0
  4. package/dist/{types/assert.d.ts → assert.d.cts} +3 -3
  5. package/dist/assert.d.cts.map +1 -0
  6. package/dist/assert.d.mts +61 -0
  7. package/dist/assert.d.mts.map +1 -0
  8. package/dist/assert.mjs +119 -15
  9. package/dist/assert.mjs.map +1 -1
  10. package/dist/base64.cjs +34 -0
  11. package/dist/base64.cjs.map +1 -0
  12. package/dist/{types/base64.d.ts → base64.d.cts} +3 -3
  13. package/dist/base64.d.cts.map +1 -0
  14. package/dist/base64.d.mts +25 -0
  15. package/dist/base64.d.mts.map +1 -0
  16. package/dist/base64.mjs +28 -9
  17. package/dist/base64.mjs.map +1 -1
  18. package/dist/bytes.cjs +400 -0
  19. package/dist/{chunk-QEPVHEP7.js.map → bytes.cjs.map} +1 -1
  20. package/dist/{types/bytes.d.ts → bytes.d.cts} +3 -3
  21. package/dist/bytes.d.cts.map +1 -0
  22. package/dist/bytes.d.mts +183 -0
  23. package/dist/bytes.d.mts.map +1 -0
  24. package/dist/bytes.mjs +379 -42
  25. package/dist/bytes.mjs.map +1 -1
  26. package/dist/caip-types.cjs +151 -0
  27. package/dist/caip-types.cjs.map +1 -0
  28. package/dist/{types/caip-types.d.ts → caip-types.d.cts} +33 -12
  29. package/dist/caip-types.d.cts.map +1 -0
  30. package/dist/caip-types.d.mts +114 -0
  31. package/dist/caip-types.d.mts.map +1 -0
  32. package/dist/caip-types.mjs +139 -39
  33. package/dist/caip-types.mjs.map +1 -1
  34. package/dist/checksum.cjs +7 -0
  35. package/dist/checksum.cjs.map +1 -0
  36. package/dist/checksum.d.cts +2 -0
  37. package/dist/checksum.d.cts.map +1 -0
  38. package/dist/checksum.d.mts +2 -0
  39. package/dist/checksum.d.mts.map +1 -0
  40. package/dist/checksum.mjs +3 -11
  41. package/dist/checksum.mjs.map +1 -1
  42. package/dist/coercers.cjs +162 -0
  43. package/dist/coercers.cjs.map +1 -0
  44. package/dist/{types/coercers.d.ts → coercers.d.cts} +7 -7
  45. package/dist/coercers.d.cts.map +1 -0
  46. package/dist/coercers.d.mts +97 -0
  47. package/dist/coercers.d.mts.map +1 -0
  48. package/dist/coercers.mjs +154 -17
  49. package/dist/coercers.mjs.map +1 -1
  50. package/dist/collections.cjs +109 -0
  51. package/dist/collections.cjs.map +1 -0
  52. package/dist/{types/collections.d.ts → collections.d.cts} +1 -1
  53. package/dist/collections.d.cts.map +1 -0
  54. package/dist/collections.d.mts +39 -0
  55. package/dist/collections.d.mts.map +1 -0
  56. package/dist/collections.mjs +103 -8
  57. package/dist/collections.mjs.map +1 -1
  58. package/dist/encryption-types.cjs +3 -0
  59. package/dist/encryption-types.cjs.map +1 -0
  60. package/dist/{types/encryption-types.d.ts → encryption-types.d.cts} +2 -2
  61. package/dist/encryption-types.d.cts.map +1 -0
  62. package/dist/encryption-types.d.mts +7 -0
  63. package/dist/encryption-types.d.mts.map +1 -0
  64. package/dist/encryption-types.mjs +1 -1
  65. package/dist/encryption-types.mjs.map +1 -1
  66. package/dist/errors.cjs +111 -0
  67. package/dist/errors.cjs.map +1 -0
  68. package/dist/{types/errors.d.ts → errors.d.cts} +1 -1
  69. package/dist/errors.d.cts.map +1 -0
  70. package/dist/errors.d.mts +58 -0
  71. package/dist/errors.d.mts.map +1 -0
  72. package/dist/errors.mjs +102 -16
  73. package/dist/errors.mjs.map +1 -1
  74. package/dist/fs.cjs +248 -0
  75. package/dist/fs.cjs.map +1 -0
  76. package/dist/{types/fs.d.ts → fs.d.cts} +3 -3
  77. package/dist/fs.d.cts.map +1 -0
  78. package/dist/fs.d.mts +133 -0
  79. package/dist/fs.d.mts.map +1 -0
  80. package/dist/fs.mjs +209 -25
  81. package/dist/fs.mjs.map +1 -1
  82. package/dist/hex.cjs +134 -0
  83. package/dist/hex.cjs.map +1 -0
  84. package/dist/{types/hex.d.ts → hex.d.cts} +3 -3
  85. package/dist/hex.d.cts.map +1 -0
  86. package/dist/hex.d.mts +77 -0
  87. package/dist/hex.d.mts.map +1 -0
  88. package/dist/hex.mjs +121 -34
  89. package/dist/hex.mjs.map +1 -1
  90. package/dist/index.cjs +37 -0
  91. package/dist/index.cjs.map +1 -0
  92. package/dist/index.d.cts +21 -0
  93. package/dist/index.d.cts.map +1 -0
  94. package/dist/index.d.mts +21 -0
  95. package/dist/index.d.mts.map +1 -0
  96. package/dist/index.mjs +20 -292
  97. package/dist/index.mjs.map +1 -1
  98. package/dist/json.cjs +413 -0
  99. package/dist/json.cjs.map +1 -0
  100. package/dist/{types/json.d.ts → json.d.cts} +21 -22
  101. package/dist/json.d.cts.map +1 -0
  102. package/dist/json.d.mts +383 -0
  103. package/dist/json.d.mts.map +1 -0
  104. package/dist/json.mjs +389 -74
  105. package/dist/json.mjs.map +1 -1
  106. package/dist/keyring.cjs +3 -0
  107. package/dist/keyring.cjs.map +1 -0
  108. package/dist/{types/keyring.d.ts → keyring.d.cts} +7 -7
  109. package/dist/keyring.d.cts.map +1 -0
  110. package/dist/keyring.d.mts +224 -0
  111. package/dist/keyring.d.mts.map +1 -0
  112. package/dist/keyring.mjs +1 -1
  113. package/dist/keyring.mjs.map +1 -1
  114. package/dist/logging.cjs +43 -0
  115. package/dist/logging.cjs.map +1 -0
  116. package/dist/{types/logging.d.ts → logging.d.cts} +2 -2
  117. package/dist/logging.d.cts.map +1 -0
  118. package/dist/logging.d.mts +30 -0
  119. package/dist/logging.d.mts.map +1 -0
  120. package/dist/logging.mjs +34 -9
  121. package/dist/logging.mjs.map +1 -1
  122. package/dist/misc.cjs +149 -0
  123. package/dist/misc.cjs.map +1 -0
  124. package/dist/{types/misc.d.ts → misc.d.cts} +6 -6
  125. package/dist/misc.d.cts.map +1 -0
  126. package/dist/misc.d.mts +119 -0
  127. package/dist/misc.d.mts.map +1 -0
  128. package/dist/misc.mjs +136 -27
  129. package/dist/misc.mjs.map +1 -1
  130. package/dist/node.cjs +19 -0
  131. package/dist/node.cjs.map +1 -0
  132. package/dist/node.d.cts +3 -0
  133. package/dist/node.d.cts.map +1 -0
  134. package/dist/node.d.mts +3 -0
  135. package/dist/node.d.mts.map +1 -0
  136. package/dist/node.mjs +2 -312
  137. package/dist/node.mjs.map +1 -1
  138. package/dist/number.cjs +102 -0
  139. package/dist/number.cjs.map +1 -0
  140. package/dist/{types/number.d.ts → number.d.cts} +1 -1
  141. package/dist/number.d.cts.map +1 -0
  142. package/dist/number.d.mts +73 -0
  143. package/dist/number.d.mts.map +1 -0
  144. package/dist/number.mjs +93 -16
  145. package/dist/number.mjs.map +1 -1
  146. package/dist/opaque.cjs +3 -0
  147. package/dist/opaque.cjs.map +1 -0
  148. package/dist/opaque.d.cts +6 -0
  149. package/dist/opaque.d.cts.map +1 -0
  150. package/dist/opaque.d.mts +6 -0
  151. package/dist/opaque.d.mts.map +1 -0
  152. package/dist/opaque.mjs +1 -1
  153. package/dist/opaque.mjs.map +1 -1
  154. package/dist/promise.cjs +40 -0
  155. package/dist/promise.cjs.map +1 -0
  156. package/dist/{types/promise.d.ts → promise.d.cts} +12 -2
  157. package/dist/promise.d.cts.map +1 -0
  158. package/dist/promise.d.mts +45 -0
  159. package/dist/promise.d.mts.map +1 -0
  160. package/dist/promise.mjs +35 -7
  161. package/dist/promise.mjs.map +1 -1
  162. package/dist/time.cjs +67 -0
  163. package/dist/time.cjs.map +1 -0
  164. package/dist/{types/time.d.ts → time.d.cts} +1 -1
  165. package/dist/time.d.cts.map +1 -0
  166. package/dist/time.d.mts +49 -0
  167. package/dist/time.d.mts.map +1 -0
  168. package/dist/time.mjs +60 -10
  169. package/dist/time.mjs.map +1 -1
  170. package/dist/transaction-types.cjs +3 -0
  171. package/dist/transaction-types.cjs.map +1 -0
  172. package/dist/{types/transaction-types.d.ts → transaction-types.d.cts} +11 -11
  173. package/dist/transaction-types.d.cts.map +1 -0
  174. package/dist/transaction-types.d.mts +117 -0
  175. package/dist/transaction-types.d.mts.map +1 -0
  176. package/dist/transaction-types.mjs +1 -1
  177. package/dist/transaction-types.mjs.map +1 -1
  178. package/dist/versions.cjs +95 -0
  179. package/dist/versions.cjs.map +1 -0
  180. package/dist/{types/versions.d.ts → versions.d.cts} +5 -5
  181. package/dist/versions.d.cts.map +1 -0
  182. package/dist/versions.d.mts +101 -0
  183. package/dist/versions.d.mts.map +1 -0
  184. package/dist/versions.mjs +85 -26
  185. package/dist/versions.mjs.map +1 -1
  186. package/package.json +28 -17
  187. package/dist/assert.js +0 -16
  188. package/dist/assert.js.map +0 -1
  189. package/dist/base64.js +0 -11
  190. package/dist/base64.js.map +0 -1
  191. package/dist/bytes.js +0 -43
  192. package/dist/bytes.js.map +0 -1
  193. package/dist/caip-types.js +0 -40
  194. package/dist/caip-types.js.map +0 -1
  195. package/dist/checksum.js +0 -12
  196. package/dist/checksum.js.map +0 -1
  197. package/dist/chunk-2LBGT4GH.js +0 -15
  198. package/dist/chunk-2LBGT4GH.js.map +0 -1
  199. package/dist/chunk-3W5G4CYI.js +0 -25
  200. package/dist/chunk-3W5G4CYI.js.map +0 -1
  201. package/dist/chunk-4D6XQBHA.js +0 -69
  202. package/dist/chunk-4D6XQBHA.js.map +0 -1
  203. package/dist/chunk-4NIRTM4M.js +0 -23
  204. package/dist/chunk-4NIRTM4M.js.map +0 -1
  205. package/dist/chunk-4RMX5YWE.js +0 -34
  206. package/dist/chunk-4RMX5YWE.js.map +0 -1
  207. package/dist/chunk-52OU772R.mjs +0 -122
  208. package/dist/chunk-52OU772R.mjs.map +0 -1
  209. package/dist/chunk-5AVWINSB.js +0 -1
  210. package/dist/chunk-5AVWINSB.js.map +0 -1
  211. package/dist/chunk-622IOGVI.mjs +0 -1
  212. package/dist/chunk-622IOGVI.mjs.map +0 -1
  213. package/dist/chunk-6C35XQOF.mjs +0 -257
  214. package/dist/chunk-6C35XQOF.mjs.map +0 -1
  215. package/dist/chunk-6NZW4WK4.js +0 -35
  216. package/dist/chunk-6NZW4WK4.js.map +0 -1
  217. package/dist/chunk-6ZDHSOUV.js +0 -59
  218. package/dist/chunk-6ZDHSOUV.js.map +0 -1
  219. package/dist/chunk-74DGVJVE.mjs +0 -59
  220. package/dist/chunk-74DGVJVE.mjs.map +0 -1
  221. package/dist/chunk-AY6FDCBT.mjs +0 -1
  222. package/dist/chunk-AY6FDCBT.mjs.map +0 -1
  223. package/dist/chunk-B7LIM2PK.mjs +0 -23
  224. package/dist/chunk-B7LIM2PK.mjs.map +0 -1
  225. package/dist/chunk-BFQDMI3M.js +0 -122
  226. package/dist/chunk-BFQDMI3M.js.map +0 -1
  227. package/dist/chunk-DHVKFDHQ.js +0 -95
  228. package/dist/chunk-DHVKFDHQ.js.map +0 -1
  229. package/dist/chunk-E4C7EW4R.js +0 -16
  230. package/dist/chunk-E4C7EW4R.js.map +0 -1
  231. package/dist/chunk-EQMZL4XU.js +0 -1
  232. package/dist/chunk-EQMZL4XU.js.map +0 -1
  233. package/dist/chunk-GZS3IQBZ.mjs +0 -16
  234. package/dist/chunk-GZS3IQBZ.mjs.map +0 -1
  235. package/dist/chunk-H4YFDLB7.mjs +0 -70
  236. package/dist/chunk-H4YFDLB7.mjs.map +0 -1
  237. package/dist/chunk-I575FZFH.mjs +0 -1
  238. package/dist/chunk-I575FZFH.mjs.map +0 -1
  239. package/dist/chunk-IZC266HS.js +0 -55
  240. package/dist/chunk-IZC266HS.js.map +0 -1
  241. package/dist/chunk-JPAL7Q5S.mjs +0 -90
  242. package/dist/chunk-JPAL7Q5S.mjs.map +0 -1
  243. package/dist/chunk-LC2CRSWD.js +0 -1
  244. package/dist/chunk-LC2CRSWD.js.map +0 -1
  245. package/dist/chunk-NQMRFZHB.mjs +0 -35
  246. package/dist/chunk-NQMRFZHB.mjs.map +0 -1
  247. package/dist/chunk-O3EIM33O.mjs +0 -95
  248. package/dist/chunk-O3EIM33O.mjs.map +0 -1
  249. package/dist/chunk-OLLG4H35.js +0 -257
  250. package/dist/chunk-OLLG4H35.js.map +0 -1
  251. package/dist/chunk-QEPVHEP7.js +0 -273
  252. package/dist/chunk-QVEKZRZ2.js +0 -70
  253. package/dist/chunk-QVEKZRZ2.js.map +0 -1
  254. package/dist/chunk-RIRDOQPX.mjs +0 -15
  255. package/dist/chunk-RIRDOQPX.mjs.map +0 -1
  256. package/dist/chunk-RKRGAFXY.js +0 -1
  257. package/dist/chunk-RKRGAFXY.js.map +0 -1
  258. package/dist/chunk-ROQSKDP5.mjs +0 -69
  259. package/dist/chunk-ROQSKDP5.mjs.map +0 -1
  260. package/dist/chunk-RRYOWRCV.mjs +0 -1
  261. package/dist/chunk-RRYOWRCV.mjs.map +0 -1
  262. package/dist/chunk-S3UHBN2Z.mjs +0 -44
  263. package/dist/chunk-S3UHBN2Z.mjs.map +0 -1
  264. package/dist/chunk-TGOMTREC.mjs +0 -75
  265. package/dist/chunk-TGOMTREC.mjs.map +0 -1
  266. package/dist/chunk-THNLGEXV.mjs +0 -34
  267. package/dist/chunk-THNLGEXV.mjs.map +0 -1
  268. package/dist/chunk-U7ZUGCE7.js +0 -75
  269. package/dist/chunk-U7ZUGCE7.js.map +0 -1
  270. package/dist/chunk-UOTVU7OQ.js +0 -1
  271. package/dist/chunk-UOTVU7OQ.js.map +0 -1
  272. package/dist/chunk-VA2DRBDE.mjs +0 -273
  273. package/dist/chunk-VA2DRBDE.mjs.map +0 -1
  274. package/dist/chunk-VFXTVNXN.js +0 -44
  275. package/dist/chunk-VFXTVNXN.js.map +0 -1
  276. package/dist/chunk-WA4DHIND.mjs +0 -1
  277. package/dist/chunk-WA4DHIND.mjs.map +0 -1
  278. package/dist/chunk-X66SUIEF.mjs +0 -25
  279. package/dist/chunk-X66SUIEF.mjs.map +0 -1
  280. package/dist/chunk-XYGUOY6N.mjs +0 -55
  281. package/dist/chunk-XYGUOY6N.mjs.map +0 -1
  282. package/dist/chunk-Z2RGWDD7.js +0 -90
  283. package/dist/chunk-Z2RGWDD7.js.map +0 -1
  284. package/dist/coercers.js +0 -18
  285. package/dist/coercers.js.map +0 -1
  286. package/dist/collections.js +0 -10
  287. package/dist/collections.js.map +0 -1
  288. package/dist/encryption-types.js +0 -2
  289. package/dist/encryption-types.js.map +0 -1
  290. package/dist/errors.js +0 -17
  291. package/dist/errors.js.map +0 -1
  292. package/dist/fs.js +0 -26
  293. package/dist/fs.js.map +0 -1
  294. package/dist/hex.js +0 -35
  295. package/dist/hex.js.map +0 -1
  296. package/dist/index.js +0 -293
  297. package/dist/index.js.map +0 -1
  298. package/dist/json.js +0 -75
  299. package/dist/json.js.map +0 -1
  300. package/dist/keyring.js +0 -2
  301. package/dist/keyring.js.map +0 -1
  302. package/dist/logging.js +0 -10
  303. package/dist/logging.js.map +0 -1
  304. package/dist/misc.js +0 -28
  305. package/dist/misc.js.map +0 -1
  306. package/dist/node.js +0 -313
  307. package/dist/node.js.map +0 -1
  308. package/dist/number.js +0 -18
  309. package/dist/number.js.map +0 -1
  310. package/dist/opaque.js +0 -2
  311. package/dist/opaque.js.map +0 -1
  312. package/dist/promise.js +0 -8
  313. package/dist/promise.js.map +0 -1
  314. package/dist/time.js +0 -12
  315. package/dist/time.js.map +0 -1
  316. package/dist/transaction-types.js +0 -2
  317. package/dist/transaction-types.js.map +0 -1
  318. package/dist/types/assert.d.ts.map +0 -1
  319. package/dist/types/base64.d.ts.map +0 -1
  320. package/dist/types/bytes.d.ts.map +0 -1
  321. package/dist/types/caip-types.d.ts.map +0 -1
  322. package/dist/types/checksum.d.ts +0 -2
  323. package/dist/types/checksum.d.ts.map +0 -1
  324. package/dist/types/coercers.d.ts.map +0 -1
  325. package/dist/types/collections.d.ts.map +0 -1
  326. package/dist/types/encryption-types.d.ts.map +0 -1
  327. package/dist/types/errors.d.ts.map +0 -1
  328. package/dist/types/fs.d.ts.map +0 -1
  329. package/dist/types/hex.d.ts.map +0 -1
  330. package/dist/types/index.d.ts +0 -21
  331. package/dist/types/index.d.ts.map +0 -1
  332. package/dist/types/json.d.ts.map +0 -1
  333. package/dist/types/keyring.d.ts.map +0 -1
  334. package/dist/types/logging.d.ts.map +0 -1
  335. package/dist/types/misc.d.ts.map +0 -1
  336. package/dist/types/node.d.ts +0 -3
  337. package/dist/types/node.d.ts.map +0 -1
  338. package/dist/types/number.d.ts.map +0 -1
  339. package/dist/types/opaque.d.ts +0 -6
  340. package/dist/types/opaque.d.ts.map +0 -1
  341. package/dist/types/promise.d.ts.map +0 -1
  342. package/dist/types/time.d.ts.map +0 -1
  343. package/dist/types/transaction-types.d.ts.map +0 -1
  344. package/dist/types/versions.d.ts.map +0 -1
  345. package/dist/versions.js +0 -27
  346. package/dist/versions.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A {@link ReadonlyMap} that cannot be modified after instantiation.
3
+ * The implementation uses an inner map hidden via a private field, and the
4
+ * immutability guarantee relies on it being impossible to get a reference
5
+ * to this map.
6
+ */
7
+ declare class FrozenMap<Key, Value> implements ReadonlyMap<Key, Value> {
8
+ #private;
9
+ get size(): number;
10
+ [Symbol.iterator](): IterableIterator<[Key, Value]>;
11
+ constructor(entries?: readonly (readonly [Key, Value])[] | null);
12
+ entries(): IterableIterator<[Key, Value]>;
13
+ forEach(callbackfn: (value: Value, key: Key, map: this) => void, thisArg?: any): void;
14
+ get(key: Key): Value | undefined;
15
+ has(key: Key): boolean;
16
+ keys(): IterableIterator<Key>;
17
+ values(): IterableIterator<Value>;
18
+ toString(): string;
19
+ }
20
+ /**
21
+ * A {@link ReadonlySet} that cannot be modified after instantiation.
22
+ * The implementation uses an inner set hidden via a private field, and the
23
+ * immutability guarantee relies on it being impossible to get a reference
24
+ * to this set.
25
+ */
26
+ declare class FrozenSet<Value> implements ReadonlySet<Value> {
27
+ #private;
28
+ get size(): number;
29
+ [Symbol.iterator](): IterableIterator<Value>;
30
+ constructor(values?: readonly Value[] | null);
31
+ entries(): IterableIterator<[Value, Value]>;
32
+ forEach(callbackfn: (value: Value, value2: Value, set: this) => void, thisArg?: any): void;
33
+ has(value: Value): boolean;
34
+ keys(): IterableIterator<Value>;
35
+ values(): IterableIterator<Value>;
36
+ toString(): string;
37
+ }
38
+ export { FrozenMap, FrozenSet };
39
+ //# sourceMappingURL=collections.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.d.mts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAM,SAAS,CAAC,GAAG,EAAE,KAAK,CAAE,YAAW,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC;;IAG5D,IAAW,IAAI,WAEd;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAIZ,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,IAAI;IAKxD,OAAO;IAIP,OAAO,CACZ,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EACvD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAQA,GAAG,CAAC,GAAG,EAAE,GAAG;IAIZ,GAAG,CAAC,GAAG,EAAE,GAAG;IAIZ,IAAI;IAIJ,MAAM;IAIN,QAAQ,IAAI,MAAM;CAS1B;AAED;;;;;GAKG;AACH,cAAM,SAAS,CAAC,KAAK,CAAE,YAAW,WAAW,CAAC,KAAK,CAAC;;IAGlD,IAAW,IAAI,WAEd;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAIZ,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI;IAKrC,OAAO;IAIP,OAAO,CACZ,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EAC5D,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAQA,GAAG,CAAC,KAAK,EAAE,KAAK;IAIhB,IAAI;IAIJ,MAAM;IAIN,QAAQ,IAAI,MAAM;CAO1B;AAQD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
@@ -1,10 +1,105 @@
1
- import {
2
- FrozenMap,
3
- FrozenSet
4
- } from "./chunk-JPAL7Q5S.mjs";
5
- import "./chunk-X66SUIEF.mjs";
6
- export {
7
- FrozenMap,
8
- FrozenSet
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9
5
  };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _FrozenMap_map, _FrozenSet_set;
13
+ /**
14
+ * A {@link ReadonlyMap} that cannot be modified after instantiation.
15
+ * The implementation uses an inner map hidden via a private field, and the
16
+ * immutability guarantee relies on it being impossible to get a reference
17
+ * to this map.
18
+ */
19
+ class FrozenMap {
20
+ get size() {
21
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").size;
22
+ }
23
+ [(_FrozenMap_map = new WeakMap(), Symbol.iterator)]() {
24
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f")[Symbol.iterator]();
25
+ }
26
+ constructor(entries) {
27
+ _FrozenMap_map.set(this, void 0);
28
+ __classPrivateFieldSet(this, _FrozenMap_map, new Map(entries), "f");
29
+ Object.freeze(this);
30
+ }
31
+ entries() {
32
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").entries();
33
+ }
34
+ forEach(callbackfn, thisArg) {
35
+ // We have to wrap the specified callback in order to prevent it from
36
+ // receiving a reference to the inner map.
37
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").forEach((value, key, _map) => callbackfn.call(thisArg, value, key, this));
38
+ }
39
+ get(key) {
40
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").get(key);
41
+ }
42
+ has(key) {
43
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").has(key);
44
+ }
45
+ keys() {
46
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").keys();
47
+ }
48
+ values() {
49
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").values();
50
+ }
51
+ toString() {
52
+ return `FrozenMap(${this.size}) {${this.size > 0
53
+ ? ` ${[...this.entries()]
54
+ .map(([key, value]) => `${String(key)} => ${String(value)}`)
55
+ .join(', ')} `
56
+ : ''}}`;
57
+ }
58
+ }
59
+ /**
60
+ * A {@link ReadonlySet} that cannot be modified after instantiation.
61
+ * The implementation uses an inner set hidden via a private field, and the
62
+ * immutability guarantee relies on it being impossible to get a reference
63
+ * to this set.
64
+ */
65
+ class FrozenSet {
66
+ get size() {
67
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").size;
68
+ }
69
+ [(_FrozenSet_set = new WeakMap(), Symbol.iterator)]() {
70
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f")[Symbol.iterator]();
71
+ }
72
+ constructor(values) {
73
+ _FrozenSet_set.set(this, void 0);
74
+ __classPrivateFieldSet(this, _FrozenSet_set, new Set(values), "f");
75
+ Object.freeze(this);
76
+ }
77
+ entries() {
78
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").entries();
79
+ }
80
+ forEach(callbackfn, thisArg) {
81
+ // We have to wrap the specified callback in order to prevent it from
82
+ // receiving a reference to the inner set.
83
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").forEach((value, value2, _set) => callbackfn.call(thisArg, value, value2, this));
84
+ }
85
+ has(value) {
86
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").has(value);
87
+ }
88
+ keys() {
89
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").keys();
90
+ }
91
+ values() {
92
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").values();
93
+ }
94
+ toString() {
95
+ return `FrozenSet(${this.size}) {${this.size > 0
96
+ ? ` ${[...this.values()].map((member) => String(member)).join(', ')} `
97
+ : ''}}`;
98
+ }
99
+ }
100
+ Object.freeze(FrozenMap);
101
+ Object.freeze(FrozenMap.prototype);
102
+ Object.freeze(FrozenSet);
103
+ Object.freeze(FrozenSet.prototype);
104
+ export { FrozenMap, FrozenSet };
10
105
  //# sourceMappingURL=collections.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"collections.mjs","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;GAKG;AACH,MAAM,SAAS;IAGb,IAAW,IAAI;QACb,OAAO,uBAAA,IAAI,sBAAK,CAAC,IAAI,CAAC;IACxB,CAAC;IAEM,kCAAC,MAAM,CAAC,QAAQ,EAAC;QACtB,OAAO,uBAAA,IAAI,sBAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtC,CAAC;IAED,YAAY,OAAmD;QAVtD,iCAAsB;QAW7B,uBAAA,IAAI,kBAAQ,IAAI,GAAG,CAAa,OAAO,CAAC,MAAA,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAEM,OAAO;QACZ,OAAO,uBAAA,IAAI,sBAAK,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,OAAO,CACZ,UAAuD,EACvD,OAAa;QAEb,qEAAqE;QACrE,0CAA0C;QAC1C,OAAO,uBAAA,IAAI,sBAA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,CAAC,SAAS,CAAC,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC","sourcesContent":["/**\n * A {@link ReadonlyMap} that cannot be modified after instantiation.\n * The implementation uses an inner map hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this map.\n */\nclass FrozenMap<Key, Value> implements ReadonlyMap<Key, Value> {\n readonly #map: Map<Key, Value>;\n\n public get size() {\n return this.#map.size;\n }\n\n public [Symbol.iterator]() {\n return this.#map[Symbol.iterator]();\n }\n\n constructor(entries?: readonly (readonly [Key, Value])[] | null) {\n this.#map = new Map<Key, Value>(entries);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#map.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, key: Key, map: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner map.\n return this.#map.forEach((value: Value, key: Key, _map: unknown) =>\n callbackfn.call(thisArg, value, key, this),\n );\n }\n\n public get(key: Key) {\n return this.#map.get(key);\n }\n\n public has(key: Key) {\n return this.#map.has(key);\n }\n\n public keys() {\n return this.#map.keys();\n }\n\n public values() {\n return this.#map.values();\n }\n\n public toString(): string {\n return `FrozenMap(${this.size}) {${\n this.size > 0\n ? ` ${[...this.entries()]\n .map(([key, value]) => `${String(key)} => ${String(value)}`)\n .join(', ')} `\n : ''\n }}`;\n }\n}\n\n/**\n * A {@link ReadonlySet} that cannot be modified after instantiation.\n * The implementation uses an inner set hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this set.\n */\nclass FrozenSet<Value> implements ReadonlySet<Value> {\n readonly #set: Set<Value>;\n\n public get size() {\n return this.#set.size;\n }\n\n public [Symbol.iterator]() {\n return this.#set[Symbol.iterator]();\n }\n\n constructor(values?: readonly Value[] | null) {\n this.#set = new Set<Value>(values);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#set.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, value2: Value, set: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner set.\n return this.#set.forEach((value: Value, value2: Value, _set: unknown) =>\n callbackfn.call(thisArg, value, value2, this),\n );\n }\n\n public has(value: Value) {\n return this.#set.has(value);\n }\n\n public keys() {\n return this.#set.keys();\n }\n\n public values() {\n return this.#set.values();\n }\n\n public toString(): string {\n return `FrozenSet(${this.size}) {${\n this.size > 0\n ? ` ${[...this.values()].map((member) => String(member)).join(', ')} `\n : ''\n }}`;\n }\n}\n\nObject.freeze(FrozenMap);\nObject.freeze(FrozenMap.prototype);\n\nObject.freeze(FrozenSet);\nObject.freeze(FrozenSet.prototype);\n\nexport { FrozenMap, FrozenSet };\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=encryption-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption-types.cjs","sourceRoot":"","sources":["../src/encryption-types.ts"],"names":[],"mappings":"","sourcesContent":["export type Eip1024EncryptedData = {\n version: string;\n nonce: string;\n ephemPublicKey: string;\n ciphertext: string;\n};\n"]}
@@ -1,7 +1,7 @@
1
- export declare type Eip1024EncryptedData = {
1
+ export type Eip1024EncryptedData = {
2
2
  version: string;
3
3
  nonce: string;
4
4
  ephemPublicKey: string;
5
5
  ciphertext: string;
6
6
  };
7
- //# sourceMappingURL=encryption-types.d.ts.map
7
+ //# sourceMappingURL=encryption-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption-types.d.cts","sourceRoot":"","sources":["../src/encryption-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type Eip1024EncryptedData = {
2
+ version: string;
3
+ nonce: string;
4
+ ephemPublicKey: string;
5
+ ciphertext: string;
6
+ };
7
+ //# sourceMappingURL=encryption-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption-types.d.mts","sourceRoot":"","sources":["../src/encryption-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -1,2 +1,2 @@
1
- import "./chunk-WA4DHIND.mjs";
1
+ export {};
2
2
  //# sourceMappingURL=encryption-types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"encryption-types.mjs","sourceRoot":"","sources":["../src/encryption-types.ts"],"names":[],"mappings":"","sourcesContent":["export type Eip1024EncryptedData = {\n version: string;\n nonce: string;\n ephemPublicKey: string;\n ciphertext: string;\n};\n"]}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapError = exports.getErrorMessage = exports.isErrorWithStack = exports.isErrorWithMessage = exports.isErrorWithCode = void 0;
4
+ const pony_cause_1 = require("pony-cause");
5
+ const misc_1 = require("./misc.cjs");
6
+ /**
7
+ * Type guard for determining whether the given value is an instance of Error.
8
+ * For errors generated via `fs.promises`, `error instanceof Error` won't work,
9
+ * so we have to come up with another way of testing.
10
+ *
11
+ * @param error - The object to check.
12
+ * @returns A boolean.
13
+ */
14
+ function isError(error) {
15
+ return (error instanceof Error ||
16
+ ((0, misc_1.isObject)(error) && error.constructor.name === 'Error'));
17
+ }
18
+ /**
19
+ * Type guard for determining whether the given value is an error object with a
20
+ * `code` property such as the type of error that Node throws for filesystem
21
+ * operations, etc.
22
+ *
23
+ * @param error - The object to check.
24
+ * @returns A boolean.
25
+ */
26
+ function isErrorWithCode(error) {
27
+ return typeof error === 'object' && error !== null && 'code' in error;
28
+ }
29
+ exports.isErrorWithCode = isErrorWithCode;
30
+ /**
31
+ * Type guard for determining whether the given value is an error object with a
32
+ * `message` property, such as an instance of Error.
33
+ *
34
+ * @param error - The object to check.
35
+ * @returns A boolean.
36
+ */
37
+ function isErrorWithMessage(error) {
38
+ return typeof error === 'object' && error !== null && 'message' in error;
39
+ }
40
+ exports.isErrorWithMessage = isErrorWithMessage;
41
+ /**
42
+ * Type guard for determining whether the given value is an error object with a
43
+ * `stack` property, such as an instance of Error.
44
+ *
45
+ * @param error - The object to check.
46
+ * @returns A boolean.
47
+ */
48
+ function isErrorWithStack(error) {
49
+ return typeof error === 'object' && error !== null && 'stack' in error;
50
+ }
51
+ exports.isErrorWithStack = isErrorWithStack;
52
+ /**
53
+ * Attempts to obtain the message from a possible error object, defaulting to an
54
+ * empty string if it is impossible to do so.
55
+ *
56
+ * @param error - The possible error to get the message from.
57
+ * @returns The message if `error` is an object with a `message` property;
58
+ * the string version of `error` if it is not `undefined` or `null`; otherwise
59
+ * an empty string.
60
+ */
61
+ function getErrorMessage(error) {
62
+ if (isErrorWithMessage(error) && typeof error.message === 'string') {
63
+ return error.message;
64
+ }
65
+ if ((0, misc_1.isNullOrUndefined)(error)) {
66
+ return '';
67
+ }
68
+ return String(error);
69
+ }
70
+ exports.getErrorMessage = getErrorMessage;
71
+ /**
72
+ * Builds a new error object, linking it to the original error via the `cause`
73
+ * property if it is an Error.
74
+ *
75
+ * This function is useful to reframe error messages in general, but is
76
+ * _critical_ when interacting with any of Node's filesystem functions as
77
+ * provided via `fs.promises`, because these do not produce stack traces in the
78
+ * case of an I/O error (see <https://github.com/nodejs/node/issues/30944>).
79
+ *
80
+ * @param originalError - The error to be wrapped (something throwable).
81
+ * @param message - The desired message of the new error.
82
+ * @returns A new error object.
83
+ */
84
+ function wrapError(originalError, message) {
85
+ if (isError(originalError)) {
86
+ let error;
87
+ if (Error.length === 2) {
88
+ // for some reason `tsserver` is not complaining that the
89
+ // Error constructor doesn't support a second argument in the editor,
90
+ // but `tsc` does. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)
91
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
92
+ // @ts-ignore
93
+ error = new Error(message, { cause: originalError });
94
+ }
95
+ else {
96
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
97
+ // @ts-ignore
98
+ error = new pony_cause_1.ErrorWithCause(message, { cause: originalError });
99
+ }
100
+ if (isErrorWithCode(originalError)) {
101
+ error.code = originalError.code;
102
+ }
103
+ return error;
104
+ }
105
+ if (message.length > 0) {
106
+ return new Error(`${String(originalError)}: ${message}`);
107
+ }
108
+ return new Error(String(originalError));
109
+ }
110
+ exports.wrapError = wrapError;
111
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAE5C,qCAAqD;AAErD;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,CAAC,IAAA,eAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC;AACxE,CAAC;AAFD,0CAEC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,CAAC;AAC3E,CAAC;AAJD,gDAIC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OA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C,CAAC,CAAC;AAC1C,CAAC;AA/BD,8BA+BC","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"]}
@@ -55,4 +55,4 @@ export declare function getErrorMessage(error: unknown): string;
55
55
  export declare function wrapError<Throwable>(originalError: Throwable, message: string): Error & {
56
56
  code?: string;
57
57
  };
58
- //# sourceMappingURL=errors.d.ts.map
58
+ //# sourceMappingURL=errors.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAE3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,SAAS,EACjC,aAAa,EAAE,SAAS,EACxB,OAAO,EAAE,MAAM,GACd,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CA4B3B"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Type guard for determining whether the given value is an error object with a
3
+ * `code` property such as the type of error that Node throws for filesystem
4
+ * operations, etc.
5
+ *
6
+ * @param error - The object to check.
7
+ * @returns A boolean.
8
+ */
9
+ export declare function isErrorWithCode(error: unknown): error is {
10
+ code: string;
11
+ };
12
+ /**
13
+ * Type guard for determining whether the given value is an error object with a
14
+ * `message` property, such as an instance of Error.
15
+ *
16
+ * @param error - The object to check.
17
+ * @returns A boolean.
18
+ */
19
+ export declare function isErrorWithMessage(error: unknown): error is {
20
+ message: string;
21
+ };
22
+ /**
23
+ * Type guard for determining whether the given value is an error object with a
24
+ * `stack` property, such as an instance of Error.
25
+ *
26
+ * @param error - The object to check.
27
+ * @returns A boolean.
28
+ */
29
+ export declare function isErrorWithStack(error: unknown): error is {
30
+ stack: string;
31
+ };
32
+ /**
33
+ * Attempts to obtain the message from a possible error object, defaulting to an
34
+ * empty string if it is impossible to do so.
35
+ *
36
+ * @param error - The possible error to get the message from.
37
+ * @returns The message if `error` is an object with a `message` property;
38
+ * the string version of `error` if it is not `undefined` or `null`; otherwise
39
+ * an empty string.
40
+ */
41
+ export declare function getErrorMessage(error: unknown): string;
42
+ /**
43
+ * Builds a new error object, linking it to the original error via the `cause`
44
+ * property if it is an Error.
45
+ *
46
+ * This function is useful to reframe error messages in general, but is
47
+ * _critical_ when interacting with any of Node's filesystem functions as
48
+ * provided via `fs.promises`, because these do not produce stack traces in the
49
+ * case of an I/O error (see <https://github.com/nodejs/node/issues/30944>).
50
+ *
51
+ * @param originalError - The error to be wrapped (something throwable).
52
+ * @param message - The desired message of the new error.
53
+ * @returns A new error object.
54
+ */
55
+ export declare function wrapError<Throwable>(originalError: Throwable, message: string): Error & {
56
+ code?: string;
57
+ };
58
+ //# sourceMappingURL=errors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAE9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAE3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,SAAS,EACjC,aAAa,EAAE,SAAS,EACxB,OAAO,EAAE,MAAM,GACd,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CA4B3B"}
package/dist/errors.mjs CHANGED
@@ -1,17 +1,103 @@
1
- import {
2
- getErrorMessage,
3
- isErrorWithCode,
4
- isErrorWithMessage,
5
- isErrorWithStack,
6
- wrapError
7
- } from "./chunk-XYGUOY6N.mjs";
8
- import "./chunk-H4YFDLB7.mjs";
9
- import "./chunk-X66SUIEF.mjs";
10
- export {
11
- getErrorMessage,
12
- isErrorWithCode,
13
- isErrorWithMessage,
14
- isErrorWithStack,
15
- wrapError
16
- };
1
+ import { ErrorWithCause } from "pony-cause";
2
+ import { isNullOrUndefined, isObject } from "./misc.mjs";
3
+ /**
4
+ * Type guard for determining whether the given value is an instance of Error.
5
+ * For errors generated via `fs.promises`, `error instanceof Error` won't work,
6
+ * so we have to come up with another way of testing.
7
+ *
8
+ * @param error - The object to check.
9
+ * @returns A boolean.
10
+ */
11
+ function isError(error) {
12
+ return (error instanceof Error ||
13
+ (isObject(error) && error.constructor.name === 'Error'));
14
+ }
15
+ /**
16
+ * Type guard for determining whether the given value is an error object with a
17
+ * `code` property such as the type of error that Node throws for filesystem
18
+ * operations, etc.
19
+ *
20
+ * @param error - The object to check.
21
+ * @returns A boolean.
22
+ */
23
+ export function isErrorWithCode(error) {
24
+ return typeof error === 'object' && error !== null && 'code' in error;
25
+ }
26
+ /**
27
+ * Type guard for determining whether the given value is an error object with a
28
+ * `message` property, such as an instance of Error.
29
+ *
30
+ * @param error - The object to check.
31
+ * @returns A boolean.
32
+ */
33
+ export function isErrorWithMessage(error) {
34
+ return typeof error === 'object' && error !== null && 'message' in error;
35
+ }
36
+ /**
37
+ * Type guard for determining whether the given value is an error object with a
38
+ * `stack` property, such as an instance of Error.
39
+ *
40
+ * @param error - The object to check.
41
+ * @returns A boolean.
42
+ */
43
+ export function isErrorWithStack(error) {
44
+ return typeof error === 'object' && error !== null && 'stack' in error;
45
+ }
46
+ /**
47
+ * Attempts to obtain the message from a possible error object, defaulting to an
48
+ * empty string if it is impossible to do so.
49
+ *
50
+ * @param error - The possible error to get the message from.
51
+ * @returns The message if `error` is an object with a `message` property;
52
+ * the string version of `error` if it is not `undefined` or `null`; otherwise
53
+ * an empty string.
54
+ */
55
+ export function getErrorMessage(error) {
56
+ if (isErrorWithMessage(error) && typeof error.message === 'string') {
57
+ return error.message;
58
+ }
59
+ if (isNullOrUndefined(error)) {
60
+ return '';
61
+ }
62
+ return String(error);
63
+ }
64
+ /**
65
+ * Builds a new error object, linking it to the original error via the `cause`
66
+ * property if it is an Error.
67
+ *
68
+ * This function is useful to reframe error messages in general, but is
69
+ * _critical_ when interacting with any of Node's filesystem functions as
70
+ * provided via `fs.promises`, because these do not produce stack traces in the
71
+ * case of an I/O error (see <https://github.com/nodejs/node/issues/30944>).
72
+ *
73
+ * @param originalError - The error to be wrapped (something throwable).
74
+ * @param message - The desired message of the new error.
75
+ * @returns A new error object.
76
+ */
77
+ export function wrapError(originalError, message) {
78
+ if (isError(originalError)) {
79
+ let error;
80
+ if (Error.length === 2) {
81
+ // for some reason `tsserver` is not complaining that the
82
+ // Error constructor doesn't support a second argument in the editor,
83
+ // but `tsc` does. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)
84
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
85
+ // @ts-ignore
86
+ error = new Error(message, { cause: originalError });
87
+ }
88
+ else {
89
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
90
+ // @ts-ignore
91
+ error = new ErrorWithCause(message, { cause: originalError });
92
+ }
93
+ if (isErrorWithCode(originalError)) {
94
+ error.code = originalError.code;
95
+ }
96
+ return error;
97
+ }
98
+ if (message.length > 0) {
99
+ return new Error(`${String(originalError)}: ${message}`);
100
+ }
101
+ return new Error(String(originalError));
102
+ }
17
103
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB;AAE5C,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,mBAAe;AAErD;;;;;;;GAOG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,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CAAC;SACjC;QAED,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,OAAO,IAAI,KAAK,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;KAC1D;IAED,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAC1C,CAAC","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"]}