bupkis 0.18.2 → 1.0.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 (390) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +1 -1
  3. package/dist/assertion/assertion-async.cjs +268 -0
  4. package/dist/assertion/assertion-async.cjs.map +1 -0
  5. package/dist/assertion/assertion-async.d.cts +40 -0
  6. package/dist/assertion/assertion-async.d.cts.map +1 -0
  7. package/dist/assertion/assertion-async.d.ts +40 -0
  8. package/dist/assertion/assertion-async.d.ts.map +1 -0
  9. package/dist/assertion/assertion-async.js +259 -0
  10. package/dist/assertion/assertion-async.js.map +1 -0
  11. package/dist/assertion/assertion-standard-schema-async.cjs +132 -0
  12. package/dist/assertion/assertion-standard-schema-async.cjs.map +1 -0
  13. package/dist/assertion/assertion-standard-schema-async.d.cts +52 -0
  14. package/dist/assertion/assertion-standard-schema-async.d.cts.map +1 -0
  15. package/dist/assertion/assertion-standard-schema-async.d.ts +52 -0
  16. package/dist/assertion/assertion-standard-schema-async.d.ts.map +1 -0
  17. package/dist/assertion/assertion-standard-schema-async.js +128 -0
  18. package/dist/assertion/assertion-standard-schema-async.js.map +1 -0
  19. package/dist/assertion/assertion-standard-schema-sync.cjs +141 -0
  20. package/dist/assertion/assertion-standard-schema-sync.cjs.map +1 -0
  21. package/dist/assertion/assertion-standard-schema-sync.d.cts +52 -0
  22. package/dist/assertion/assertion-standard-schema-sync.d.cts.map +1 -0
  23. package/dist/assertion/assertion-standard-schema-sync.d.ts +52 -0
  24. package/dist/assertion/assertion-standard-schema-sync.d.ts.map +1 -0
  25. package/dist/assertion/assertion-standard-schema-sync.js +137 -0
  26. package/dist/assertion/assertion-standard-schema-sync.js.map +1 -0
  27. package/dist/assertion/assertion-sync.cjs +281 -0
  28. package/dist/assertion/assertion-sync.cjs.map +1 -0
  29. package/dist/assertion/assertion-sync.d.cts +60 -0
  30. package/dist/assertion/assertion-sync.d.cts.map +1 -0
  31. package/dist/assertion/assertion-sync.d.ts +60 -0
  32. package/dist/assertion/assertion-sync.d.ts.map +1 -0
  33. package/dist/assertion/assertion-sync.js +275 -0
  34. package/dist/assertion/assertion-sync.js.map +1 -0
  35. package/dist/assertion/assertion-types.cjs +20 -0
  36. package/dist/assertion/assertion-types.cjs.map +1 -0
  37. package/dist/assertion/assertion-types.d.cts +1086 -0
  38. package/dist/assertion/assertion-types.d.cts.map +1 -0
  39. package/dist/assertion/assertion-types.d.ts +1086 -0
  40. package/dist/assertion/assertion-types.d.ts.map +1 -0
  41. package/dist/assertion/assertion-types.js +19 -0
  42. package/dist/assertion/assertion-types.js.map +1 -0
  43. package/dist/assertion/assertion.cjs +382 -0
  44. package/dist/assertion/assertion.cjs.map +1 -0
  45. package/dist/assertion/assertion.d.cts +109 -0
  46. package/dist/assertion/assertion.d.cts.map +1 -0
  47. package/dist/assertion/assertion.d.ts +109 -0
  48. package/dist/assertion/assertion.d.ts.map +1 -0
  49. package/dist/assertion/assertion.js +375 -0
  50. package/dist/assertion/assertion.js.map +1 -0
  51. package/dist/assertion/create.cjs +148 -0
  52. package/dist/assertion/create.cjs.map +1 -0
  53. package/dist/assertion/create.d.cts +85 -0
  54. package/dist/assertion/create.d.cts.map +1 -0
  55. package/dist/assertion/create.d.ts +85 -0
  56. package/dist/assertion/create.d.ts.map +1 -0
  57. package/dist/assertion/create.js +143 -0
  58. package/dist/assertion/create.js.map +1 -0
  59. package/dist/assertion/format-assertion-failure.cjs +63 -0
  60. package/dist/assertion/format-assertion-failure.cjs.map +1 -0
  61. package/dist/assertion/format-assertion-failure.d.cts +21 -0
  62. package/dist/assertion/format-assertion-failure.d.cts.map +1 -0
  63. package/dist/assertion/format-assertion-failure.d.ts +21 -0
  64. package/dist/assertion/format-assertion-failure.d.ts.map +1 -0
  65. package/dist/assertion/format-assertion-failure.js +59 -0
  66. package/dist/assertion/format-assertion-failure.js.map +1 -0
  67. package/dist/assertion/impl/assertion-util.cjs +68 -0
  68. package/dist/assertion/impl/assertion-util.cjs.map +1 -0
  69. package/dist/assertion/impl/assertion-util.d.cts +36 -0
  70. package/dist/assertion/impl/assertion-util.d.cts.map +1 -0
  71. package/dist/assertion/impl/assertion-util.d.ts +36 -0
  72. package/dist/assertion/impl/assertion-util.d.ts.map +1 -0
  73. package/dist/assertion/impl/assertion-util.js +62 -0
  74. package/dist/assertion/impl/assertion-util.js.map +1 -0
  75. package/dist/assertion/impl/async-iterable.cjs +627 -0
  76. package/dist/assertion/impl/async-iterable.cjs.map +1 -0
  77. package/dist/assertion/impl/async-iterable.d.cts +406 -0
  78. package/dist/assertion/impl/async-iterable.d.cts.map +1 -0
  79. package/dist/assertion/impl/async-iterable.d.ts +406 -0
  80. package/dist/assertion/impl/async-iterable.d.ts.map +1 -0
  81. package/dist/assertion/impl/async-iterable.js +624 -0
  82. package/dist/assertion/impl/async-iterable.js.map +1 -0
  83. package/dist/assertion/impl/async-parametric.cjs +412 -0
  84. package/dist/assertion/impl/async-parametric.cjs.map +1 -0
  85. package/dist/assertion/impl/async-parametric.d.cts +278 -0
  86. package/dist/assertion/impl/async-parametric.d.cts.map +1 -0
  87. package/dist/assertion/impl/async-parametric.d.ts +278 -0
  88. package/dist/assertion/impl/async-parametric.d.ts.map +1 -0
  89. package/dist/assertion/impl/async-parametric.js +409 -0
  90. package/dist/assertion/impl/async-parametric.js.map +1 -0
  91. package/dist/assertion/impl/async.cjs +56 -0
  92. package/dist/assertion/impl/async.cjs.map +1 -0
  93. package/dist/assertion/impl/async.d.cts +179 -0
  94. package/dist/assertion/impl/async.d.cts.map +1 -0
  95. package/dist/assertion/impl/async.d.ts +179 -0
  96. package/dist/assertion/impl/async.d.ts.map +1 -0
  97. package/dist/assertion/impl/async.js +39 -0
  98. package/dist/assertion/impl/async.js.map +1 -0
  99. package/dist/assertion/impl/index.cjs +37 -0
  100. package/dist/assertion/impl/index.cjs.map +1 -0
  101. package/dist/assertion/impl/index.d.cts +21 -0
  102. package/dist/assertion/impl/index.d.cts.map +1 -0
  103. package/dist/assertion/impl/index.d.ts +21 -0
  104. package/dist/assertion/impl/index.d.ts.map +1 -0
  105. package/dist/assertion/impl/index.js +21 -0
  106. package/dist/assertion/impl/index.js.map +1 -0
  107. package/dist/assertion/impl/iteration-util.cjs +297 -0
  108. package/dist/assertion/impl/iteration-util.cjs.map +1 -0
  109. package/dist/assertion/impl/iteration-util.d.cts +12 -0
  110. package/dist/assertion/impl/iteration-util.d.cts.map +1 -0
  111. package/dist/assertion/impl/iteration-util.d.ts +12 -0
  112. package/dist/assertion/impl/iteration-util.d.ts.map +1 -0
  113. package/dist/assertion/impl/iteration-util.js +282 -0
  114. package/dist/assertion/impl/iteration-util.js.map +1 -0
  115. package/dist/assertion/impl/snapshot.cjs +276 -0
  116. package/dist/assertion/impl/snapshot.cjs.map +1 -0
  117. package/dist/assertion/impl/snapshot.d.cts +278 -0
  118. package/dist/assertion/impl/snapshot.d.cts.map +1 -0
  119. package/dist/assertion/impl/snapshot.d.ts +278 -0
  120. package/dist/assertion/impl/snapshot.d.ts.map +1 -0
  121. package/dist/assertion/impl/snapshot.js +273 -0
  122. package/dist/assertion/impl/snapshot.js.map +1 -0
  123. package/dist/assertion/impl/sync-basic.cjs +553 -0
  124. package/dist/assertion/impl/sync-basic.cjs.map +1 -0
  125. package/dist/assertion/impl/sync-basic.d.cts +528 -0
  126. package/dist/assertion/impl/sync-basic.d.cts.map +1 -0
  127. package/dist/assertion/impl/sync-basic.d.ts +528 -0
  128. package/dist/assertion/impl/sync-basic.d.ts.map +1 -0
  129. package/dist/assertion/impl/sync-basic.js +550 -0
  130. package/dist/assertion/impl/sync-basic.js.map +1 -0
  131. package/dist/assertion/impl/sync-collection.cjs +1424 -0
  132. package/dist/assertion/impl/sync-collection.cjs.map +1 -0
  133. package/dist/assertion/impl/sync-collection.d.cts +922 -0
  134. package/dist/assertion/impl/sync-collection.d.cts.map +1 -0
  135. package/dist/assertion/impl/sync-collection.d.ts +922 -0
  136. package/dist/assertion/impl/sync-collection.d.ts.map +1 -0
  137. package/dist/assertion/impl/sync-collection.js +1418 -0
  138. package/dist/assertion/impl/sync-collection.js.map +1 -0
  139. package/dist/assertion/impl/sync-date.cjs +341 -0
  140. package/dist/assertion/impl/sync-date.cjs.map +1 -0
  141. package/dist/assertion/impl/sync-date.d.cts +209 -0
  142. package/dist/assertion/impl/sync-date.d.cts.map +1 -0
  143. package/dist/assertion/impl/sync-date.d.ts +209 -0
  144. package/dist/assertion/impl/sync-date.d.ts.map +1 -0
  145. package/dist/assertion/impl/sync-date.js +338 -0
  146. package/dist/assertion/impl/sync-date.js.map +1 -0
  147. package/dist/assertion/impl/sync-esoteric.cjs +214 -0
  148. package/dist/assertion/impl/sync-esoteric.cjs.map +1 -0
  149. package/dist/assertion/impl/sync-esoteric.d.cts +191 -0
  150. package/dist/assertion/impl/sync-esoteric.d.cts.map +1 -0
  151. package/dist/assertion/impl/sync-esoteric.d.ts +191 -0
  152. package/dist/assertion/impl/sync-esoteric.d.ts.map +1 -0
  153. package/dist/assertion/impl/sync-esoteric.js +211 -0
  154. package/dist/assertion/impl/sync-esoteric.js.map +1 -0
  155. package/dist/assertion/impl/sync-iterable.cjs +512 -0
  156. package/dist/assertion/impl/sync-iterable.cjs.map +1 -0
  157. package/dist/assertion/impl/sync-iterable.d.cts +334 -0
  158. package/dist/assertion/impl/sync-iterable.d.cts.map +1 -0
  159. package/dist/assertion/impl/sync-iterable.d.ts +334 -0
  160. package/dist/assertion/impl/sync-iterable.d.ts.map +1 -0
  161. package/dist/assertion/impl/sync-iterable.js +509 -0
  162. package/dist/assertion/impl/sync-iterable.js.map +1 -0
  163. package/dist/assertion/impl/sync-parametric.cjs +805 -0
  164. package/dist/assertion/impl/sync-parametric.cjs.map +1 -0
  165. package/dist/assertion/impl/sync-parametric.d.cts +560 -0
  166. package/dist/assertion/impl/sync-parametric.d.cts.map +1 -0
  167. package/dist/assertion/impl/sync-parametric.d.ts +560 -0
  168. package/dist/assertion/impl/sync-parametric.d.ts.map +1 -0
  169. package/dist/assertion/impl/sync-parametric.js +802 -0
  170. package/dist/assertion/impl/sync-parametric.js.map +1 -0
  171. package/dist/assertion/impl/sync.cjs +229 -0
  172. package/dist/assertion/impl/sync.cjs.map +1 -0
  173. package/dist/assertion/impl/sync.d.cts +536 -0
  174. package/dist/assertion/impl/sync.d.cts.map +1 -0
  175. package/dist/assertion/impl/sync.d.ts +536 -0
  176. package/dist/assertion/impl/sync.d.ts.map +1 -0
  177. package/dist/assertion/impl/sync.js +212 -0
  178. package/dist/assertion/impl/sync.js.map +1 -0
  179. package/dist/assertion/index.cjs +38 -0
  180. package/dist/assertion/index.cjs.map +1 -0
  181. package/dist/assertion/index.d.cts +18 -0
  182. package/dist/assertion/index.d.cts.map +1 -0
  183. package/dist/assertion/index.d.ts +18 -0
  184. package/dist/assertion/index.d.ts.map +1 -0
  185. package/dist/assertion/index.js +17 -0
  186. package/dist/assertion/index.js.map +1 -0
  187. package/dist/assertion/slotify.cjs +165 -0
  188. package/dist/assertion/slotify.cjs.map +1 -0
  189. package/dist/assertion/slotify.d.cts +11 -0
  190. package/dist/assertion/slotify.d.cts.map +1 -0
  191. package/dist/assertion/slotify.d.ts +11 -0
  192. package/dist/assertion/slotify.d.ts.map +1 -0
  193. package/dist/assertion/slotify.js +161 -0
  194. package/dist/assertion/slotify.js.map +1 -0
  195. package/dist/bootstrap.cjs +43 -0
  196. package/dist/bootstrap.cjs.map +1 -0
  197. package/dist/bootstrap.d.cts +27 -0
  198. package/dist/bootstrap.d.cts.map +1 -0
  199. package/dist/bootstrap.d.ts +27 -0
  200. package/dist/bootstrap.d.ts.map +1 -0
  201. package/dist/bootstrap.js +40 -0
  202. package/dist/bootstrap.js.map +1 -0
  203. package/dist/constant.cjs +82 -0
  204. package/dist/constant.cjs.map +1 -0
  205. package/dist/constant.d.cts +69 -0
  206. package/dist/constant.d.cts.map +1 -0
  207. package/dist/constant.d.ts +69 -0
  208. package/dist/constant.d.ts.map +1 -0
  209. package/dist/constant.js +79 -0
  210. package/dist/constant.js.map +1 -0
  211. package/dist/diff.cjs +340 -0
  212. package/dist/diff.cjs.map +1 -0
  213. package/dist/diff.d.cts +51 -0
  214. package/dist/diff.d.cts.map +1 -0
  215. package/dist/diff.d.ts +51 -0
  216. package/dist/diff.d.ts.map +1 -0
  217. package/dist/diff.js +334 -0
  218. package/dist/diff.js.map +1 -0
  219. package/dist/error.cjs +194 -0
  220. package/dist/error.cjs.map +1 -0
  221. package/dist/error.d.cts +212 -0
  222. package/dist/error.d.cts.map +1 -0
  223. package/dist/error.d.ts +212 -0
  224. package/dist/error.d.ts.map +1 -0
  225. package/dist/error.js +181 -0
  226. package/dist/error.js.map +1 -0
  227. package/dist/expect.cjs +587 -0
  228. package/dist/expect.cjs.map +1 -0
  229. package/dist/expect.d.cts +138 -0
  230. package/dist/expect.d.cts.map +1 -0
  231. package/dist/expect.d.ts +138 -0
  232. package/dist/expect.d.ts.map +1 -0
  233. package/dist/expect.js +582 -0
  234. package/dist/expect.js.map +1 -0
  235. package/dist/guards.cjs +291 -0
  236. package/dist/guards.cjs.map +1 -0
  237. package/dist/guards.d.cts +225 -0
  238. package/dist/guards.d.cts.map +1 -0
  239. package/dist/guards.d.ts +225 -0
  240. package/dist/guards.d.ts.map +1 -0
  241. package/dist/guards.js +273 -0
  242. package/dist/guards.js.map +1 -0
  243. package/dist/index.cjs +111 -0
  244. package/dist/index.cjs.map +1 -0
  245. package/dist/index.d.cts +460 -0
  246. package/dist/index.d.cts.map +1 -0
  247. package/dist/index.d.ts +460 -0
  248. package/dist/index.d.ts.map +1 -0
  249. package/dist/index.js +71 -0
  250. package/dist/index.js.map +1 -0
  251. package/dist/internal-schema.cjs +234 -0
  252. package/dist/internal-schema.cjs.map +1 -0
  253. package/dist/internal-schema.d.cts +8 -0
  254. package/dist/internal-schema.d.cts.map +1 -0
  255. package/dist/internal-schema.d.ts +8 -0
  256. package/dist/internal-schema.d.ts.map +1 -0
  257. package/dist/internal-schema.js +229 -0
  258. package/dist/internal-schema.js.map +1 -0
  259. package/dist/metadata.cjs +57 -0
  260. package/dist/metadata.cjs.map +1 -0
  261. package/dist/metadata.d.cts +27 -0
  262. package/dist/metadata.d.cts.map +1 -0
  263. package/dist/metadata.d.ts +27 -0
  264. package/dist/metadata.d.ts.map +1 -0
  265. package/dist/metadata.js +54 -0
  266. package/dist/metadata.js.map +1 -0
  267. package/dist/schema.cjs +1522 -0
  268. package/dist/schema.cjs.map +1 -0
  269. package/dist/schema.d.cts +1196 -0
  270. package/dist/schema.d.cts.map +1 -0
  271. package/dist/schema.d.ts +1196 -0
  272. package/dist/schema.d.ts.map +1 -0
  273. package/dist/schema.js +1516 -0
  274. package/dist/schema.js.map +1 -0
  275. package/dist/snapshot/adapter.cjs +29 -0
  276. package/dist/snapshot/adapter.cjs.map +1 -0
  277. package/dist/snapshot/adapter.d.cts +258 -0
  278. package/dist/snapshot/adapter.d.cts.map +1 -0
  279. package/dist/snapshot/adapter.d.ts +258 -0
  280. package/dist/snapshot/adapter.d.ts.map +1 -0
  281. package/dist/snapshot/adapter.js +25 -0
  282. package/dist/snapshot/adapter.js.map +1 -0
  283. package/dist/snapshot/adapters/fallback.cjs +452 -0
  284. package/dist/snapshot/adapters/fallback.cjs.map +1 -0
  285. package/dist/snapshot/adapters/fallback.d.cts +185 -0
  286. package/dist/snapshot/adapters/fallback.d.cts.map +1 -0
  287. package/dist/snapshot/adapters/fallback.d.ts +185 -0
  288. package/dist/snapshot/adapters/fallback.d.ts.map +1 -0
  289. package/dist/snapshot/adapters/fallback.js +445 -0
  290. package/dist/snapshot/adapters/fallback.js.map +1 -0
  291. package/dist/snapshot/adapters/node-test.cjs +297 -0
  292. package/dist/snapshot/adapters/node-test.cjs.map +1 -0
  293. package/dist/snapshot/adapters/node-test.d.cts +131 -0
  294. package/dist/snapshot/adapters/node-test.d.cts.map +1 -0
  295. package/dist/snapshot/adapters/node-test.d.ts +131 -0
  296. package/dist/snapshot/adapters/node-test.d.ts.map +1 -0
  297. package/dist/snapshot/adapters/node-test.js +293 -0
  298. package/dist/snapshot/adapters/node-test.js.map +1 -0
  299. package/dist/snapshot/index.cjs +61 -0
  300. package/dist/snapshot/index.cjs.map +1 -0
  301. package/dist/snapshot/index.d.cts +40 -0
  302. package/dist/snapshot/index.d.cts.map +1 -0
  303. package/dist/snapshot/index.d.ts +40 -0
  304. package/dist/snapshot/index.d.ts.map +1 -0
  305. package/dist/snapshot/index.js +44 -0
  306. package/dist/snapshot/index.js.map +1 -0
  307. package/dist/snapshot/node-version.cjs +49 -0
  308. package/dist/snapshot/node-version.cjs.map +1 -0
  309. package/dist/snapshot/node-version.d.cts +34 -0
  310. package/dist/snapshot/node-version.d.cts.map +1 -0
  311. package/dist/snapshot/node-version.d.ts +34 -0
  312. package/dist/snapshot/node-version.d.ts.map +1 -0
  313. package/dist/snapshot/node-version.js +44 -0
  314. package/dist/snapshot/node-version.js.map +1 -0
  315. package/dist/snapshot/select-adapter.cjs +170 -0
  316. package/dist/snapshot/select-adapter.cjs.map +1 -0
  317. package/dist/snapshot/select-adapter.d.cts +128 -0
  318. package/dist/snapshot/select-adapter.d.cts.map +1 -0
  319. package/dist/snapshot/select-adapter.d.ts +128 -0
  320. package/dist/snapshot/select-adapter.d.ts.map +1 -0
  321. package/dist/snapshot/select-adapter.js +164 -0
  322. package/dist/snapshot/select-adapter.js.map +1 -0
  323. package/dist/snapshot/serializer.cjs +245 -0
  324. package/dist/snapshot/serializer.cjs.map +1 -0
  325. package/dist/snapshot/serializer.d.cts +126 -0
  326. package/dist/snapshot/serializer.d.cts.map +1 -0
  327. package/dist/snapshot/serializer.d.ts +126 -0
  328. package/dist/snapshot/serializer.d.ts.map +1 -0
  329. package/dist/snapshot/serializer.js +237 -0
  330. package/dist/snapshot/serializer.js.map +1 -0
  331. package/dist/standard-schema.cjs +13 -0
  332. package/dist/standard-schema.cjs.map +1 -0
  333. package/dist/standard-schema.d.cts +192 -0
  334. package/dist/standard-schema.d.cts.map +1 -0
  335. package/dist/standard-schema.d.ts +192 -0
  336. package/dist/standard-schema.d.ts.map +1 -0
  337. package/dist/standard-schema.js +12 -0
  338. package/dist/standard-schema.js.map +1 -0
  339. package/dist/types.cjs +22 -0
  340. package/dist/types.cjs.map +1 -0
  341. package/dist/types.d.cts +756 -0
  342. package/dist/types.d.cts.map +1 -0
  343. package/dist/types.d.ts +756 -0
  344. package/dist/types.d.ts.map +1 -0
  345. package/dist/types.js +21 -0
  346. package/dist/types.js.map +1 -0
  347. package/dist/use.cjs +240 -0
  348. package/dist/use.cjs.map +1 -0
  349. package/dist/use.d.cts +8 -0
  350. package/dist/use.d.cts.map +1 -0
  351. package/dist/use.d.ts +8 -0
  352. package/dist/use.d.ts.map +1 -0
  353. package/dist/use.js +236 -0
  354. package/dist/use.js.map +1 -0
  355. package/dist/util.cjs +255 -0
  356. package/dist/util.cjs.map +1 -0
  357. package/dist/util.d.cts +141 -0
  358. package/dist/util.d.cts.map +1 -0
  359. package/dist/util.d.ts +141 -0
  360. package/dist/util.d.ts.map +1 -0
  361. package/dist/util.js +234 -0
  362. package/dist/util.js.map +1 -0
  363. package/dist/value-to-schema.cjs +537 -0
  364. package/dist/value-to-schema.cjs.map +1 -0
  365. package/dist/value-to-schema.d.cts +144 -0
  366. package/dist/value-to-schema.d.cts.map +1 -0
  367. package/dist/value-to-schema.d.ts +144 -0
  368. package/dist/value-to-schema.d.ts.map +1 -0
  369. package/dist/value-to-schema.js +533 -0
  370. package/dist/value-to-schema.js.map +1 -0
  371. package/package.json +24 -21
  372. package/src/assertion/assertion-sync.ts +1 -1
  373. package/src/assertion/assertion-types.ts +4 -8
  374. package/src/assertion/assertion.ts +12 -7
  375. package/src/assertion/format-assertion-failure.ts +2 -0
  376. package/src/assertion/impl/assertion-util.ts +1 -2
  377. package/src/assertion/impl/iteration-util.ts +3 -5
  378. package/src/assertion/impl/sync-collection.ts +633 -7
  379. package/src/assertion/impl/sync.ts +27 -0
  380. package/src/error.ts +13 -22
  381. package/src/expect.ts +1 -1
  382. package/src/guards.ts +8 -14
  383. package/src/internal-schema.ts +4 -8
  384. package/src/metadata.ts +1 -2
  385. package/src/snapshot/adapter.ts +2 -3
  386. package/src/snapshot/adapters/fallback.ts +2 -3
  387. package/src/snapshot/adapters/node-test.ts +14 -20
  388. package/src/snapshot/select-adapter.ts +3 -3
  389. package/src/snapshot/serializer.ts +2 -3
  390. package/src/types.ts +2 -162
