bupkis 0.18.1 → 0.18.2

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 (376) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -4
  3. package/src/assertion/assertion-types.ts +4 -4
  4. package/src/assertion/impl/sync-parametric.ts +1 -1
  5. package/src/expect.ts +0 -4
  6. package/src/guards.ts +24 -24
  7. package/src/internal-schema.ts +16 -32
  8. package/src/value-to-schema.ts +1 -1
  9. package/dist/assertion/assertion-async.cjs +0 -268
  10. package/dist/assertion/assertion-async.cjs.map +0 -1
  11. package/dist/assertion/assertion-async.d.cts +0 -40
  12. package/dist/assertion/assertion-async.d.cts.map +0 -1
  13. package/dist/assertion/assertion-async.d.ts +0 -40
  14. package/dist/assertion/assertion-async.d.ts.map +0 -1
  15. package/dist/assertion/assertion-async.js +0 -259
  16. package/dist/assertion/assertion-async.js.map +0 -1
  17. package/dist/assertion/assertion-standard-schema-async.cjs +0 -132
  18. package/dist/assertion/assertion-standard-schema-async.cjs.map +0 -1
  19. package/dist/assertion/assertion-standard-schema-async.d.cts +0 -52
  20. package/dist/assertion/assertion-standard-schema-async.d.cts.map +0 -1
  21. package/dist/assertion/assertion-standard-schema-async.d.ts +0 -52
  22. package/dist/assertion/assertion-standard-schema-async.d.ts.map +0 -1
  23. package/dist/assertion/assertion-standard-schema-async.js +0 -128
  24. package/dist/assertion/assertion-standard-schema-async.js.map +0 -1
  25. package/dist/assertion/assertion-standard-schema-sync.cjs +0 -141
  26. package/dist/assertion/assertion-standard-schema-sync.cjs.map +0 -1
  27. package/dist/assertion/assertion-standard-schema-sync.d.cts +0 -52
  28. package/dist/assertion/assertion-standard-schema-sync.d.cts.map +0 -1
  29. package/dist/assertion/assertion-standard-schema-sync.d.ts +0 -52
  30. package/dist/assertion/assertion-standard-schema-sync.d.ts.map +0 -1
  31. package/dist/assertion/assertion-standard-schema-sync.js +0 -137
  32. package/dist/assertion/assertion-standard-schema-sync.js.map +0 -1
  33. package/dist/assertion/assertion-sync.cjs +0 -284
  34. package/dist/assertion/assertion-sync.cjs.map +0 -1
  35. package/dist/assertion/assertion-sync.d.cts +0 -60
  36. package/dist/assertion/assertion-sync.d.cts.map +0 -1
  37. package/dist/assertion/assertion-sync.d.ts +0 -60
  38. package/dist/assertion/assertion-sync.d.ts.map +0 -1
  39. package/dist/assertion/assertion-sync.js +0 -275
  40. package/dist/assertion/assertion-sync.js.map +0 -1
  41. package/dist/assertion/assertion-types.cjs +0 -20
  42. package/dist/assertion/assertion-types.cjs.map +0 -1
  43. package/dist/assertion/assertion-types.d.cts +0 -1086
  44. package/dist/assertion/assertion-types.d.cts.map +0 -1
  45. package/dist/assertion/assertion-types.d.ts +0 -1086
  46. package/dist/assertion/assertion-types.d.ts.map +0 -1
  47. package/dist/assertion/assertion-types.js +0 -19
  48. package/dist/assertion/assertion-types.js.map +0 -1
  49. package/dist/assertion/assertion.cjs +0 -382
  50. package/dist/assertion/assertion.cjs.map +0 -1
  51. package/dist/assertion/assertion.d.cts +0 -109
  52. package/dist/assertion/assertion.d.cts.map +0 -1
  53. package/dist/assertion/assertion.d.ts +0 -109
  54. package/dist/assertion/assertion.d.ts.map +0 -1
  55. package/dist/assertion/assertion.js +0 -375
  56. package/dist/assertion/assertion.js.map +0 -1
  57. package/dist/assertion/create.cjs +0 -148
  58. package/dist/assertion/create.cjs.map +0 -1
  59. package/dist/assertion/create.d.cts +0 -85
  60. package/dist/assertion/create.d.cts.map +0 -1
  61. package/dist/assertion/create.d.ts +0 -85
  62. package/dist/assertion/create.d.ts.map +0 -1
  63. package/dist/assertion/create.js +0 -143
  64. package/dist/assertion/create.js.map +0 -1
  65. package/dist/assertion/format-assertion-failure.cjs +0 -63
  66. package/dist/assertion/format-assertion-failure.cjs.map +0 -1
  67. package/dist/assertion/format-assertion-failure.d.cts +0 -21
  68. package/dist/assertion/format-assertion-failure.d.cts.map +0 -1
  69. package/dist/assertion/format-assertion-failure.d.ts +0 -21
  70. package/dist/assertion/format-assertion-failure.d.ts.map +0 -1
  71. package/dist/assertion/format-assertion-failure.js +0 -59
  72. package/dist/assertion/format-assertion-failure.js.map +0 -1
  73. package/dist/assertion/impl/assertion-util.cjs +0 -68
  74. package/dist/assertion/impl/assertion-util.cjs.map +0 -1
  75. package/dist/assertion/impl/assertion-util.d.cts +0 -36
  76. package/dist/assertion/impl/assertion-util.d.cts.map +0 -1
  77. package/dist/assertion/impl/assertion-util.d.ts +0 -36
  78. package/dist/assertion/impl/assertion-util.d.ts.map +0 -1
  79. package/dist/assertion/impl/assertion-util.js +0 -62
  80. package/dist/assertion/impl/assertion-util.js.map +0 -1
  81. package/dist/assertion/impl/async-iterable.cjs +0 -627
  82. package/dist/assertion/impl/async-iterable.cjs.map +0 -1
  83. package/dist/assertion/impl/async-iterable.d.cts +0 -406
  84. package/dist/assertion/impl/async-iterable.d.cts.map +0 -1
  85. package/dist/assertion/impl/async-iterable.d.ts +0 -406
  86. package/dist/assertion/impl/async-iterable.d.ts.map +0 -1
  87. package/dist/assertion/impl/async-iterable.js +0 -624
  88. package/dist/assertion/impl/async-iterable.js.map +0 -1
  89. package/dist/assertion/impl/async-parametric.cjs +0 -412
  90. package/dist/assertion/impl/async-parametric.cjs.map +0 -1
  91. package/dist/assertion/impl/async-parametric.d.cts +0 -278
  92. package/dist/assertion/impl/async-parametric.d.cts.map +0 -1
  93. package/dist/assertion/impl/async-parametric.d.ts +0 -278
  94. package/dist/assertion/impl/async-parametric.d.ts.map +0 -1
  95. package/dist/assertion/impl/async-parametric.js +0 -409
  96. package/dist/assertion/impl/async-parametric.js.map +0 -1
  97. package/dist/assertion/impl/async.cjs +0 -56
  98. package/dist/assertion/impl/async.cjs.map +0 -1
  99. package/dist/assertion/impl/async.d.cts +0 -179
  100. package/dist/assertion/impl/async.d.cts.map +0 -1
  101. package/dist/assertion/impl/async.d.ts +0 -179
  102. package/dist/assertion/impl/async.d.ts.map +0 -1
  103. package/dist/assertion/impl/async.js +0 -39
  104. package/dist/assertion/impl/async.js.map +0 -1
  105. package/dist/assertion/impl/index.cjs +0 -37
  106. package/dist/assertion/impl/index.cjs.map +0 -1
  107. package/dist/assertion/impl/index.d.cts +0 -21
  108. package/dist/assertion/impl/index.d.cts.map +0 -1
  109. package/dist/assertion/impl/index.d.ts +0 -21
  110. package/dist/assertion/impl/index.d.ts.map +0 -1
  111. package/dist/assertion/impl/index.js +0 -21
  112. package/dist/assertion/impl/index.js.map +0 -1
  113. package/dist/assertion/impl/iteration-util.cjs +0 -297
  114. package/dist/assertion/impl/iteration-util.cjs.map +0 -1
  115. package/dist/assertion/impl/iteration-util.d.cts +0 -12
  116. package/dist/assertion/impl/iteration-util.d.cts.map +0 -1
  117. package/dist/assertion/impl/iteration-util.d.ts +0 -12
  118. package/dist/assertion/impl/iteration-util.d.ts.map +0 -1
  119. package/dist/assertion/impl/iteration-util.js +0 -282
  120. package/dist/assertion/impl/iteration-util.js.map +0 -1
  121. package/dist/assertion/impl/snapshot.cjs +0 -276
  122. package/dist/assertion/impl/snapshot.cjs.map +0 -1
  123. package/dist/assertion/impl/snapshot.d.cts +0 -278
  124. package/dist/assertion/impl/snapshot.d.cts.map +0 -1
  125. package/dist/assertion/impl/snapshot.d.ts +0 -278
  126. package/dist/assertion/impl/snapshot.d.ts.map +0 -1
  127. package/dist/assertion/impl/snapshot.js +0 -273
  128. package/dist/assertion/impl/snapshot.js.map +0 -1
  129. package/dist/assertion/impl/sync-basic.cjs +0 -553
  130. package/dist/assertion/impl/sync-basic.cjs.map +0 -1
  131. package/dist/assertion/impl/sync-basic.d.cts +0 -528
  132. package/dist/assertion/impl/sync-basic.d.cts.map +0 -1
  133. package/dist/assertion/impl/sync-basic.d.ts +0 -528
  134. package/dist/assertion/impl/sync-basic.d.ts.map +0 -1
  135. package/dist/assertion/impl/sync-basic.js +0 -550
  136. package/dist/assertion/impl/sync-basic.js.map +0 -1
  137. package/dist/assertion/impl/sync-collection.cjs +0 -856
  138. package/dist/assertion/impl/sync-collection.cjs.map +0 -1
  139. package/dist/assertion/impl/sync-collection.d.cts +0 -607
  140. package/dist/assertion/impl/sync-collection.d.cts.map +0 -1
  141. package/dist/assertion/impl/sync-collection.d.ts +0 -607
  142. package/dist/assertion/impl/sync-collection.d.ts.map +0 -1
  143. package/dist/assertion/impl/sync-collection.js +0 -850
  144. package/dist/assertion/impl/sync-collection.js.map +0 -1
  145. package/dist/assertion/impl/sync-date.cjs +0 -341
  146. package/dist/assertion/impl/sync-date.cjs.map +0 -1
  147. package/dist/assertion/impl/sync-date.d.cts +0 -209
  148. package/dist/assertion/impl/sync-date.d.cts.map +0 -1
  149. package/dist/assertion/impl/sync-date.d.ts +0 -209
  150. package/dist/assertion/impl/sync-date.d.ts.map +0 -1
  151. package/dist/assertion/impl/sync-date.js +0 -338
  152. package/dist/assertion/impl/sync-date.js.map +0 -1
  153. package/dist/assertion/impl/sync-esoteric.cjs +0 -214
  154. package/dist/assertion/impl/sync-esoteric.cjs.map +0 -1
  155. package/dist/assertion/impl/sync-esoteric.d.cts +0 -191
  156. package/dist/assertion/impl/sync-esoteric.d.cts.map +0 -1
  157. package/dist/assertion/impl/sync-esoteric.d.ts +0 -191
  158. package/dist/assertion/impl/sync-esoteric.d.ts.map +0 -1
  159. package/dist/assertion/impl/sync-esoteric.js +0 -211
  160. package/dist/assertion/impl/sync-esoteric.js.map +0 -1
  161. package/dist/assertion/impl/sync-iterable.cjs +0 -512
  162. package/dist/assertion/impl/sync-iterable.cjs.map +0 -1
  163. package/dist/assertion/impl/sync-iterable.d.cts +0 -334
  164. package/dist/assertion/impl/sync-iterable.d.cts.map +0 -1
  165. package/dist/assertion/impl/sync-iterable.d.ts +0 -334
  166. package/dist/assertion/impl/sync-iterable.d.ts.map +0 -1
  167. package/dist/assertion/impl/sync-iterable.js +0 -509
  168. package/dist/assertion/impl/sync-iterable.js.map +0 -1
  169. package/dist/assertion/impl/sync-parametric.cjs +0 -805
  170. package/dist/assertion/impl/sync-parametric.cjs.map +0 -1
  171. package/dist/assertion/impl/sync-parametric.d.cts +0 -560
  172. package/dist/assertion/impl/sync-parametric.d.cts.map +0 -1
  173. package/dist/assertion/impl/sync-parametric.d.ts +0 -560
  174. package/dist/assertion/impl/sync-parametric.d.ts.map +0 -1
  175. package/dist/assertion/impl/sync-parametric.js +0 -802
  176. package/dist/assertion/impl/sync-parametric.js.map +0 -1
  177. package/dist/assertion/impl/sync.cjs +0 -214
  178. package/dist/assertion/impl/sync.cjs.map +0 -1
  179. package/dist/assertion/impl/sync.d.cts +0 -512
  180. package/dist/assertion/impl/sync.d.cts.map +0 -1
  181. package/dist/assertion/impl/sync.d.ts +0 -512
  182. package/dist/assertion/impl/sync.d.ts.map +0 -1
  183. package/dist/assertion/impl/sync.js +0 -197
  184. package/dist/assertion/impl/sync.js.map +0 -1
  185. package/dist/assertion/index.cjs +0 -38
  186. package/dist/assertion/index.cjs.map +0 -1
  187. package/dist/assertion/index.d.cts +0 -18
  188. package/dist/assertion/index.d.cts.map +0 -1
  189. package/dist/assertion/index.d.ts +0 -18
  190. package/dist/assertion/index.d.ts.map +0 -1
  191. package/dist/assertion/index.js +0 -17
  192. package/dist/assertion/index.js.map +0 -1
  193. package/dist/assertion/slotify.cjs +0 -165
  194. package/dist/assertion/slotify.cjs.map +0 -1
  195. package/dist/assertion/slotify.d.cts +0 -11
  196. package/dist/assertion/slotify.d.cts.map +0 -1
  197. package/dist/assertion/slotify.d.ts +0 -11
  198. package/dist/assertion/slotify.d.ts.map +0 -1
  199. package/dist/assertion/slotify.js +0 -161
  200. package/dist/assertion/slotify.js.map +0 -1
  201. package/dist/bootstrap.cjs +0 -43
  202. package/dist/bootstrap.cjs.map +0 -1
  203. package/dist/bootstrap.d.cts +0 -27
  204. package/dist/bootstrap.d.cts.map +0 -1
  205. package/dist/bootstrap.d.ts +0 -27
  206. package/dist/bootstrap.d.ts.map +0 -1
  207. package/dist/bootstrap.js +0 -40
  208. package/dist/bootstrap.js.map +0 -1
  209. package/dist/constant.cjs +0 -82
  210. package/dist/constant.cjs.map +0 -1
  211. package/dist/constant.d.cts +0 -69
  212. package/dist/constant.d.cts.map +0 -1
  213. package/dist/constant.d.ts +0 -69
  214. package/dist/constant.d.ts.map +0 -1
  215. package/dist/constant.js +0 -79
  216. package/dist/constant.js.map +0 -1
  217. package/dist/diff.cjs +0 -340
  218. package/dist/diff.cjs.map +0 -1
  219. package/dist/diff.d.cts +0 -51
  220. package/dist/diff.d.cts.map +0 -1
  221. package/dist/diff.d.ts +0 -51
  222. package/dist/diff.d.ts.map +0 -1
  223. package/dist/diff.js +0 -334
  224. package/dist/diff.js.map +0 -1
  225. package/dist/error.cjs +0 -204
  226. package/dist/error.cjs.map +0 -1
  227. package/dist/error.d.cts +0 -212
  228. package/dist/error.d.cts.map +0 -1
  229. package/dist/error.d.ts +0 -212
  230. package/dist/error.d.ts.map +0 -1
  231. package/dist/error.js +0 -191
  232. package/dist/error.js.map +0 -1
  233. package/dist/expect.cjs +0 -590
  234. package/dist/expect.cjs.map +0 -1
  235. package/dist/expect.d.cts +0 -138
  236. package/dist/expect.d.cts.map +0 -1
  237. package/dist/expect.d.ts +0 -138
  238. package/dist/expect.d.ts.map +0 -1
  239. package/dist/expect.js +0 -582
  240. package/dist/expect.js.map +0 -1
  241. package/dist/guards.cjs +0 -297
  242. package/dist/guards.cjs.map +0 -1
  243. package/dist/guards.d.cts +0 -231
  244. package/dist/guards.d.cts.map +0 -1
  245. package/dist/guards.d.ts +0 -231
  246. package/dist/guards.d.ts.map +0 -1
  247. package/dist/guards.js +0 -277
  248. package/dist/guards.js.map +0 -1
  249. package/dist/index.cjs +0 -111
  250. package/dist/index.cjs.map +0 -1
  251. package/dist/index.d.cts +0 -448
  252. package/dist/index.d.cts.map +0 -1
  253. package/dist/index.d.ts +0 -448
  254. package/dist/index.d.ts.map +0 -1
  255. package/dist/index.js +0 -71
  256. package/dist/index.js.map +0 -1
  257. package/dist/internal-schema.cjs +0 -253
  258. package/dist/internal-schema.cjs.map +0 -1
  259. package/dist/internal-schema.d.cts +0 -8
  260. package/dist/internal-schema.d.cts.map +0 -1
  261. package/dist/internal-schema.d.ts +0 -8
  262. package/dist/internal-schema.d.ts.map +0 -1
  263. package/dist/internal-schema.js +0 -248
  264. package/dist/internal-schema.js.map +0 -1
  265. package/dist/metadata.cjs +0 -57
  266. package/dist/metadata.cjs.map +0 -1
  267. package/dist/metadata.d.cts +0 -27
  268. package/dist/metadata.d.cts.map +0 -1
  269. package/dist/metadata.d.ts +0 -27
  270. package/dist/metadata.d.ts.map +0 -1
  271. package/dist/metadata.js +0 -54
  272. package/dist/metadata.js.map +0 -1
  273. package/dist/schema.cjs +0 -1522
  274. package/dist/schema.cjs.map +0 -1
  275. package/dist/schema.d.cts +0 -1196
  276. package/dist/schema.d.cts.map +0 -1
  277. package/dist/schema.d.ts +0 -1196
  278. package/dist/schema.d.ts.map +0 -1
  279. package/dist/schema.js +0 -1516
  280. package/dist/schema.js.map +0 -1
  281. package/dist/snapshot/adapter.cjs +0 -31
  282. package/dist/snapshot/adapter.cjs.map +0 -1
  283. package/dist/snapshot/adapter.d.cts +0 -258
  284. package/dist/snapshot/adapter.d.cts.map +0 -1
  285. package/dist/snapshot/adapter.d.ts +0 -258
  286. package/dist/snapshot/adapter.d.ts.map +0 -1
  287. package/dist/snapshot/adapter.js +0 -27
  288. package/dist/snapshot/adapter.js.map +0 -1
  289. package/dist/snapshot/adapters/fallback.cjs +0 -453
  290. package/dist/snapshot/adapters/fallback.cjs.map +0 -1
  291. package/dist/snapshot/adapters/fallback.d.cts +0 -185
  292. package/dist/snapshot/adapters/fallback.d.cts.map +0 -1
  293. package/dist/snapshot/adapters/fallback.d.ts +0 -185
  294. package/dist/snapshot/adapters/fallback.d.ts.map +0 -1
  295. package/dist/snapshot/adapters/fallback.js +0 -446
  296. package/dist/snapshot/adapters/fallback.js.map +0 -1
  297. package/dist/snapshot/adapters/node-test.cjs +0 -301
  298. package/dist/snapshot/adapters/node-test.cjs.map +0 -1
  299. package/dist/snapshot/adapters/node-test.d.cts +0 -131
  300. package/dist/snapshot/adapters/node-test.d.cts.map +0 -1
  301. package/dist/snapshot/adapters/node-test.d.ts +0 -131
  302. package/dist/snapshot/adapters/node-test.d.ts.map +0 -1
  303. package/dist/snapshot/adapters/node-test.js +0 -297
  304. package/dist/snapshot/adapters/node-test.js.map +0 -1
  305. package/dist/snapshot/index.cjs +0 -61
  306. package/dist/snapshot/index.cjs.map +0 -1
  307. package/dist/snapshot/index.d.cts +0 -40
  308. package/dist/snapshot/index.d.cts.map +0 -1
  309. package/dist/snapshot/index.d.ts +0 -40
  310. package/dist/snapshot/index.d.ts.map +0 -1
  311. package/dist/snapshot/index.js +0 -44
  312. package/dist/snapshot/index.js.map +0 -1
  313. package/dist/snapshot/node-version.cjs +0 -49
  314. package/dist/snapshot/node-version.cjs.map +0 -1
  315. package/dist/snapshot/node-version.d.cts +0 -34
  316. package/dist/snapshot/node-version.d.cts.map +0 -1
  317. package/dist/snapshot/node-version.d.ts +0 -34
  318. package/dist/snapshot/node-version.d.ts.map +0 -1
  319. package/dist/snapshot/node-version.js +0 -44
  320. package/dist/snapshot/node-version.js.map +0 -1
  321. package/dist/snapshot/select-adapter.cjs +0 -170
  322. package/dist/snapshot/select-adapter.cjs.map +0 -1
  323. package/dist/snapshot/select-adapter.d.cts +0 -128
  324. package/dist/snapshot/select-adapter.d.cts.map +0 -1
  325. package/dist/snapshot/select-adapter.d.ts +0 -128
  326. package/dist/snapshot/select-adapter.d.ts.map +0 -1
  327. package/dist/snapshot/select-adapter.js +0 -164
  328. package/dist/snapshot/select-adapter.js.map +0 -1
  329. package/dist/snapshot/serializer.cjs +0 -246
  330. package/dist/snapshot/serializer.cjs.map +0 -1
  331. package/dist/snapshot/serializer.d.cts +0 -126
  332. package/dist/snapshot/serializer.d.cts.map +0 -1
  333. package/dist/snapshot/serializer.d.ts +0 -126
  334. package/dist/snapshot/serializer.d.ts.map +0 -1
  335. package/dist/snapshot/serializer.js +0 -238
  336. package/dist/snapshot/serializer.js.map +0 -1
  337. package/dist/standard-schema.cjs +0 -13
  338. package/dist/standard-schema.cjs.map +0 -1
  339. package/dist/standard-schema.d.cts +0 -192
  340. package/dist/standard-schema.d.cts.map +0 -1
  341. package/dist/standard-schema.d.ts +0 -192
  342. package/dist/standard-schema.d.ts.map +0 -1
  343. package/dist/standard-schema.js +0 -12
  344. package/dist/standard-schema.js.map +0 -1
  345. package/dist/types.cjs +0 -22
  346. package/dist/types.cjs.map +0 -1
  347. package/dist/types.d.cts +0 -905
  348. package/dist/types.d.cts.map +0 -1
  349. package/dist/types.d.ts +0 -905
  350. package/dist/types.d.ts.map +0 -1
  351. package/dist/types.js +0 -21
  352. package/dist/types.js.map +0 -1
  353. package/dist/use.cjs +0 -240
  354. package/dist/use.cjs.map +0 -1
  355. package/dist/use.d.cts +0 -8
  356. package/dist/use.d.cts.map +0 -1
  357. package/dist/use.d.ts +0 -8
  358. package/dist/use.d.ts.map +0 -1
  359. package/dist/use.js +0 -236
  360. package/dist/use.js.map +0 -1
  361. package/dist/util.cjs +0 -255
  362. package/dist/util.cjs.map +0 -1
  363. package/dist/util.d.cts +0 -141
  364. package/dist/util.d.cts.map +0 -1
  365. package/dist/util.d.ts +0 -141
  366. package/dist/util.d.ts.map +0 -1
  367. package/dist/util.js +0 -234
  368. package/dist/util.js.map +0 -1
  369. package/dist/value-to-schema.cjs +0 -537
  370. package/dist/value-to-schema.cjs.map +0 -1
  371. package/dist/value-to-schema.d.cts +0 -144
  372. package/dist/value-to-schema.d.cts.map +0 -1
  373. package/dist/value-to-schema.d.ts +0 -144
  374. package/dist/value-to-schema.d.ts.map +0 -1
  375. package/dist/value-to-schema.js +0 -533
  376. package/dist/value-to-schema.js.map +0 -1
@@ -1,62 +0,0 @@
1
- /**
2
- * Utility functions for assertion implementations
3
- *
4
- * @internal
5
- * @packageDocumentation
6
- */
7
- /**
8
- * Executes & traps a `Promise` rejected from an async function, capturing the
9
- * error.
10
- *
11
- * @function
12
- * @param fn The function to execute that may throw an error or return a
13
- * `Promise`
14
- * @returns Rejection or whatever was fulfilled
15
- */
16
- export const trapAsyncFnError = async (fn) => {
17
- try {
18
- const result = await fn();
19
- return { result };
20
- }
21
- catch (error) {
22
- return {
23
- error: error ?? new TypeError(`Function rejected with undefined: ${fn}`),
24
- };
25
- }
26
- };
27
- /**
28
- * Awaits & traps a Promise, capturing any rejection error.
29
- *
30
- * @function
31
- * @param promise The `Promise` to trap
32
- * @returns Result object
33
- */
34
- export const trapPromiseError = async (promise) => {
35
- try {
36
- const result = await promise;
37
- return { result };
38
- }
39
- catch (error) {
40
- return { error: error ?? new TypeError('Promise rejected with undefined') };
41
- }
42
- };
43
- /**
44
- * Executes & traps a synchronous function that may throw, capturing any thrown
45
- * error and discarding the result.
46
- *
47
- * @remarks
48
- * Avoids throwing `undefined` for some reason.
49
- * @function
50
- * @param fn Function to execute
51
- * @returns Result object
52
- */
53
- export const trapError = (fn) => {
54
- try {
55
- const result = fn();
56
- return { result };
57
- }
58
- catch (error) {
59
- return { error: error ?? new TypeError(`Function threw undefined: ${fn}`) };
60
- }
61
- };
62
- //# sourceMappingURL=assertion-util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertion-util.js","sourceRoot":"","sources":["../../../src/assertion/impl/assertion-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,EAAiB,EACI,EAAE;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,KAAK,EAAE,KAAK,IAAI,IAAI,SAAS,CAAC,qCAAqC,EAAE,EAAE,CAAC;SACzE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,OAA6B,EACR,EAAE;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;QAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI,SAAS,CAAC,iCAAiC,CAAC,EAAE,CAAC;IAC9E,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAiB,EAAc,EAAE;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,EAAE,CAAC;QACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,IAAI,SAAS,CAAC,6BAA6B,EAAE,EAAE,CAAC,EAAE,CAAC;IAC9E,CAAC;AACH,CAAC,CAAC"}
@@ -1,627 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsyncIterableAssertions = exports.asyncIterableRejectsWithErrorSatisfyingAssertion = exports.asyncIterableRejectsWithTypeAssertion = exports.asyncIterableRejectsAssertion = exports.asyncIterableCompletesAssertion = exports.asyncIterableYieldsSequenceSatisfyingAssertion = exports.asyncIterableYieldsExactlyAssertion = exports.asyncIterableEmptyAssertion = exports.asyncIterableYieldsAtMostAssertion = exports.asyncIterableYieldsAtLeastAssertion = exports.asyncIterableYieldsCountAssertion = exports.asyncIterableYieldsLastExhaustivelyAssertion = exports.asyncIterableYieldsLastAssertion = exports.asyncIterableYieldsFirstExhaustivelyAssertion = exports.asyncIterableYieldsFirstAssertion = exports.asyncIterableYieldsItemsExhaustivelyAssertion = exports.asyncIterableYieldsItemsSatisfyingAssertion = exports.asyncIterableYieldsExhaustivelyAssertion = exports.asyncIterableYieldsAssertion = void 0;
4
- // do not remove; otherwise zshy will not resolve the .d.ts file; it must be referenced directly
5
- // eslint-disable-next-line @typescript-eslint/triple-slash-reference
6
- /// <reference path="./shims.d.ts" />
7
- /**
8
- * Iterable assertions for asynchronous iterables and iterators.
9
- *
10
- * These assertions test async iterables using the **async iteration protocol**
11
- * (`Symbol.asyncIterator`), including async generators, Node.js Readable
12
- * streams, and Web ReadableStreams.
13
- *
14
- * @packageDocumentation
15
- * @groupDescription Async Iterable Assertions
16
- * Assertions for asynchronous iterables and iterators using the async iteration protocol.
17
- *
18
- * @showGroup
19
- */
20
- const node_util_1 = require("node:util");
21
- const zod_1 = require("zod");
22
- const schema_js_1 = require("../../schema.cjs");
23
- const value_to_schema_js_1 = require("../../value-to-schema.cjs");
24
- const create_js_1 = require("../create.cjs");
25
- const iteration_util_js_1 = require("./iteration-util.cjs");
26
- // =============================================================================
27
- // 'to yield' assertions - check if ANY item matches
28
- // =============================================================================
29
- /**
30
- * Asserts that an async iterable yields a value satisfying the expected shape.
31
- *
32
- * Uses partial/satisfy semantics (like `'to satisfy'`). The assertion passes if
33
- * ANY yielded value matches the expected shape.
34
- *
35
- * @example
36
- *
37
- * ```ts
38
- * await expectAsync(asyncGenerator(), 'to yield', 'value'); // passes
39
- * await expectAsync(nodeReadable, 'to emit', 'chunk'); // passes
40
- * await expectAsync(response.body, 'to yield value satisfying', {
41
- * data: 'test',
42
- * }); // Web Stream
43
- * ```
44
- *
45
- * @group Async Iterable Assertions
46
- * @bupkisAnchor async-iterable-to-yield-any
47
- * @bupkisAssertionCategory iterable
48
- */
49
- exports.asyncIterableYieldsAssertion = (0, create_js_1.createAsyncAssertion)([
50
- schema_js_1.AsyncIterableOrIteratorSchema,
51
- ['to yield', 'to emit', 'to yield value satisfying'],
52
- schema_js_1.UnknownSchema,
53
- ], async (subject, expected) => {
54
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
55
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
56
- let next = await iterator.next();
57
- while (!next.done) {
58
- if (schema.safeParse(next.value).success) {
59
- return; // success - found a matching value
60
- }
61
- next = await iterator.next();
62
- }
63
- return {
64
- message: `Expected async iterable to yield a value satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
65
- };
66
- });
67
- /**
68
- * Asserts that an async iterable yields a value exhaustively matching the
69
- * expected value.
70
- *
71
- * Uses deep equality semantics (like `'to equal'`). Extra properties on yielded
72
- * values cause failure.
73
- *
74
- * @example
75
- *
76
- * ```ts
77
- * await expectAsync(asyncGen(), 'to yield value exhaustively satisfying', {
78
- * a: 1,
79
- * }); // passes if { a: 1 } exactly is yielded
80
- * ```
81
- *
82
- * @group Async Iterable Assertions
83
- * @bupkisAnchor async-iterable-to-yield-value-exhaustively-satisfying-any
84
- * @bupkisAssertionCategory iterable
85
- */
86
- exports.asyncIterableYieldsExhaustivelyAssertion = (0, create_js_1.createAsyncAssertion)([
87
- schema_js_1.AsyncIterableOrIteratorSchema,
88
- 'to yield value exhaustively satisfying',
89
- schema_js_1.UnknownSchema,
90
- ], async (subject, expected) => {
91
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
92
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
93
- let next = await iterator.next();
94
- while (!next.done) {
95
- if (schema.safeParse(next.value).success) {
96
- return; // success - found an exact match
97
- }
98
- next = await iterator.next();
99
- }
100
- return {
101
- message: `Expected async iterable to yield a value exhaustively satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
102
- };
103
- });
104
- // =============================================================================
105
- // 'to yield items satisfying' - ALL items must match
106
- // =============================================================================
107
- /**
108
- * Asserts that ALL yielded values individually satisfy the expected shape.
109
- *
110
- * Uses partial/satisfy semantics. Every item yielded must match.
111
- *
112
- * @example
113
- *
114
- * ```ts
115
- * await expectAsync(asyncGen(), 'to yield items satisfying', {
116
- * type: 'data',
117
- * });
118
- * ```
119
- *
120
- * @group Async Iterable Assertions
121
- * @bupkisAnchor async-iterable-to-yield-items-satisfying-any
122
- * @bupkisAssertionCategory iterable
123
- */
124
- exports.asyncIterableYieldsItemsSatisfyingAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, 'to yield items satisfying', schema_js_1.UnknownSchema], async (subject, expected) => {
125
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
126
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
127
- let index = 0;
128
- let next = await iterator.next();
129
- while (!next.done) {
130
- const result = schema.safeParse(next.value);
131
- if (!result.success) {
132
- return {
133
- message: `Expected all items to satisfy ${(0, node_util_1.inspect)(expected)}, but item at index ${index} did not match: ${(0, node_util_1.inspect)(next.value)}`,
134
- };
135
- }
136
- index++;
137
- next = await iterator.next();
138
- }
139
- });
140
- /**
141
- * Asserts that ALL yielded values individually match with deep equality.
142
- *
143
- * Uses strict equality semantics. Every item yielded must exactly match.
144
- *
145
- * @example
146
- *
147
- * ```ts
148
- * await expectAsync(asyncGen(), 'to yield items exhaustively satisfying', {
149
- * a: 1,
150
- * });
151
- * ```
152
- *
153
- * @group Async Iterable Assertions
154
- * @bupkisAnchor async-iterable-to-yield-items-exhaustively-satisfying-any
155
- * @bupkisAssertionCategory iterable
156
- */
157
- exports.asyncIterableYieldsItemsExhaustivelyAssertion = (0, create_js_1.createAsyncAssertion)([
158
- schema_js_1.AsyncIterableOrIteratorSchema,
159
- 'to yield items exhaustively satisfying',
160
- schema_js_1.UnknownSchema,
161
- ], async (subject, expected) => {
162
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
163
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
164
- let index = 0;
165
- let next = await iterator.next();
166
- while (!next.done) {
167
- const result = schema.safeParse(next.value);
168
- if (!result.success) {
169
- return {
170
- message: `Expected all items to exhaustively satisfy ${(0, node_util_1.inspect)(expected)}, but item at index ${index} did not match: ${(0, node_util_1.inspect)(next.value)}`,
171
- };
172
- }
173
- index++;
174
- next = await iterator.next();
175
- }
176
- });
177
- // =============================================================================
178
- // First/Last assertions
179
- // =============================================================================
180
- /**
181
- * Asserts that the first yielded value satisfies the expected shape.
182
- *
183
- * Uses partial/satisfy semantics.
184
- *
185
- * @example
186
- *
187
- * ```ts
188
- * await expectAsync(asyncGen(), 'to yield first', { type: 'header' });
189
- * ```
190
- *
191
- * @group Async Iterable Assertions
192
- * @bupkisAnchor async-iterable-to-yield-first-any
193
- * @bupkisAssertionCategory iterable
194
- */
195
- exports.asyncIterableYieldsFirstAssertion = (0, create_js_1.createAsyncAssertion)([
196
- schema_js_1.AsyncIterableOrIteratorSchema,
197
- ['to yield first', 'to yield first satisfying'],
198
- schema_js_1.UnknownSchema,
199
- ], async (subject, expected) => {
200
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
201
- const result = await iterator.next();
202
- if (result.done) {
203
- return {
204
- message: 'Expected async iterable to yield at least one value, but it was empty',
205
- };
206
- }
207
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
208
- if (!schema.safeParse(result.value).success) {
209
- return {
210
- message: `Expected first yielded value to satisfy ${(0, node_util_1.inspect)(expected)}, but got ${(0, node_util_1.inspect)(result.value)}`,
211
- };
212
- }
213
- });
214
- /**
215
- * Asserts that the first yielded value exhaustively matches.
216
- *
217
- * Uses deep equality semantics.
218
- *
219
- * @example
220
- *
221
- * ```ts
222
- * await expectAsync(asyncGen(), 'to yield first exhaustively satisfying', {
223
- * a: 1,
224
- * });
225
- * ```
226
- *
227
- * @group Async Iterable Assertions
228
- * @bupkisAnchor async-iterable-to-yield-first-exhaustively-satisfying-any
229
- * @bupkisAssertionCategory iterable
230
- */
231
- exports.asyncIterableYieldsFirstExhaustivelyAssertion = (0, create_js_1.createAsyncAssertion)([
232
- schema_js_1.AsyncIterableOrIteratorSchema,
233
- 'to yield first exhaustively satisfying',
234
- schema_js_1.UnknownSchema,
235
- ], async (subject, expected) => {
236
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
237
- const result = await iterator.next();
238
- if (result.done) {
239
- return {
240
- message: 'Expected async iterable to yield at least one value, but it was empty',
241
- };
242
- }
243
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
244
- if (!schema.safeParse(result.value).success) {
245
- return {
246
- message: `Expected first yielded value to exhaustively satisfy ${(0, node_util_1.inspect)(expected)}, but got ${(0, node_util_1.inspect)(result.value)}`,
247
- };
248
- }
249
- });
250
- /**
251
- * Asserts that the last yielded value satisfies the expected shape.
252
- *
253
- * Uses partial/satisfy semantics. Note: fully consumes the async iterator.
254
- *
255
- * @example
256
- *
257
- * ```ts
258
- * await expectAsync(asyncGen(), 'to yield last', { type: 'footer' });
259
- * ```
260
- *
261
- * @group Async Iterable Assertions
262
- * @bupkisAnchor async-iterable-to-yield-last-any
263
- * @bupkisAssertionCategory iterable
264
- */
265
- exports.asyncIterableYieldsLastAssertion = (0, create_js_1.createAsyncAssertion)([
266
- schema_js_1.AsyncIterableOrIteratorSchema,
267
- ['to yield last', 'to yield last satisfying'],
268
- schema_js_1.UnknownSchema,
269
- ], async (subject, expected) => {
270
- const { hasValue, lastValue } = await (0, iteration_util_js_1.iterateFullyAsync)(subject);
271
- if (!hasValue) {
272
- return {
273
- message: 'Expected async iterable to yield at least one value, but it was empty',
274
- };
275
- }
276
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
277
- if (!schema.safeParse(lastValue).success) {
278
- return {
279
- message: `Expected last yielded value to satisfy ${(0, node_util_1.inspect)(expected)}, but got ${(0, node_util_1.inspect)(lastValue)}`,
280
- };
281
- }
282
- });
283
- /**
284
- * Asserts that the last yielded value exhaustively matches.
285
- *
286
- * Uses deep equality semantics. Note: fully consumes the async iterator.
287
- *
288
- * @example
289
- *
290
- * ```ts
291
- * await expectAsync(asyncGen(), 'to yield last exhaustively satisfying', {
292
- * b: 2,
293
- * });
294
- * ```
295
- *
296
- * @group Async Iterable Assertions
297
- * @bupkisAnchor async-iterable-to-yield-last-exhaustively-satisfying-any
298
- * @bupkisAssertionCategory iterable
299
- */
300
- exports.asyncIterableYieldsLastExhaustivelyAssertion = (0, create_js_1.createAsyncAssertion)([
301
- schema_js_1.AsyncIterableOrIteratorSchema,
302
- 'to yield last exhaustively satisfying',
303
- schema_js_1.UnknownSchema,
304
- ], async (subject, expected) => {
305
- const { hasValue, lastValue } = await (0, iteration_util_js_1.iterateFullyAsync)(subject);
306
- if (!hasValue) {
307
- return {
308
- message: 'Expected async iterable to yield at least one value, but it was empty',
309
- };
310
- }
311
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
312
- if (!schema.safeParse(lastValue).success) {
313
- return {
314
- message: `Expected last yielded value to exhaustively satisfy ${(0, node_util_1.inspect)(expected)}, but got ${(0, node_util_1.inspect)(lastValue)}`,
315
- };
316
- }
317
- });
318
- // =============================================================================
319
- // Cardinality assertions
320
- // =============================================================================
321
- /**
322
- * Asserts that an async iterable yields exactly the specified count of values.
323
- *
324
- * @example
325
- *
326
- * ```ts
327
- * await expectAsync(asyncGen(), 'to yield count', 5);
328
- * ```
329
- *
330
- * @group Async Iterable Assertions
331
- * @bupkisAnchor async-iterable-to-yield-count-number
332
- * @bupkisAssertionCategory iterable
333
- */
334
- exports.asyncIterableYieldsCountAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, 'to yield count', schema_js_1.NonNegativeIntegerSchema], async (subject, expectedCount) => {
335
- const actual = await (0, iteration_util_js_1.countAsync)(subject);
336
- if (actual !== expectedCount) {
337
- return {
338
- actual,
339
- expected: expectedCount,
340
- message: `Expected async iterable to yield ${expectedCount} value(s), but yielded ${actual}`,
341
- };
342
- }
343
- });
344
- /**
345
- * Asserts that an async iterable yields at least the specified count of values.
346
- *
347
- * @example
348
- *
349
- * ```ts
350
- * await expectAsync(asyncGen(), 'to yield at least', 3);
351
- * ```
352
- *
353
- * @group Async Iterable Assertions
354
- * @bupkisAnchor async-iterable-to-yield-at-least-number
355
- * @bupkisAssertionCategory iterable
356
- */
357
- exports.asyncIterableYieldsAtLeastAssertion = (0, create_js_1.createAsyncAssertion)([
358
- schema_js_1.AsyncIterableOrIteratorSchema,
359
- 'to yield at least',
360
- schema_js_1.NonNegativeIntegerSchema,
361
- ], async (subject, minCount) => {
362
- const actual = await (0, iteration_util_js_1.countAsync)(subject);
363
- if (actual < minCount) {
364
- return {
365
- actual,
366
- expected: `at least ${minCount}`,
367
- message: `Expected async iterable to yield at least ${minCount} value(s), but yielded ${actual}`,
368
- };
369
- }
370
- });
371
- /**
372
- * Asserts that an async iterable yields at most the specified count of values.
373
- *
374
- * @example
375
- *
376
- * ```ts
377
- * await expectAsync(asyncGen(), 'to yield at most', 10);
378
- * ```
379
- *
380
- * @group Async Iterable Assertions
381
- * @bupkisAnchor async-iterable-to-yield-at-most-number
382
- * @bupkisAssertionCategory iterable
383
- */
384
- exports.asyncIterableYieldsAtMostAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, 'to yield at most', schema_js_1.NonNegativeIntegerSchema], async (subject, maxCount) => {
385
- const actual = await (0, iteration_util_js_1.countAsync)(subject);
386
- if (actual > maxCount) {
387
- return {
388
- actual,
389
- expected: `at most ${maxCount}`,
390
- message: `Expected async iterable to yield at most ${maxCount} value(s), but yielded ${actual}`,
391
- };
392
- }
393
- });
394
- /**
395
- * Asserts that an async iterable yields nothing (is empty).
396
- *
397
- * @remarks
398
- * Use `'not to be an empty iterable'` or `'to yield at least', 1` for non-empty
399
- * assertions.
400
- * @example
401
- *
402
- * ```ts
403
- * await expectAsync(emptyAsyncGen(), 'to be an empty iterable');
404
- * ```
405
- *
406
- * @group Async Iterable Assertions
407
- * @bupkisAnchor async-iterable-to-be-an-empty-iterable
408
- * @bupkisAssertionCategory iterable
409
- */
410
- exports.asyncIterableEmptyAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, 'to be an empty iterable'], async (subject) => {
411
- const iterator = (0, iteration_util_js_1.toAsyncIterator)(subject);
412
- const result = await iterator.next();
413
- if (!result.done) {
414
- return {
415
- message: `Expected async iterable to be empty, but it yielded at least one value: ${(0, node_util_1.inspect)(result.value)}`,
416
- };
417
- }
418
- });
419
- // =============================================================================
420
- // Sequence/Collection assertions
421
- // =============================================================================
422
- /**
423
- * Asserts that an async iterable yields exactly the specified values in order.
424
- *
425
- * Uses deep equality semantics. The iterable must yield the exact same number
426
- * of values in the exact same order.
427
- *
428
- * @example
429
- *
430
- * ```ts
431
- * await expectAsync(asyncGen(), 'to yield exactly', [1, 2, 3]);
432
- * ```
433
- *
434
- * @group Async Iterable Assertions
435
- * @bupkisAnchor async-iterable-to-yield-exactly-array
436
- * @bupkisAssertionCategory iterable
437
- */
438
- exports.asyncIterableYieldsExactlyAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, 'to yield exactly', zod_1.z.array(schema_js_1.UnknownSchema)], async (subject, expected) => {
439
- const actual = await (0, iteration_util_js_1.collectAsync)(subject);
440
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
441
- return { schema, subject: actual };
442
- });
443
- /**
444
- * Asserts that an async iterable yields values that satisfy the expected
445
- * sequence.
446
- *
447
- * Uses satisfy/partial matching semantics on the collected array.
448
- *
449
- * @example
450
- *
451
- * ```ts
452
- * await expectAsync(asyncGen(), 'to yield sequence satisfying', [
453
- * { type: 'start' },
454
- * { type: 'end' },
455
- * ]);
456
- * ```
457
- *
458
- * @group Async Iterable Assertions
459
- * @bupkisAnchor async-iterable-to-yield-sequence-satisfying-array
460
- * @bupkisAssertionCategory iterable
461
- */
462
- exports.asyncIterableYieldsSequenceSatisfyingAssertion = (0, create_js_1.createAsyncAssertion)([
463
- schema_js_1.AsyncIterableOrIteratorSchema,
464
- ['to yield sequence satisfying', 'to yield array satisfying'],
465
- zod_1.z.array(schema_js_1.UnknownSchema),
466
- ], async (subject, expected) => {
467
- const actual = await (0, iteration_util_js_1.collectAsync)(subject);
468
- const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
469
- return { schema, subject: actual };
470
- });
471
- // =============================================================================
472
- // Completion/Error assertions (async-only)
473
- // =============================================================================
474
- /**
475
- * Asserts that an async iterable completes without throwing.
476
- *
477
- * Fully consumes the iterator and verifies no error is thrown during iteration.
478
- *
479
- * @example
480
- *
481
- * ```ts
482
- * await expectAsync(asyncGenerator(), 'to complete'); // passes if no error
483
- * await expectAsync(nodeReadable, 'to finish'); // passes if stream ends cleanly
484
- * ```
485
- *
486
- * @group Async Iterable Assertions
487
- * @bupkisAnchor async-iterable-to-complete
488
- * @bupkisAssertionCategory iterable
489
- */
490
- exports.asyncIterableCompletesAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, ['to complete', 'to finish']], async (subject) => {
491
- const { completed, error } = await (0, iteration_util_js_1.iterateFullyAsync)(subject);
492
- if (!completed) {
493
- return {
494
- message: `Expected async iterable to complete, but it rejected with: ${(0, node_util_1.inspect)(error)}`,
495
- };
496
- }
497
- });
498
- /**
499
- * Asserts that an async iterable rejects during iteration.
500
- *
501
- * @example
502
- *
503
- * ```ts
504
- * await expectAsync(failingStream, 'to reject'); // passes if iteration rejects
505
- * await expectAsync(failingStream, 'to be rejected'); // alias
506
- * ```
507
- *
508
- * @group Async Iterable Assertions
509
- * @bupkisAnchor async-iterable-to-reject
510
- * @bupkisAssertionCategory iterable
511
- */
512
- exports.asyncIterableRejectsAssertion = (0, create_js_1.createAsyncAssertion)([schema_js_1.AsyncIterableOrIteratorSchema, ['to reject', 'to be rejected']], async (subject) => {
513
- const { completed } = await (0, iteration_util_js_1.iterateFullyAsync)(subject);
514
- if (completed) {
515
- return {
516
- message: 'Expected async iterable to reject, but it completed successfully',
517
- };
518
- }
519
- });
520
- /**
521
- * Asserts that an async iterable rejects with a specific error type.
522
- *
523
- * @example
524
- *
525
- * ```ts
526
- * await expectAsync(failingStream, 'to reject with a', TypeError);
527
- * await expectAsync(failingStream, 'to reject with an', Error);
528
- * ```
529
- *
530
- * @group Async Iterable Assertions
531
- * @bupkisAnchor async-iterable-to-reject-with-a-constructor
532
- * @bupkisAssertionCategory iterable
533
- */
534
- exports.asyncIterableRejectsWithTypeAssertion = (0, create_js_1.createAsyncAssertion)([
535
- schema_js_1.AsyncIterableOrIteratorSchema,
536
- ['to reject with a', 'to reject with an'],
537
- schema_js_1.ConstructibleSchema,
538
- ], async (subject, expectedType) => {
539
- const { completed, error } = await (0, iteration_util_js_1.iterateFullyAsync)(subject);
540
- if (completed) {
541
- return {
542
- message: `Expected async iterable to reject with ${expectedType.name}, but it completed successfully`,
543
- };
544
- }
545
- if (!(error instanceof expectedType)) {
546
- return {
547
- message: `Expected async iterable to reject with ${expectedType.name}, but got ${(0, node_util_1.inspect)(error)}`,
548
- };
549
- }
550
- });
551
- /**
552
- * Asserts that an async iterable rejects with an error satisfying a shape.
553
- *
554
- * @example
555
- *
556
- * ```ts
557
- * await expectAsync(failingStream, 'to reject with error satisfying', {
558
- * message: 'Connection failed',
559
- * });
560
- * await expectAsync(
561
- * failingStream,
562
- * 'to be rejected with error satisfying',
563
- * {
564
- * code: 'ECONNREFUSED',
565
- * },
566
- * );
567
- * ```
568
- *
569
- * @group Async Iterable Assertions
570
- * @bupkisAnchor async-iterable-to-reject-with-error-satisfying-any
571
- * @bupkisAssertionCategory iterable
572
- */
573
- exports.asyncIterableRejectsWithErrorSatisfyingAssertion = (0, create_js_1.createAsyncAssertion)([
574
- schema_js_1.AsyncIterableOrIteratorSchema,
575
- [
576
- 'to reject with error satisfying',
577
- 'to be rejected with error satisfying',
578
- ],
579
- schema_js_1.UnknownSchema,
580
- ], async (subject, expectedShape) => {
581
- const { completed, error } = await (0, iteration_util_js_1.iterateFullyAsync)(subject);
582
- if (completed) {
583
- return {
584
- message: `Expected async iterable to reject with error satisfying ${(0, node_util_1.inspect)(expectedShape)}, but it completed successfully`,
585
- };
586
- }
587
- const schema = (0, value_to_schema_js_1.valueToSchema)(expectedShape, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
588
- if (!schema.safeParse(error).success) {
589
- return {
590
- message: `Expected async iterable to reject with error satisfying ${(0, node_util_1.inspect)(expectedShape)}, but got ${(0, node_util_1.inspect)(error)}`,
591
- };
592
- }
593
- });
594
- // =============================================================================
595
- // Export all async iterable assertions as a tuple
596
- // =============================================================================
597
- /**
598
- * All asynchronous iterable assertions bundled as a tuple for convenient
599
- * registration.
600
- */
601
- exports.AsyncIterableAssertions = [
602
- // 'to yield' - any item matches
603
- exports.asyncIterableYieldsAssertion,
604
- exports.asyncIterableYieldsExhaustivelyAssertion,
605
- // 'to yield items' - all items must match
606
- exports.asyncIterableYieldsItemsSatisfyingAssertion,
607
- exports.asyncIterableYieldsItemsExhaustivelyAssertion,
608
- // First/last assertions
609
- exports.asyncIterableYieldsFirstAssertion,
610
- exports.asyncIterableYieldsFirstExhaustivelyAssertion,
611
- exports.asyncIterableYieldsLastAssertion,
612
- exports.asyncIterableYieldsLastExhaustivelyAssertion,
613
- // Cardinality
614
- exports.asyncIterableYieldsCountAssertion,
615
- exports.asyncIterableYieldsAtLeastAssertion,
616
- exports.asyncIterableYieldsAtMostAssertion,
617
- exports.asyncIterableEmptyAssertion,
618
- // Sequence
619
- exports.asyncIterableYieldsExactlyAssertion,
620
- exports.asyncIterableYieldsSequenceSatisfyingAssertion,
621
- // Completion/error (async-only)
622
- exports.asyncIterableCompletesAssertion,
623
- exports.asyncIterableRejectsAssertion,
624
- exports.asyncIterableRejectsWithTypeAssertion,
625
- exports.asyncIterableRejectsWithErrorSatisfyingAssertion,
626
- ];
627
- //# sourceMappingURL=async-iterable.js.map