@@ -0,0 +1,1424 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.objectHasKeyMatchingAssertion = exports.objectKeysMatchAssertion = exports.objectHasKeySatisfyingAssertion = exports.objectKeysSatisfyAssertion = exports.mapHasKeyExhaustivelySatisfyingAssertion = exports.mapHasKeySatisfyingAssertion = exports.mapKeysExhaustivelySatisfyAssertion = exports.mapKeysSatisfyAssertion = exports.collectionHasValueExhaustivelySatisfyingAssertion = exports.collectionHasValueSatisfyingAssertion = exports.collectionValuesExhaustivelySatisfyAssertion = exports.collectionValuesSatisfyAssertion = exports.collectionSizeBetweenAssertion = exports.collectionSizeLessThanAssertion = exports.collectionSizeGreaterThanAssertion = exports.mapEqualityAssertion = exports.mapEntryAssertion = exports.mapValueAssertion = exports.mapKeyAssertion = exports.setSymmetricDifferenceEqualityAssertion = exports.setDifferenceEqualityAssertion = exports.setIntersectionEqualityAssertion = exports.setUnionEqualityAssertion = exports.setDisjointAssertion = exports.setIntersectionAssertion = exports.setSupersetAssertion = exports.setSubsetAssertion = exports.setEqualityAssertion = exports.objectSizeAssertion = exports.objectExactKeyAssertion = exports.objectKeyAssertion = exports.objectKeysAssertion = exports.nonEmptyArrayAssertion = exports.arraySizeAssertion = exports.arrayItemSatisfiesAssertion = exports.arrayContainsAssertion = exports.emptySetAssertion = exports.setSizeAssertion = exports.setContainsAssertion = exports.emptyMapAssertion = exports.mapSizeAssertion = exports.mapContainsAssertion = void 0;
7
+ // do not remove; otherwise zshy will not resolve the .d.ts file; it must be referenced directly
8
+ // eslint-disable-next-line @typescript-eslint/triple-slash-reference
9
+ /// <reference path="./shims.d.ts" />
10
+ /**
11
+ * Collection-based assertions for arrays, objects, Maps, and Sets.
12
+ *
13
+ * These assertions handle operations like containment, size checking, and
14
+ * set-theoretic operations for various collection types including native
15
+ * JavaScript collections and WeakMap/WeakSet.
16
+ *
17
+ * @packageDocumentation
18
+ * @groupDescription Collection Assertions
19
+ * Assertions for arrays, objects, Maps, Sets, and collection operations.
20
+ *
21
+ * @showGroup
22
+ */
23
+ const node_util_1 = require("node:util");
24
+ const set_prototype_difference_1 = __importDefault(require("set.prototype.difference"));
25
+ const set_prototype_intersection_1 = __importDefault(require("set.prototype.intersection"));
26
+ const set_prototype_isdisjointfrom_1 = __importDefault(require("set.prototype.isdisjointfrom"));
27
+ const set_prototype_issubsetof_1 = __importDefault(require("set.prototype.issubsetof"));
28
+ const set_prototype_issupersetof_1 = __importDefault(require("set.prototype.issupersetof"));
29
+ const set_prototype_symmetricdifference_1 = __importDefault(require("set.prototype.symmetricdifference"));
30
+ const set_prototype_union_1 = __importDefault(require("set.prototype.union"));
31
+ const zod_1 = require("zod");
32
+ const guards_js_1 = require("../../guards.cjs");
33
+ const schema_js_1 = require("../../schema.cjs");
34
+ const util_js_1 = require("../../util.cjs");
35
+ const value_to_schema_js_1 = require("../../value-to-schema.cjs");
36
+ const create_js_1 = require("../create.cjs");
37
+ const { hasOwn, keys } = Object;
38
+ /**
39
+ * Asserts that a Map or WeakMap contains a specific key. For WeakMap, the key
40
+ * must be an object.
41
+ *
42
+ * @example
43
+ *
44
+ * ```ts
45
+ * const map = new Map([['key', 'value']]);
46
+ * expect(map, 'to contain', 'key'); // passes
47
+ *
48
+ * const obj = {};
49
+ * const weakMap = new WeakMap([[obj, 'value']]);
50
+ * expect(weakMap, 'to contain', obj); // passes
51
+ * expect(weakMap, 'to contain', 'string'); // fails (not an object)
52
+ * ```
53
+ *
54
+ * @group Collection Assertions
55
+ * @bupkisAnchor map-to-contain-any
56
+ * @bupkisAssertionCategory collections
57
+ */
58
+ exports.mapContainsAssertion = (0, create_js_1.createAssertion)([schema_js_1.AnyMapSchema, ['to contain', 'to include'], schema_js_1.UnknownSchema], (subject, key) => {
59
+ // WeakMap.has only works with object or symbol keys
60
+ let hasKey;
61
+ if (subject instanceof WeakMap) {
62
+ if (!(0, guards_js_1.isWeakKey)(key)) {
63
+ return {
64
+ message: `WeakMap keys must be objects or symbols, got ${typeof key}`,
65
+ };
66
+ }
67
+ hasKey = subject.has(key);
68
+ }
69
+ else {
70
+ hasKey = subject.has(key);
71
+ }
72
+ if (!hasKey) {
73
+ return {
74
+ message: `Expected ${subject.constructor.name} to contain key`,
75
+ };
76
+ }
77
+ });
78
+ /**
79
+ * Asserts that a Map has a specific size.
80
+ *
81
+ * @example
82
+ *
83
+ * ```ts
84
+ * const map = new Map([
85
+ * ['a', 1],
86
+ * ['b', 2],
87
+ * ]);
88
+ * expect(map, 'to have size', 2); // passes
89
+ * expect(map, 'to have size', 3); // fails
90
+ * ```
91
+ *
92
+ * @group Collection Assertions
93
+ * @bupkisAnchor map-to-have-size-nonnegative-integer
94
+ * @bupkisAssertionCategory collections
95
+ */
96
+ exports.mapSizeAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to have size', schema_js_1.NonNegativeIntegerSchema], (_subject, expectedSize) => zod_1.z.map(zod_1.z.unknown(), zod_1.z.unknown()).refine((map) => map.size === expectedSize, {
97
+ error: `Expected Map to have size ${expectedSize}`,
98
+ }));
99
+ /**
100
+ * Asserts that a Map is empty.
101
+ *
102
+ * @example
103
+ *
104
+ * ```ts
105
+ * expect(new Map(), 'to be empty'); // passes
106
+ * expect(new Map([['key', 'value']]), 'to be empty'); // fails
107
+ * ```
108
+ *
109
+ * @group Collection Assertions
110
+ * @bupkisAnchor map-to-be-empty
111
+ * @bupkisAssertionCategory collections
112
+ */
113
+ exports.emptyMapAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to be empty'], schema_js_1.MapSchema.refine((map) => map.size === 0, {
114
+ error: 'Expected Map to be empty',
115
+ }));
116
+ /**
117
+ * Asserts that a Set or WeakSet contains a specific value. For WeakSet, the
118
+ * value must be an object.
119
+ *
120
+ * @example
121
+ *
122
+ * ```ts
123
+ * const set = new Set(['a', 'b']);
124
+ * expect(set, 'to contain', 'a'); // passes
125
+ *
126
+ * const obj = {};
127
+ * const weakSet = new WeakSet([obj]);
128
+ * expect(weakSet, 'to contain', obj); // passes
129
+ * expect(weakSet, 'to contain', 'string'); // fails (not an object)
130
+ * ```
131
+ *
132
+ * @group Collection Assertions
133
+ * @bupkisAnchor set-to-contain-any
134
+ * @bupkisAssertionCategory collections
135
+ */
136
+ exports.setContainsAssertion = (0, create_js_1.createAssertion)([schema_js_1.AnySetSchema, ['to contain', 'to include'], schema_js_1.UnknownSchema], (subject, value) => {
137
+ // WeakSet.has only works with object or symbol values
138
+ if (subject instanceof WeakSet && !(0, guards_js_1.isWeakKey)(value)) {
139
+ return {
140
+ message: `WeakSet values must be objects or symbols, got ${typeof value}`,
141
+ };
142
+ }
143
+ // At this point, if it's a WeakSet, we know value is a WeakKey
144
+ const hasValue = subject instanceof WeakSet
145
+ ? subject.has(value)
146
+ : subject.has(value);
147
+ if (!hasValue) {
148
+ return {
149
+ message: `Expected ${subject.constructor.name} to contain value`,
150
+ };
151
+ }
152
+ });
153
+ /**
154
+ * Asserts that a Set has a specific size.
155
+ *
156
+ * @example
157
+ *
158
+ * ```ts
159
+ * const set = new Set(['a', 'b']);
160
+ * expect(set, 'to have size', 2); // passes
161
+ * expect(set, 'to have size', 3); // fails
162
+ * ```
163
+ *
164
+ * @group Collection Assertions
165
+ * @bupkisAnchor set-to-have-size-nonnegative-integer
166
+ * @bupkisAssertionCategory collections
167
+ */
168
+ exports.setSizeAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to have size', schema_js_1.NonNegativeIntegerSchema], (_subject, expectedSize) => zod_1.z
169
+ .set(zod_1.z.unknown())
170
+ .min(expectedSize, { error: `Expected Set to have size ${expectedSize}` })
171
+ .max(expectedSize, {
172
+ error: `Expected Set to have size ${expectedSize}`,
173
+ }));
174
+ /**
175
+ * Asserts that a Set is empty.
176
+ *
177
+ * @example
178
+ *
179
+ * ```ts
180
+ * expect(new Set(), 'to be empty'); // passes
181
+ * expect(new Set(['value']), 'to be empty'); // fails
182
+ * ```
183
+ *
184
+ * @group Collection Assertions
185
+ * @bupkisAnchor set-to-be-empty
186
+ * @bupkisAssertionCategory collections
187
+ */
188
+ exports.emptySetAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to be empty'], schema_js_1.SetSchema.refine(({ size }) => size === 0, {
189
+ error: 'Expected Set to be empty',
190
+ }));
191
+ /**
192
+ * Asserts that an array contains a specific value.
193
+ *
194
+ * @example
195
+ *
196
+ * ```ts
197
+ * expect([1, 2, 3], 'to contain', 2); // passes
198
+ * expect([1, 2, 3], 'to contain', 4); // fails
199
+ * ```
200
+ *
201
+ * @group Collection Assertions
202
+ * @bupkisAnchor array-to-contain-any
203
+ * @bupkisAssertionCategory collections
204
+ */
205
+ exports.arrayContainsAssertion = (0, create_js_1.createAssertion)([schema_js_1.UnknownArraySchema, ['to contain', 'to include'], schema_js_1.UnknownSchema], (subject, value) => {
206
+ if (!subject.includes(value)) {
207
+ return {
208
+ message: `Expected array to contain value`,
209
+ };
210
+ }
211
+ });
212
+ /**
213
+ * Asserts that an array contains an item that satisfies a given shape or
214
+ * pattern. Uses partial matching semantics - the item only needs to match the
215
+ * specified properties.
216
+ *
217
+ * @example
218
+ *
219
+ * ```ts
220
+ * expect([{ a: 1, b: 2 }, { c: 3 }], 'to have item satisfying', { a: 1 }); // passes
221
+ * expect([{ a: 1 }, { b: 2 }], 'to have an item satisfying', { c: 3 }); // fails
222
+ * expect([1, 2, 3], 'to contain item satisfying', 2); // passes (exact match)
223
+ * ```
224
+ *
225
+ * @group Collection Assertions
226
+ * @bupkisAnchor array-to-have-item-satisfying
227
+ * @bupkisAssertionCategory collections
228
+ */
229
+ exports.arrayItemSatisfiesAssertion = (0, create_js_1.createAssertion)([
230
+ schema_js_1.UnknownArraySchema,
231
+ [
232
+ 'to have item satisfying',
233
+ 'to have an item satisfying',
234
+ 'to contain item satisfying',
235
+ ],
236
+ schema_js_1.UnknownSchema,
237
+ ], (subject, shape) => {
238
+ const schema = (0, value_to_schema_js_1.valueToSchema)(shape, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
239
+ for (const item of subject) {
240
+ const result = schema.safeParse(item);
241
+ if (result.success) {
242
+ return;
243
+ }
244
+ }
245
+ return {
246
+ message: `Expected array to contain an item satisfying the given shape`,
247
+ };
248
+ });
249
+ /**
250
+ * Asserts that an array has a specific size.
251
+ *
252
+ * @example
253
+ *
254
+ * ```ts
255
+ * expect([1, 2, 3], 'to have length', 3); // passes
256
+ * expect([1, 2, 3], 'to have size', 2); // fails
257
+ * ```
258
+ *
259
+ * @group Collection Assertions
260
+ * @bupkisAnchor array-to-have-size-nonnegative-integer
261
+ * @bupkisAssertionCategory collections
262
+ */
263
+ exports.arraySizeAssertion = (0, create_js_1.createAssertion)([
264
+ schema_js_1.UnknownArraySchema,
265
+ ['to have length', 'to have size'],
266
+ schema_js_1.NonNegativeIntegerSchema,
267
+ ], (_subject, expectedSize) => schema_js_1.UnknownArraySchema.min(expectedSize, {
268
+ error: `Expected array to have size ${expectedSize}}`,
269
+ }).max(expectedSize, {
270
+ error: `Expected array to have size ${expectedSize}}`,
271
+ }));
272
+ /**
273
+ * Asserts that an array is non-empty.
274
+ *
275
+ * @example
276
+ *
277
+ * ```ts
278
+ * expect([1, 2, 3], 'to be non-empty'); // passes
279
+ * expect([], 'to be non-empty'); // fails
280
+ * ```
281
+ *
282
+ * @group Collection Assertions
283
+ * @bupkisAnchor array-not-to-be-empty
284
+ * @bupkisAssertionCategory collections
285
+ */
286
+ exports.nonEmptyArrayAssertion = (0, create_js_1.createAssertion)([schema_js_1.UnknownArraySchema, 'to be non-empty'], schema_js_1.UnknownArraySchema.min(1, { error: 'Expected array to be non-empty' }));
287
+ /**
288
+ * Asserts that an object has specific keys/properties.
289
+ *
290
+ * @example
291
+ *
292
+ * ```ts
293
+ * expect({ a: 1, b: 2 }, 'to have keys', 'a', 'b'); // passes
294
+ * expect({ a: 1 }, 'to have keys', 'a', 'b'); // fails
295
+ * ```
296
+ *
297
+ * @group Collection Assertions
298
+ * @bupkisAnchor object-to-have-keys-array
299
+ * @bupkisAssertionCategory object
300
+ */
301
+ // TODO support keypaths, maybe.
302
+ // TODO support `undefined` values (will require moving away from Zod schema)
303
+ exports.objectKeysAssertion = (0, create_js_1.createAssertion)([
304
+ schema_js_1.NonCollectionObjectSchema,
305
+ [
306
+ 'to have keys',
307
+ 'to have properties',
308
+ 'to have props',
309
+ 'to contain keys',
310
+ 'to contain properties',
311
+ 'to contain props',
312
+ 'to include keys',
313
+ 'to include properties',
314
+ 'to include props',
315
+ ],
316
+ zod_1.z.array(schema_js_1.PropertyKeySchema).nonempty(),
317
+ ], (_subject, keys) => schema_js_1.NonCollectionObjectSchema.superRefine((subject, ctx) => {
318
+ // iterate thru keys and add an issue for each missing
319
+ for (const k of keys) {
320
+ if (!hasOwn(subject, k)) {
321
+ ctx.addIssue({
322
+ code: 'custom',
323
+ input: subject,
324
+ message: `Expected object to contain key "${String(k)}"`,
325
+ params: { bupkisType: 'missing_key' },
326
+ });
327
+ }
328
+ }
329
+ }));
330
+ /**
331
+ * Asserts that an object has a property at the specified keypath using dot or
332
+ * bracket notation. Uses the `has()` function to traverse nested properties and
333
+ * supports complex keypaths like 'foo.bar[0]["baz"]'.
334
+ *
335
+ * This assertion supports:
336
+ *
337
+ * - Dot notation: 'prop.nested'
338
+ * - Bracket notation with numbers: 'arr[0]'
339
+ * - Bracket notation with quoted strings: 'obj["key"]' or "obj['key']"
340
+ * - Mixed notation: 'data.items[1].name'
341
+ *
342
+ * @example
343
+ *
344
+ * ```ts
345
+ * const obj = {
346
+ * foo: { bar: [{ baz: 'value' }] },
347
+ * 'kebab-case': 'works',
348
+ * };
349
+ *
350
+ * expect(obj, 'to have key', 'foo.bar'); // passes
351
+ * expect(obj, 'to have property', 'foo.bar[0].baz'); // passes
352
+ * expect(obj, 'to have prop', 'foo["kebab-case"]'); // passes
353
+ * expect(obj, 'to have key', 'nonexistent.path'); // fails
354
+ * ```
355
+ *
356
+ * @group Collection Assertions
357
+ * @bupkisAnchor object-to-have-key-string-number-symbol
358
+ * @bupkisAssertionCategory object
359
+ */
360
+ exports.objectKeyAssertion = (0, create_js_1.createAssertion)([
361
+ schema_js_1.NonCollectionObjectSchema,
362
+ [
363
+ 'to have key',
364
+ 'to have property',
365
+ 'to have prop',
366
+ 'to contain key',
367
+ 'to contain property',
368
+ 'to contain prop',
369
+ 'to include key',
370
+ 'to include property',
371
+ 'to include prop',
372
+ ],
373
+ schema_js_1.KeypathSchema,
374
+ ], (subject, keypath) => {
375
+ const result = (0, util_js_1.has)(subject, keypath);
376
+ if (!result) {
377
+ return {
378
+ actual: 'no such keypath',
379
+ expect: `to have keypath ${keypath}`,
380
+ message: `Expected object to contain keypath ${keypath}`,
381
+ };
382
+ }
383
+ });
384
+ /**
385
+ * Asserts that an object has an exact property key without keypath traversal.
386
+ * This assertion checks for direct properties on the object and supports
387
+ * symbols and keys that would conflict with bracket/dot notation.
388
+ *
389
+ * Unlike `objectKeyAssertion`, this does not use the `has()` function and
390
+ * therefore:
391
+ *
392
+ * - Does not support keypath traversal (no dots or brackets)
393
+ * - Can check for symbol keys
394
+ * - Can check for keys containing dots, brackets, or other special characters
395
+ * - Only checks direct properties (no nested access)
396
+ *
397
+ * @example
398
+ *
399
+ * ```ts
400
+ * const sym = Symbol('test');
401
+ * const obj = {
402
+ * simple: 'value',
403
+ * 'key.with.dots': 'direct property',
404
+ * 'key[with]brackets': 'another direct property',
405
+ * [sym]: 'symbol value',
406
+ * };
407
+ *
408
+ * expect(obj, 'to have exact key', 'simple'); // passes
409
+ * expect(obj, 'to have exact property', 'key.with.dots'); // passes (literal key)
410
+ * expect(obj, 'to have exact prop', 'key[with]brackets'); // passes (literal key)
411
+ * expect(obj, 'to have exact key', sym); // passes (symbol key)
412
+ *
413
+ * // These would fail because they're not direct properties:
414
+ * expect(obj, 'to have exact key', 'nested.path'); // fails (no keypath traversal)
415
+ * ```
416
+ *
417
+ * @group Collection Assertions
418
+ * @bupkisAnchor object-to-have-only-keys-array
419
+ * @bupkisAssertionCategory object
420
+ */
421
+ exports.objectExactKeyAssertion = (0, create_js_1.createAssertion)([
422
+ schema_js_1.NonCollectionObjectSchema,
423
+ ['to have exact key', 'to have exact property', 'to have exact prop'],
424
+ schema_js_1.PropertyKeySchema,
425
+ ], (_, key) => schema_js_1.NonCollectionObjectSchema.transform((v) => ({ ...v })).refine((value) => hasOwn(value, key), { error: `Expected object to have own exact key "${String(key)}"` }));
426
+ /**
427
+ * Asserts that an object has a specific number of keys.
428
+ *
429
+ * @example
430
+ *
431
+ * ```ts
432
+ * expect({ a: 1, b: 2 }, 'to have size', 2); // passes
433
+ * expect({ a: 1 }, 'to have size', 2); // fails
434
+ * ```
435
+ *
436
+ * @group Collection Assertions
437
+ * @bupkisAnchor unknown-to-be-an-object
438
+ * @bupkisAssertionCategory object
439
+ */
440
+ exports.objectSizeAssertion = (0, create_js_1.createAssertion)([schema_js_1.UnknownRecordSchema, 'to have size', schema_js_1.NonNegativeIntegerSchema], (subject, expectedSize) => {
441
+ const actual = keys(subject).length;
442
+ if (actual !== expectedSize) {
443
+ return {
444
+ actual,
445
+ expected: expectedSize,
446
+ message: `Expected object to have ${expectedSize} keys, but it has ${actual} keys`,
447
+ };
448
+ }
449
+ });
450
+ /**
451
+ * Asserts that two Sets are equal (same elements, order-independent).
452
+ *
453
+ * @example
454
+ *
455
+ * ```ts
456
+ * expect(new Set([1, 2]), 'to equal', new Set([2, 1])); // passes
457
+ * expect(new Set([1, 2]), 'to equal', new Set([1, 3])); // fails
458
+ * ```
459
+ *
460
+ * @group Collection Assertions
461
+ * @bupkisAnchor set-to-equal-set
462
+ * @bupkisAssertionCategory collections
463
+ */
464
+ exports.setEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to equal', schema_js_1.SetSchema], (actual, expected) => actual.size === expected.size && (0, set_prototype_issubsetof_1.default)(actual, expected));
465
+ /**
466
+ * Asserts that one Set is a subset of another.
467
+ *
468
+ * @example
469
+ *
470
+ * ```ts
471
+ * expect(new Set([1, 2]), 'to be a subset of', new Set([1, 2, 3])); // passes
472
+ * expect(new Set([1, 4]), 'to be a subset of', new Set([1, 2, 3])); // fails
473
+ * ```
474
+ *
475
+ * @group Collection Assertions
476
+ * @bupkisAnchor set-to-be-a-subset-of-set
477
+ * @bupkisAssertionCategory collections
478
+ */
479
+ exports.setSubsetAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to be a subset of', schema_js_1.SetSchema], (subset, superset) => (0, set_prototype_issubsetof_1.default)(subset, superset));
480
+ /**
481
+ * Asserts that one Set is a superset of another.
482
+ *
483
+ * @example
484
+ *
485
+ * ```ts
486
+ * expect(new Set([1, 2, 3]), 'to be a superset of', new Set([1, 2])); // passes
487
+ * expect(new Set([1, 2]), 'to be a superset of', new Set([1, 2, 3])); // fails
488
+ * ```
489
+ *
490
+ * @group Collection Assertions
491
+ * @bupkisAnchor set-to-be-a-superset-of-set
492
+ * @bupkisAssertionCategory collections
493
+ */
494
+ exports.setSupersetAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to be a superset of', schema_js_1.SetSchema], (superset, subset) => (0, set_prototype_issupersetof_1.default)(superset, subset));
495
+ /**
496
+ * Asserts that two Sets intersect (have common elements).
497
+ *
498
+ * @example
499
+ *
500
+ * ```ts
501
+ * expect(new Set([1, 2]), 'to intersect with', new Set([2, 3])); // passes
502
+ * expect(new Set([1, 2]), 'to intersect with', new Set([3, 4])); // fails
503
+ * ```
504
+ *
505
+ * @group Collection Assertions
506
+ * @bupkisAnchor set-to-have-intersection-with-set-satisfying-any
507
+ * @bupkisAssertionCategory collections
508
+ */
509
+ exports.setIntersectionAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to intersect with', schema_js_1.SetSchema], (setA, setB) => !(0, set_prototype_isdisjointfrom_1.default)(setA, setB));
510
+ /**
511
+ * Asserts that two Sets are disjoint (have no common elements).
512
+ *
513
+ * @example
514
+ *
515
+ * ```ts
516
+ * expect(new Set([1, 2]), 'to be disjoint from', new Set([3, 4])); // passes
517
+ * expect(new Set([1, 2]), 'to be disjoint from', new Set([2, 3])); // fails
518
+ * ```
519
+ *
520
+ * @group Collection Assertions
521
+ * @bupkisAnchor set-to-be-disjoint-from-set
522
+ * @bupkisAssertionCategory collections
523
+ */
524
+ exports.setDisjointAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to be disjoint from', schema_js_1.SetSchema], (setA, setB) => (0, set_prototype_isdisjointfrom_1.default)(setA, setB));
525
+ /**
526
+ * Asserts that the union of two Sets equals a third Set.
527
+ *
528
+ * @example
529
+ *
530
+ * ```ts
531
+ * expect(
532
+ * new Set([1, 2]),
533
+ * 'to have union',
534
+ * new Set([3]),
535
+ * 'equal to',
536
+ * new Set([1, 2, 3]),
537
+ * ); // passes
538
+ * ```
539
+ *
540
+ * @group Collection Assertions
541
+ * @bupkisAnchor set-union-with-set-to-equal-set
542
+ * @bupkisAssertionCategory collections
543
+ */
544
+ exports.setUnionEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to have union', schema_js_1.SetSchema, 'equal to', schema_js_1.SetSchema], (setA, setB, expected) => {
545
+ const result = (0, set_prototype_union_1.default)(setA, setB);
546
+ return (result.size === expected.size &&
547
+ (0, set_prototype_issubsetof_1.default)(result, expected) &&
548
+ (0, set_prototype_issubsetof_1.default)(expected, result));
549
+ });
550
+ /**
551
+ * Asserts that the intersection of two Sets equals a third Set.
552
+ *
553
+ * @example
554
+ *
555
+ * ```ts
556
+ * expect(
557
+ * new Set([1, 2, 3]),
558
+ * 'to have intersection',
559
+ * new Set([2, 3, 4]),
560
+ * 'equal to',
561
+ * new Set([2, 3]),
562
+ * ); // passes
563
+ * ```
564
+ *
565
+ * @group Collection Assertions
566
+ * @bupkisAnchor set-intersection-with-set-to-equal-set
567
+ * @bupkisAssertionCategory collections
568
+ */
569
+ exports.setIntersectionEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to have intersection', schema_js_1.SetSchema, 'equal to', schema_js_1.SetSchema], (setA, setB, expected) => {
570
+ const result = (0, set_prototype_intersection_1.default)(setA, setB);
571
+ return (result.size === expected.size &&
572
+ (0, set_prototype_issubsetof_1.default)(result, expected) &&
573
+ (0, set_prototype_issubsetof_1.default)(expected, result));
574
+ });
575
+ /**
576
+ * Asserts that the difference between two Sets equals a third Set.
577
+ *
578
+ * @example
579
+ *
580
+ * ```ts
581
+ * expect(
582
+ * new Set([1, 2, 3]),
583
+ * 'to have difference',
584
+ * new Set([2, 4]),
585
+ * 'equal to',
586
+ * new Set([1, 3]),
587
+ * ); // passes
588
+ * ```
589
+ *
590
+ * @group Collection Assertions
591
+ * @bupkisAnchor set-difference-with-set-to-equal-set
592
+ * @bupkisAssertionCategory collections
593
+ */
594
+ exports.setDifferenceEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to have difference', schema_js_1.SetSchema, 'equal to', schema_js_1.SetSchema], (setA, setB, expected) => {
595
+ const result = (0, set_prototype_difference_1.default)(setA, setB);
596
+ return (result.size === expected.size &&
597
+ (0, set_prototype_issubsetof_1.default)(result, expected) &&
598
+ (0, set_prototype_issubsetof_1.default)(expected, result));
599
+ });
600
+ /**
601
+ * Asserts that the symmetric difference between two Sets equals a third Set.
602
+ *
603
+ * @example
604
+ *
605
+ * ```ts
606
+ * expect(
607
+ * new Set([1, 2]),
608
+ * 'to have symmetric difference',
609
+ * new Set([2, 3]),
610
+ * 'equal to',
611
+ * new Set([1, 3]),
612
+ * ); // passes
613
+ * ```
614
+ *
615
+ * @group Collection Assertions
616
+ * @bupkisAnchor set-symmetric-difference-with-set-to-equal-set
617
+ * @bupkisAssertionCategory collections
618
+ */
619
+ exports.setSymmetricDifferenceEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to have symmetric difference', schema_js_1.SetSchema, 'equal to', schema_js_1.SetSchema], (setA, setB, expected) => {
620
+ const result = (0, set_prototype_symmetricdifference_1.default)(setA, setB);
621
+ return (result.size === expected.size &&
622
+ (0, set_prototype_issubsetof_1.default)(result, expected) &&
623
+ (0, set_prototype_issubsetof_1.default)(expected, result));
624
+ });
625
+ /**
626
+ * Asserts that a Map has a specific key.
627
+ *
628
+ * @example
629
+ *
630
+ * ```ts
631
+ * const map = new Map([['key', 'value']]);
632
+ * expect(map, 'to have key', 'key'); // passes
633
+ * expect(map, 'to have key', 'missing'); // fails
634
+ * ```
635
+ *
636
+ * @group Collection Assertions
637
+ * @bupkisAnchor map-to-have-key-any
638
+ * @bupkisAssertionCategory collections
639
+ */
640
+ exports.mapKeyAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to have key', schema_js_1.UnknownSchema], (map, key) => {
641
+ if (!map.has(key)) {
642
+ return {
643
+ actual: [...map.keys()],
644
+ expected: [...map.keys(), key],
645
+ message: 'Expected Map to have key',
646
+ };
647
+ }
648
+ });
649
+ /**
650
+ * Asserts that a Map contains a specific value.
651
+ *
652
+ * @example
653
+ *
654
+ * ```ts
655
+ * const map = new Map([['key', 'value']]);
656
+ * expect(map, 'to have value', 'value'); // passes
657
+ * expect(map, 'to have value', 'missing'); // fails
658
+ * ```
659
+ *
660
+ * @group Collection Assertions
661
+ * @bupkisAnchor map-to-have-value-any
662
+ * @bupkisAssertionCategory collections
663
+ */
664
+ exports.mapValueAssertion = (0, create_js_1.createAssertion)([
665
+ schema_js_1.MapSchema,
666
+ ['to have value', 'to contain value', 'to include value'],
667
+ schema_js_1.UnknownSchema,
668
+ ], (map, value) => {
669
+ for (const mapValue of map.values()) {
670
+ if (mapValue === value) {
671
+ return;
672
+ }
673
+ }
674
+ return {
675
+ actual: [...map.values()],
676
+ expected: value,
677
+ message: `Expected Map to have value`,
678
+ };
679
+ });
680
+ /**
681
+ * Asserts that a Map has a specific key-value entry.
682
+ *
683
+ * @example
684
+ *
685
+ * ```ts
686
+ * const map = new Map([['key', 'value']]);
687
+ * expect(map, 'to have entry', ['key', 'value']); // passes
688
+ * expect(map, 'to have entry', ['key', 'wrong']); // fails
689
+ * ```
690
+ *
691
+ * @group Collection Assertions
692
+ * @bupkisAnchor map-to-have-entry-any-any
693
+ * @bupkisAssertionCategory collections
694
+ */
695
+ exports.mapEntryAssertion = (0, create_js_1.createAssertion)([
696
+ schema_js_1.AnyMapSchema,
697
+ [
698
+ 'to have entry',
699
+ 'to have key/value pair',
700
+ 'to contain entry',
701
+ 'to contain key/value pair',
702
+ 'to include entry',
703
+ 'to include key/value pair',
704
+ ],
705
+ zod_1.z.tuple([schema_js_1.UnknownSchema, schema_js_1.UnknownSchema]),
706
+ ], (map, [key, value]) => {
707
+ // WeakMap operations only work with object or symbol keys
708
+ if (map instanceof WeakMap && !(0, guards_js_1.isWeakKey)(key)) {
709
+ return {
710
+ message: `WeakMap keys must be objects or symbols, got ${typeof key}`,
711
+ };
712
+ }
713
+ // At this point, if it's a WeakMap, we know key is a WeakKey
714
+ const actualValue = map instanceof WeakMap ? map.get(key) : map.get(key);
715
+ if (actualValue === value) {
716
+ return;
717
+ }
718
+ const hasKey = map instanceof WeakMap ? map.has(key) : map.has(key);
719
+ return {
720
+ actual: hasKey ? [key, actualValue] : undefined,
721
+ expected: [key, value],
722
+ message: hasKey
723
+ ? `Expected ${map.constructor.name} entry [${String(key)}, ${String(actualValue)}] to equal [${String(key)}, ${String(value)}]`
724
+ : `Expected ${map.constructor.name} to have key ${String(key)}`,
725
+ };
726
+ });
727
+ /**
728
+ * Asserts that two Maps are equal (same key-value pairs, order-independent).
729
+ *
730
+ * @example
731
+ *
732
+ * ```ts
733
+ * const map1 = new Map([
734
+ * ['a', 1],
735
+ * ['b', 2],
736
+ * ]);
737
+ * const map2 = new Map([
738
+ * ['b', 2],
739
+ * ['a', 1],
740
+ * ]);
741
+ * expect(map1, 'to equal', map2); // passes
742
+ * ```
743
+ *
744
+ * @group Collection Assertions
745
+ * @bupkisAnchor map-to-equal-map
746
+ * @bupkisAssertionCategory collections
747
+ */
748
+ exports.mapEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to equal', schema_js_1.MapSchema], (mapA, mapB) => {
749
+ if (mapA.size !== mapB.size) {
750
+ return {
751
+ actual: mapA.size,
752
+ expected: mapB.size,
753
+ message: `Expected Maps to have equal sizes, got ${mapA.size} and ${mapB.size}`,
754
+ };
755
+ }
756
+ for (const [key, value] of mapA) {
757
+ if (!mapB.has(key)) {
758
+ return {
759
+ message: `Expected second Map to contain key ${String(key)}`,
760
+ };
761
+ }
762
+ if (mapB.get(key) !== value) {
763
+ return {
764
+ actual: [key, mapB.get(key)],
765
+ expected: [key, value],
766
+ message: `Expected Maps to have equal value for key ${String(key)}`,
767
+ };
768
+ }
769
+ }
770
+ });
771
+ /**
772
+ * Asserts that a collection (Map or Set) has a size greater than a threshold.
773
+ *
774
+ * @example
775
+ *
776
+ * ```ts
777
+ * expect(new Set([1, 2, 3]), 'to have size greater than', 2); // passes
778
+ * expect(new Set([1]), 'to have size greater than', 2); // fails
779
+ * ```
780
+ *
781
+ * @group Collection Assertions
782
+ * @bupkisAnchor collection-to-have-size-greater-than-nonnegative-integer
783
+ * @bupkisAssertionCategory collections
784
+ */
785
+ exports.collectionSizeGreaterThanAssertion = (0, create_js_1.createAssertion)([
786
+ zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema]),
787
+ 'to have size greater than',
788
+ schema_js_1.NonNegativeIntegerSchema,
789
+ ], (collection, minSize) => {
790
+ if (collection.size <= minSize) {
791
+ return {
792
+ actual: collection.size,
793
+ expected: minSize,
794
+ message: `Expected ${collection.constructor.name} to have size greater than ${minSize}, got ${collection.size}`,
795
+ };
796
+ }
797
+ });
798
+ /**
799
+ * Asserts that a collection (Map or Set) has a size less than a threshold.
800
+ *
801
+ * @example
802
+ *
803
+ * ```ts
804
+ * expect(new Set([1]), 'to have size less than', 2); // passes
805
+ * expect(new Set([1, 2, 3]), 'to have size less than', 2); // fails
806
+ * ```
807
+ *
808
+ * @group Collection Assertions
809
+ * @bupkisAnchor collection-to-have-size-less-than-nonnegative-integer
810
+ * @bupkisAssertionCategory collections
811
+ */
812
+ exports.collectionSizeLessThanAssertion = (0, create_js_1.createAssertion)([
813
+ zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema]),
814
+ 'to have size less than',
815
+ schema_js_1.NonNegativeIntegerSchema,
816
+ ], (collection, maxSize) => {
817
+ if (collection.size >= maxSize) {
818
+ return {
819
+ actual: collection.size,
820
+ expected: maxSize,
821
+ message: `Expected ${collection.constructor.name} to have size less than ${maxSize}, got ${collection.size}`,
822
+ };
823
+ }
824
+ });
825
+ /**
826
+ * Asserts that a collection (Map or Set) has a size within a specific range.
827
+ *
828
+ * @example
829
+ *
830
+ * ```ts
831
+ * expect(new Set([1, 2]), 'to have size between', [1, 3]); // passes
832
+ * expect(new Set([1, 2, 3, 4]), 'to have size between', [1, 3]); // fails
833
+ * ```
834
+ *
835
+ * @group Collection Assertions
836
+ * @bupkisAnchor collection-to-have-size-between-nonnegative-integer-and-nonnegative-integer
837
+ * @bupkisAssertionCategory collections
838
+ */
839
+ exports.collectionSizeBetweenAssertion = (0, create_js_1.createAssertion)([
840
+ zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema]),
841
+ 'to have size between',
842
+ zod_1.z.tuple([schema_js_1.NonNegativeIntegerSchema, schema_js_1.NonNegativeIntegerSchema]),
843
+ ], (collection, [min, max]) => {
844
+ const size = collection.size;
845
+ if (!(size >= min && size <= max)) {
846
+ return {
847
+ message: `Expected ${collection.constructor.name} to have size between ${min} and ${max}, got ${size}`,
848
+ };
849
+ }
850
+ });
851
+ // =============================================================================
852
+ // Collection value assertions (Map/Set/Array)
853
+ // =============================================================================
854
+ const CollectionSchema = zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema, schema_js_1.UnknownArraySchema]);
855
+ /**
856
+ * Returns the iterable of values for a Map, Set, or Array.
857
+ *
858
+ * Map iterates its values (not entries), while Set and Array are directly
859
+ * iterable.
860
+ *
861
+ * @function
862
+ * @internal
863
+ */
864
+ const getCollectionValues = (collection) => {
865
+ if (collection instanceof Map) {
866
+ return collection.values();
867
+ }
868
+ return collection;
869
+ };
870
+ /**
871
+ * Asserts that ALL values in a Map, Set, or Array individually satisfy the
872
+ * expected shape.
873
+ *
874
+ * Uses partial/satisfy semantics — every value must match. Empty collections
875
+ * pass vacuously.
876
+ *
877
+ * @remarks
878
+ * For `Map`, values (not keys) are checked. Use `mapKeysSatisfyAssertion` to
879
+ * assert on Map keys instead.
880
+ * @example
881
+ *
882
+ * ```ts
883
+ * expect([{ a: 1 }, { a: 2, b: 3 }], 'to have values satisfying', {
884
+ * a: z.number(),
885
+ * }); // passes
886
+ * expect(new Set([1, 2, 3]), 'to have values satisfying', z.number()); // passes
887
+ * expect(new Map([['k', { x: 1 }]]), 'to have values satisfying', {
888
+ * x: z.number(),
889
+ * }); // passes
890
+ * ```
891
+ *
892
+ * @function
893
+ * @group Collection Assertions
894
+ * @bupkisAnchor collection-to-have-values-satisfying-any
895
+ * @bupkisAssertionCategory collections
896
+ */
897
+ exports.collectionValuesSatisfyAssertion = (0, create_js_1.createAssertion)([
898
+ CollectionSchema,
899
+ ['to have values satisfying', 'to contain values satisfying'],
900
+ schema_js_1.UnknownSchema,
901
+ ], (subject, expected) => {
902
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
903
+ let index = 0;
904
+ for (const value of getCollectionValues(subject)) {
905
+ const result = schema.safeParse(value);
906
+ if (!result.success) {
907
+ return {
908
+ message: `Expected all values to satisfy ${(0, node_util_1.inspect)(expected)}, but value at index ${index} did not match: ${(0, node_util_1.inspect)(value)}`,
909
+ };
910
+ }
911
+ index++;
912
+ }
913
+ // Empty collections trivially satisfy (vacuous truth)
914
+ });
915
+ /**
916
+ * Asserts that ALL values in a Map, Set, or Array individually match with deep
917
+ * equality.
918
+ *
919
+ * Uses strict deep-equality semantics — every value must exactly match. Empty
920
+ * collections pass vacuously.
921
+ *
922
+ * @example
923
+ *
924
+ * ```ts
925
+ * expect([{ a: 1 }, { a: 1 }], 'to have values exhaustively satisfying', {
926
+ * a: 1,
927
+ * }); // passes
928
+ * expect([{ a: 1, b: 2 }], 'to have values exhaustively satisfying', {
929
+ * a: 1,
930
+ * }); // fails — extra property b
931
+ * ```
932
+ *
933
+ * @function
934
+ * @group Collection Assertions
935
+ * @bupkisAnchor collection-to-have-values-exhaustively-satisfying-any
936
+ * @bupkisAssertionCategory collections
937
+ */
938
+ exports.collectionValuesExhaustivelySatisfyAssertion = (0, create_js_1.createAssertion)([CollectionSchema, 'to have values exhaustively satisfying', schema_js_1.UnknownSchema], (subject, expected) => {
939
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
940
+ let index = 0;
941
+ for (const value of getCollectionValues(subject)) {
942
+ const result = schema.safeParse(value);
943
+ if (!result.success) {
944
+ return {
945
+ message: `Expected all values to exhaustively satisfy ${(0, node_util_1.inspect)(expected)}, but value at index ${index} did not match: ${(0, node_util_1.inspect)(value)}`,
946
+ };
947
+ }
948
+ index++;
949
+ }
950
+ });
951
+ /**
952
+ * Asserts that at least one value in a Map, Set, or Array satisfies the
953
+ * expected shape.
954
+ *
955
+ * Uses partial/satisfy semantics — any single matching value is sufficient.
956
+ * Fails on empty collections.
957
+ *
958
+ * @remarks
959
+ * For `Map`, values (not keys) are checked.
960
+ * @example
961
+ *
962
+ * ```ts
963
+ * expect([{ a: 1, b: 2 }, { c: 3 }], 'to have a value satisfying', {
964
+ * a: 1,
965
+ * }); // passes
966
+ * expect(new Set([1, 'two', 3]), 'to have a value satisfying', z.string()); // passes
967
+ * expect([1, 2, 3], 'to have value satisfying', 2); // passes
968
+ * ```
969
+ *
970
+ * @function
971
+ * @group Collection Assertions
972
+ * @bupkisAnchor collection-to-have-a-value-satisfying-any
973
+ * @bupkisAssertionCategory collections
974
+ */
975
+ exports.collectionHasValueSatisfyingAssertion = (0, create_js_1.createAssertion)([
976
+ CollectionSchema,
977
+ [
978
+ 'to have a value satisfying',
979
+ 'to have value satisfying',
980
+ 'to contain a value satisfying',
981
+ ],
982
+ schema_js_1.UnknownSchema,
983
+ ], (subject, expected) => {
984
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
985
+ for (const value of getCollectionValues(subject)) {
986
+ if (schema.safeParse(value).success) {
987
+ return;
988
+ }
989
+ }
990
+ return {
991
+ message: `Expected collection to have a value satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
992
+ };
993
+ });
994
+ /**
995
+ * Asserts that at least one value in a Map, Set, or Array exhaustively matches
996
+ * the expected value.
997
+ *
998
+ * Uses strict deep-equality semantics. Fails on empty collections.
999
+ *
1000
+ * @example
1001
+ *
1002
+ * ```ts
1003
+ * expect(
1004
+ * [{ a: 1 }, { a: 1, b: 2 }],
1005
+ * 'to have a value exhaustively satisfying',
1006
+ * {
1007
+ * a: 1,
1008
+ * },
1009
+ * ); // passes — first element matches exactly
1010
+ * expect([{ a: 1, b: 2 }], 'to have a value exhaustively satisfying', {
1011
+ * a: 1,
1012
+ * }); // fails — extra property b
1013
+ * ```
1014
+ *
1015
+ * @function
1016
+ * @group Collection Assertions
1017
+ * @bupkisAnchor collection-to-have-a-value-exhaustively-satisfying-any
1018
+ * @bupkisAssertionCategory collections
1019
+ */
1020
+ exports.collectionHasValueExhaustivelySatisfyingAssertion = (0, create_js_1.createAssertion)([
1021
+ CollectionSchema,
1022
+ [
1023
+ 'to have a value exhaustively satisfying',
1024
+ 'to have value exhaustively satisfying',
1025
+ ],
1026
+ schema_js_1.UnknownSchema,
1027
+ ], (subject, expected) => {
1028
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
1029
+ for (const value of getCollectionValues(subject)) {
1030
+ if (schema.safeParse(value).success) {
1031
+ return;
1032
+ }
1033
+ }
1034
+ return {
1035
+ message: `Expected collection to have a value exhaustively satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
1036
+ };
1037
+ });
1038
+ // =============================================================================
1039
+ // Map key assertions
1040
+ // =============================================================================
1041
+ /**
1042
+ * Asserts that ALL keys in a Map individually satisfy the expected shape.
1043
+ *
1044
+ * Uses partial/satisfy semantics — every key must match. Empty Maps pass
1045
+ * vacuously.
1046
+ *
1047
+ * @example
1048
+ *
1049
+ * ```ts
1050
+ * const map = new Map([
1051
+ * ['foo', 1],
1052
+ * ['bar', 2],
1053
+ * ]);
1054
+ * expect(map, 'to have keys satisfying', z.string()); // passes
1055
+ * expect(map, 'to have props satisfying', z.string()); // alias — same assertion
1056
+ * expect(map, 'to have fields satisfying', z.string()); // alias
1057
+ * expect(map, 'to contain keys satisfying', /^[a-z]+$/); // alias
1058
+ * ```
1059
+ *
1060
+ * @function
1061
+ * @group Collection Assertions
1062
+ * @bupkisAnchor map-to-have-keys-satisfying-any
1063
+ * @bupkisAssertionCategory collections
1064
+ */
1065
+ exports.mapKeysSatisfyAssertion = (0, create_js_1.createAssertion)([
1066
+ schema_js_1.MapSchema,
1067
+ [
1068
+ 'to have keys satisfying',
1069
+ 'to have props satisfying',
1070
+ 'to have properties satisfying',
1071
+ 'to have fields satisfying',
1072
+ 'to contain keys satisfying',
1073
+ 'to contain props satisfying',
1074
+ 'to contain properties satisfying',
1075
+ 'to contain fields satisfying',
1076
+ ],
1077
+ schema_js_1.UnknownSchema,
1078
+ ], (subject, expected) => {
1079
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
1080
+ let index = 0;
1081
+ for (const key of subject.keys()) {
1082
+ const result = schema.safeParse(key);
1083
+ if (!result.success) {
1084
+ return {
1085
+ message: `Expected all Map keys to satisfy ${(0, node_util_1.inspect)(expected)}, but key at index ${index} did not match: ${(0, node_util_1.inspect)(key)}`,
1086
+ };
1087
+ }
1088
+ index++;
1089
+ }
1090
+ // Empty Maps trivially satisfy (vacuous truth)
1091
+ });
1092
+ /**
1093
+ * Asserts that ALL keys in a Map individually match with deep equality.
1094
+ *
1095
+ * Uses strict deep-equality semantics — every key must exactly match. Empty
1096
+ * Maps pass vacuously.
1097
+ *
1098
+ * @example
1099
+ *
1100
+ * ```ts
1101
+ * const map = new Map([
1102
+ * [{ id: 1 }, 'a'],
1103
+ * [{ id: 2 }, 'b'],
1104
+ * ]);
1105
+ * expect(map, 'to have keys exhaustively satisfying', { id: z.number() }); // fails — extra strict
1106
+ * expect(map, 'to have props exhaustively satisfying', { id: z.number() }); // alias
1107
+ * expect(map, 'to have fields exhaustively satisfying', {
1108
+ * id: z.number(),
1109
+ * }); // alias
1110
+ * ```
1111
+ *
1112
+ * @function
1113
+ * @group Collection Assertions
1114
+ * @bupkisAnchor map-to-have-keys-exhaustively-satisfying-any
1115
+ * @bupkisAssertionCategory collections
1116
+ */
1117
+ exports.mapKeysExhaustivelySatisfyAssertion = (0, create_js_1.createAssertion)([
1118
+ schema_js_1.MapSchema,
1119
+ [
1120
+ 'to have keys exhaustively satisfying',
1121
+ 'to have props exhaustively satisfying',
1122
+ 'to have properties exhaustively satisfying',
1123
+ 'to have fields exhaustively satisfying',
1124
+ ],
1125
+ schema_js_1.UnknownSchema,
1126
+ ], (subject, expected) => {
1127
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
1128
+ let index = 0;
1129
+ for (const key of subject.keys()) {
1130
+ const result = schema.safeParse(key);
1131
+ if (!result.success) {
1132
+ return {
1133
+ message: `Expected all Map keys to exhaustively satisfy ${(0, node_util_1.inspect)(expected)}, but key at index ${index} did not match: ${(0, node_util_1.inspect)(key)}`,
1134
+ };
1135
+ }
1136
+ index++;
1137
+ }
1138
+ });
1139
+ /**
1140
+ * Asserts that at least one key in a Map satisfies the expected shape.
1141
+ *
1142
+ * Uses partial/satisfy semantics. Fails on empty Maps.
1143
+ *
1144
+ * @example
1145
+ *
1146
+ * ```ts
1147
+ * const map = new Map([
1148
+ * ['foo', 1],
1149
+ * [42, 2],
1150
+ * ]);
1151
+ * expect(map, 'to have a key satisfying', z.string()); // passes
1152
+ * expect(map, 'to have key satisfying', z.number()); // passes
1153
+ * expect(map, 'to have a prop satisfying', z.string()); // alias
1154
+ * expect(map, 'to have a field satisfying', z.number()); // alias
1155
+ * ```
1156
+ *
1157
+ * @function
1158
+ * @group Collection Assertions
1159
+ * @bupkisAnchor map-to-have-a-key-satisfying-any
1160
+ * @bupkisAssertionCategory collections
1161
+ */
1162
+ exports.mapHasKeySatisfyingAssertion = (0, create_js_1.createAssertion)([
1163
+ schema_js_1.MapSchema,
1164
+ [
1165
+ 'to have a key satisfying',
1166
+ 'to have key satisfying',
1167
+ 'to have a prop satisfying',
1168
+ 'to have prop satisfying',
1169
+ 'to have a property satisfying',
1170
+ 'to have property satisfying',
1171
+ 'to have a field satisfying',
1172
+ 'to have field satisfying',
1173
+ ],
1174
+ schema_js_1.UnknownSchema,
1175
+ ], (subject, expected) => {
1176
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
1177
+ for (const key of subject.keys()) {
1178
+ if (schema.safeParse(key).success) {
1179
+ return;
1180
+ }
1181
+ }
1182
+ return {
1183
+ message: `Expected Map to have a key satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
1184
+ };
1185
+ });
1186
+ /**
1187
+ * Asserts that at least one key in a Map exhaustively matches the expected
1188
+ * value.
1189
+ *
1190
+ * Uses strict deep-equality semantics. Fails on empty Maps.
1191
+ *
1192
+ * @example
1193
+ *
1194
+ * ```ts
1195
+ * const map = new Map([
1196
+ * [{ id: 1 }, 'a'],
1197
+ * [{ id: 2 }, 'b'],
1198
+ * ]);
1199
+ * expect(map, 'to have a key exhaustively satisfying', { id: 1 }); // passes
1200
+ * expect(map, 'to have a prop exhaustively satisfying', { id: 1 }); // alias
1201
+ * expect(map, 'to have a field exhaustively satisfying', { id: 2 }); // alias
1202
+ * ```
1203
+ *
1204
+ * @function
1205
+ * @group Collection Assertions
1206
+ * @bupkisAnchor map-to-have-a-key-exhaustively-satisfying-any
1207
+ * @bupkisAssertionCategory collections
1208
+ */
1209
+ exports.mapHasKeyExhaustivelySatisfyingAssertion = (0, create_js_1.createAssertion)([
1210
+ schema_js_1.MapSchema,
1211
+ [
1212
+ 'to have a key exhaustively satisfying',
1213
+ 'to have key exhaustively satisfying',
1214
+ 'to have a prop exhaustively satisfying',
1215
+ 'to have prop exhaustively satisfying',
1216
+ 'to have a property exhaustively satisfying',
1217
+ 'to have property exhaustively satisfying',
1218
+ 'to have a field exhaustively satisfying',
1219
+ 'to have field exhaustively satisfying',
1220
+ ],
1221
+ schema_js_1.UnknownSchema,
1222
+ ], (subject, expected) => {
1223
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForDeepEqual);
1224
+ for (const key of subject.keys()) {
1225
+ if (schema.safeParse(key).success) {
1226
+ return;
1227
+ }
1228
+ }
1229
+ return {
1230
+ message: `Expected Map to have a key exhaustively satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
1231
+ };
1232
+ });
1233
+ // =============================================================================
1234
+ // Object key assertions
1235
+ // =============================================================================
1236
+ /**
1237
+ * Asserts that ALL own enumerable string keys of a non-collection object
1238
+ * individually satisfy the expected shape.
1239
+ *
1240
+ * Uses partial/satisfy semantics — every key must match. Empty objects pass
1241
+ * vacuously.
1242
+ *
1243
+ * @remarks
1244
+ * Only considers own enumerable string keys (equivalent to `Object.keys()`).
1245
+ * Symbol keys and non-enumerable keys are not checked.
1246
+ * @example
1247
+ *
1248
+ * ```ts
1249
+ * expect({ foo: 1, bar: 2 }, 'to have keys satisfying', z.string()); // passes
1250
+ * expect({ foo: 1, bar: 2 }, 'to have props satisfying', /^[a-z]+$/); // alias
1251
+ * expect({ foo: 1, bar: 2 }, 'to have fields satisfying', /^[a-z]+$/); // alias
1252
+ * expect({ FOO: 1 }, 'to have keys satisfying', /^[a-z]+$/); // fails
1253
+ * ```
1254
+ *
1255
+ * @function
1256
+ * @group Collection Assertions
1257
+ * @bupkisAnchor object-to-have-keys-satisfying-any
1258
+ * @bupkisAssertionCategory object
1259
+ */
1260
+ exports.objectKeysSatisfyAssertion = (0, create_js_1.createAssertion)([
1261
+ schema_js_1.NonCollectionObjectSchema,
1262
+ [
1263
+ 'to have keys satisfying',
1264
+ 'to have props satisfying',
1265
+ 'to have properties satisfying',
1266
+ 'to have fields satisfying',
1267
+ ],
1268
+ schema_js_1.UnknownSchema,
1269
+ ], (subject, expected) => {
1270
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
1271
+ for (const key of keys(subject)) {
1272
+ const result = schema.safeParse(key);
1273
+ if (!result.success) {
1274
+ return {
1275
+ message: `Expected all object keys to satisfy ${(0, node_util_1.inspect)(expected)}, but key ${(0, node_util_1.inspect)(key)} did not match`,
1276
+ };
1277
+ }
1278
+ }
1279
+ // Empty objects trivially satisfy (vacuous truth)
1280
+ });
1281
+ /**
1282
+ * Asserts that at least one own enumerable string key of a non-collection
1283
+ * object satisfies the expected shape.
1284
+ *
1285
+ * Uses partial/satisfy semantics. Fails on objects with no own enumerable
1286
+ * string keys.
1287
+ *
1288
+ * @remarks
1289
+ * Only considers own enumerable string keys (equivalent to `Object.keys()`).
1290
+ * Symbol keys and non-enumerable keys are not checked.
1291
+ * @example
1292
+ *
1293
+ * ```ts
1294
+ * expect({ foo: 1, BAR: 2 }, 'to have a key satisfying', /^[a-z]+$/); // passes
1295
+ * expect({ foo: 1 }, 'to have key satisfying', z.string()); // passes
1296
+ * expect({ foo: 1 }, 'to have a prop satisfying', z.string()); // alias
1297
+ * expect({ foo: 1 }, 'to have a field satisfying', z.string()); // alias
1298
+ * ```
1299
+ *
1300
+ * @function
1301
+ * @group Collection Assertions
1302
+ * @bupkisAnchor object-to-have-a-key-satisfying-any
1303
+ * @bupkisAssertionCategory object
1304
+ */
1305
+ exports.objectHasKeySatisfyingAssertion = (0, create_js_1.createAssertion)([
1306
+ schema_js_1.NonCollectionObjectSchema,
1307
+ [
1308
+ 'to have a key satisfying',
1309
+ 'to have key satisfying',
1310
+ 'to have a prop satisfying',
1311
+ 'to have prop satisfying',
1312
+ 'to have a property satisfying',
1313
+ 'to have property satisfying',
1314
+ 'to have a field satisfying',
1315
+ 'to have field satisfying',
1316
+ ],
1317
+ schema_js_1.UnknownSchema,
1318
+ ], (subject, expected) => {
1319
+ const schema = (0, value_to_schema_js_1.valueToSchema)(expected, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
1320
+ for (const key of keys(subject)) {
1321
+ if (schema.safeParse(key).success) {
1322
+ return;
1323
+ }
1324
+ }
1325
+ return {
1326
+ message: `Expected object to have a key satisfying ${(0, node_util_1.inspect)(expected)}, but none matched`,
1327
+ };
1328
+ });
1329
+ /**
1330
+ * Asserts that ALL own enumerable string keys of a non-collection object match
1331
+ * a regular expression.
1332
+ *
1333
+ * Empty objects pass vacuously.
1334
+ *
1335
+ * @remarks
1336
+ * Only considers own enumerable string keys (equivalent to `Object.keys()`).
1337
+ * Symbol keys and non-enumerable keys are not checked.
1338
+ * @example
1339
+ *
1340
+ * ```ts
1341
+ * expect({ foo: 1, bar: 2 }, 'to have keys matching', /^[a-z]+$/); // passes
1342
+ * expect({ foo: 1, bar: 2 }, 'to have props matching', /^[a-z]+$/); // alias
1343
+ * expect({ foo: 1, bar: 2 }, 'to have fields matching', /^[a-z]+$/); // alias
1344
+ * expect({ foo: 1, Bar: 2 }, 'to have keys matching', /^[a-z]+$/); // fails
1345
+ * expect({}, 'to have keys matching', /anything/); // passes (vacuous)
1346
+ * ```
1347
+ *
1348
+ * @function
1349
+ * @group Collection Assertions
1350
+ * @bupkisAnchor object-to-have-keys-matching-regexp
1351
+ * @bupkisAssertionCategory object
1352
+ */
1353
+ exports.objectKeysMatchAssertion = (0, create_js_1.createAssertion)([
1354
+ schema_js_1.NonCollectionObjectSchema,
1355
+ [
1356
+ 'to have keys matching',
1357
+ 'to have props matching',
1358
+ 'to have properties matching',
1359
+ 'to have fields matching',
1360
+ ],
1361
+ zod_1.z.instanceof(RegExp),
1362
+ ], (subject, pattern) => {
1363
+ for (const key of keys(subject)) {
1364
+ if (pattern.global || pattern.sticky) {
1365
+ pattern.lastIndex = 0;
1366
+ }
1367
+ if (!pattern.test(key)) {
1368
+ return {
1369
+ message: `Expected all object keys to match ${(0, node_util_1.inspect)(pattern)}, but key ${(0, node_util_1.inspect)(key)} did not match`,
1370
+ };
1371
+ }
1372
+ }
1373
+ });
1374
+ /**
1375
+ * Asserts that at least one own enumerable string key of a non-collection
1376
+ * object matches a regular expression.
1377
+ *
1378
+ * Fails on objects with no own enumerable string keys.
1379
+ *
1380
+ * @remarks
1381
+ * Only considers own enumerable string keys (equivalent to `Object.keys()`).
1382
+ * Symbol keys and non-enumerable keys are not checked.
1383
+ * @example
1384
+ *
1385
+ * ```ts
1386
+ * expect({ foo: 1, BAR: 2 }, 'to have a key matching', /^[a-z]+$/); // passes
1387
+ * expect({ foo: 1, BAR: 2 }, 'to have a prop matching', /^[a-z]+$/); // alias
1388
+ * expect({ foo: 1, BAR: 2 }, 'to have a field matching', /^[a-z]+$/); // alias
1389
+ * expect({ FOO: 1, BAR: 2 }, 'to have a key matching', /^[a-z]+$/); // fails
1390
+ * expect({ foo: 1 }, 'to have key matching', /foo/); // passes
1391
+ * ```
1392
+ *
1393
+ * @function
1394
+ * @group Collection Assertions
1395
+ * @bupkisAnchor object-to-have-a-key-matching-regexp
1396
+ * @bupkisAssertionCategory object
1397
+ */
1398
+ exports.objectHasKeyMatchingAssertion = (0, create_js_1.createAssertion)([
1399
+ schema_js_1.NonCollectionObjectSchema,
1400
+ [
1401
+ 'to have a key matching',
1402
+ 'to have key matching',
1403
+ 'to have a prop matching',
1404
+ 'to have prop matching',
1405
+ 'to have a property matching',
1406
+ 'to have property matching',
1407
+ 'to have a field matching',
1408
+ 'to have field matching',
1409
+ ],
1410
+ zod_1.z.instanceof(RegExp),
1411
+ ], (subject, pattern) => {
1412
+ for (const key of keys(subject)) {
1413
+ if (pattern.global || pattern.sticky) {
1414
+ pattern.lastIndex = 0;
1415
+ }
1416
+ if (pattern.test(key)) {
1417
+ return;
1418
+ }
1419
+ }
1420
+ return {
1421
+ message: `Expected object to have a key matching ${(0, node_util_1.inspect)(pattern)}, but none matched`,
1422
+ };
1423
+ });
1424
+ //# sourceMappingURL=sync-collection.js.map