bupkis 0.18.0 → 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 (377) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +1 -4
  3. package/src/assertion/assertion-types.ts +4 -4
  4. package/src/assertion/impl/async-parametric.ts +4 -21
  5. package/src/assertion/impl/sync-parametric.ts +5 -17
  6. package/src/expect.ts +0 -4
  7. package/src/guards.ts +24 -24
  8. package/src/internal-schema.ts +16 -32
  9. package/src/value-to-schema.ts +1 -1
  10. package/dist/assertion/assertion-async.cjs +0 -268
  11. package/dist/assertion/assertion-async.cjs.map +0 -1
  12. package/dist/assertion/assertion-async.d.cts +0 -40
  13. package/dist/assertion/assertion-async.d.cts.map +0 -1
  14. package/dist/assertion/assertion-async.d.ts +0 -40
  15. package/dist/assertion/assertion-async.d.ts.map +0 -1
  16. package/dist/assertion/assertion-async.js +0 -259
  17. package/dist/assertion/assertion-async.js.map +0 -1
  18. package/dist/assertion/assertion-standard-schema-async.cjs +0 -132
  19. package/dist/assertion/assertion-standard-schema-async.cjs.map +0 -1
  20. package/dist/assertion/assertion-standard-schema-async.d.cts +0 -52
  21. package/dist/assertion/assertion-standard-schema-async.d.cts.map +0 -1
  22. package/dist/assertion/assertion-standard-schema-async.d.ts +0 -52
  23. package/dist/assertion/assertion-standard-schema-async.d.ts.map +0 -1
  24. package/dist/assertion/assertion-standard-schema-async.js +0 -128
  25. package/dist/assertion/assertion-standard-schema-async.js.map +0 -1
  26. package/dist/assertion/assertion-standard-schema-sync.cjs +0 -141
  27. package/dist/assertion/assertion-standard-schema-sync.cjs.map +0 -1
  28. package/dist/assertion/assertion-standard-schema-sync.d.cts +0 -52
  29. package/dist/assertion/assertion-standard-schema-sync.d.cts.map +0 -1
  30. package/dist/assertion/assertion-standard-schema-sync.d.ts +0 -52
  31. package/dist/assertion/assertion-standard-schema-sync.d.ts.map +0 -1
  32. package/dist/assertion/assertion-standard-schema-sync.js +0 -137
  33. package/dist/assertion/assertion-standard-schema-sync.js.map +0 -1
  34. package/dist/assertion/assertion-sync.cjs +0 -284
  35. package/dist/assertion/assertion-sync.cjs.map +0 -1
  36. package/dist/assertion/assertion-sync.d.cts +0 -60
  37. package/dist/assertion/assertion-sync.d.cts.map +0 -1
  38. package/dist/assertion/assertion-sync.d.ts +0 -60
  39. package/dist/assertion/assertion-sync.d.ts.map +0 -1
  40. package/dist/assertion/assertion-sync.js +0 -275
  41. package/dist/assertion/assertion-sync.js.map +0 -1
  42. package/dist/assertion/assertion-types.cjs +0 -20
  43. package/dist/assertion/assertion-types.cjs.map +0 -1
  44. package/dist/assertion/assertion-types.d.cts +0 -1086
  45. package/dist/assertion/assertion-types.d.cts.map +0 -1
  46. package/dist/assertion/assertion-types.d.ts +0 -1086
  47. package/dist/assertion/assertion-types.d.ts.map +0 -1
  48. package/dist/assertion/assertion-types.js +0 -19
  49. package/dist/assertion/assertion-types.js.map +0 -1
  50. package/dist/assertion/assertion.cjs +0 -382
  51. package/dist/assertion/assertion.cjs.map +0 -1
  52. package/dist/assertion/assertion.d.cts +0 -109
  53. package/dist/assertion/assertion.d.cts.map +0 -1
  54. package/dist/assertion/assertion.d.ts +0 -109
  55. package/dist/assertion/assertion.d.ts.map +0 -1
  56. package/dist/assertion/assertion.js +0 -375
  57. package/dist/assertion/assertion.js.map +0 -1
  58. package/dist/assertion/create.cjs +0 -148
  59. package/dist/assertion/create.cjs.map +0 -1
  60. package/dist/assertion/create.d.cts +0 -85
  61. package/dist/assertion/create.d.cts.map +0 -1
  62. package/dist/assertion/create.d.ts +0 -85
  63. package/dist/assertion/create.d.ts.map +0 -1
  64. package/dist/assertion/create.js +0 -143
  65. package/dist/assertion/create.js.map +0 -1
  66. package/dist/assertion/format-assertion-failure.cjs +0 -63
  67. package/dist/assertion/format-assertion-failure.cjs.map +0 -1
  68. package/dist/assertion/format-assertion-failure.d.cts +0 -21
  69. package/dist/assertion/format-assertion-failure.d.cts.map +0 -1
  70. package/dist/assertion/format-assertion-failure.d.ts +0 -21
  71. package/dist/assertion/format-assertion-failure.d.ts.map +0 -1
  72. package/dist/assertion/format-assertion-failure.js +0 -59
  73. package/dist/assertion/format-assertion-failure.js.map +0 -1
  74. package/dist/assertion/impl/assertion-util.cjs +0 -68
  75. package/dist/assertion/impl/assertion-util.cjs.map +0 -1
  76. package/dist/assertion/impl/assertion-util.d.cts +0 -36
  77. package/dist/assertion/impl/assertion-util.d.cts.map +0 -1
  78. package/dist/assertion/impl/assertion-util.d.ts +0 -36
  79. package/dist/assertion/impl/assertion-util.d.ts.map +0 -1
  80. package/dist/assertion/impl/assertion-util.js +0 -62
  81. package/dist/assertion/impl/assertion-util.js.map +0 -1
  82. package/dist/assertion/impl/async-iterable.cjs +0 -627
  83. package/dist/assertion/impl/async-iterable.cjs.map +0 -1
  84. package/dist/assertion/impl/async-iterable.d.cts +0 -406
  85. package/dist/assertion/impl/async-iterable.d.cts.map +0 -1
  86. package/dist/assertion/impl/async-iterable.d.ts +0 -406
  87. package/dist/assertion/impl/async-iterable.d.ts.map +0 -1
  88. package/dist/assertion/impl/async-iterable.js +0 -624
  89. package/dist/assertion/impl/async-iterable.js.map +0 -1
  90. package/dist/assertion/impl/async-parametric.cjs +0 -423
  91. package/dist/assertion/impl/async-parametric.cjs.map +0 -1
  92. package/dist/assertion/impl/async-parametric.d.cts +0 -278
  93. package/dist/assertion/impl/async-parametric.d.cts.map +0 -1
  94. package/dist/assertion/impl/async-parametric.d.ts +0 -278
  95. package/dist/assertion/impl/async-parametric.d.ts.map +0 -1
  96. package/dist/assertion/impl/async-parametric.js +0 -420
  97. package/dist/assertion/impl/async-parametric.js.map +0 -1
  98. package/dist/assertion/impl/async.cjs +0 -56
  99. package/dist/assertion/impl/async.cjs.map +0 -1
  100. package/dist/assertion/impl/async.d.cts +0 -179
  101. package/dist/assertion/impl/async.d.cts.map +0 -1
  102. package/dist/assertion/impl/async.d.ts +0 -179
  103. package/dist/assertion/impl/async.d.ts.map +0 -1
  104. package/dist/assertion/impl/async.js +0 -39
  105. package/dist/assertion/impl/async.js.map +0 -1
  106. package/dist/assertion/impl/index.cjs +0 -37
  107. package/dist/assertion/impl/index.cjs.map +0 -1
  108. package/dist/assertion/impl/index.d.cts +0 -21
  109. package/dist/assertion/impl/index.d.cts.map +0 -1
  110. package/dist/assertion/impl/index.d.ts +0 -21
  111. package/dist/assertion/impl/index.d.ts.map +0 -1
  112. package/dist/assertion/impl/index.js +0 -21
  113. package/dist/assertion/impl/index.js.map +0 -1
  114. package/dist/assertion/impl/iteration-util.cjs +0 -297
  115. package/dist/assertion/impl/iteration-util.cjs.map +0 -1
  116. package/dist/assertion/impl/iteration-util.d.cts +0 -12
  117. package/dist/assertion/impl/iteration-util.d.cts.map +0 -1
  118. package/dist/assertion/impl/iteration-util.d.ts +0 -12
  119. package/dist/assertion/impl/iteration-util.d.ts.map +0 -1
  120. package/dist/assertion/impl/iteration-util.js +0 -282
  121. package/dist/assertion/impl/iteration-util.js.map +0 -1
  122. package/dist/assertion/impl/snapshot.cjs +0 -276
  123. package/dist/assertion/impl/snapshot.cjs.map +0 -1
  124. package/dist/assertion/impl/snapshot.d.cts +0 -278
  125. package/dist/assertion/impl/snapshot.d.cts.map +0 -1
  126. package/dist/assertion/impl/snapshot.d.ts +0 -278
  127. package/dist/assertion/impl/snapshot.d.ts.map +0 -1
  128. package/dist/assertion/impl/snapshot.js +0 -273
  129. package/dist/assertion/impl/snapshot.js.map +0 -1
  130. package/dist/assertion/impl/sync-basic.cjs +0 -553
  131. package/dist/assertion/impl/sync-basic.cjs.map +0 -1
  132. package/dist/assertion/impl/sync-basic.d.cts +0 -528
  133. package/dist/assertion/impl/sync-basic.d.cts.map +0 -1
  134. package/dist/assertion/impl/sync-basic.d.ts +0 -528
  135. package/dist/assertion/impl/sync-basic.d.ts.map +0 -1
  136. package/dist/assertion/impl/sync-basic.js +0 -550
  137. package/dist/assertion/impl/sync-basic.js.map +0 -1
  138. package/dist/assertion/impl/sync-collection.cjs +0 -856
  139. package/dist/assertion/impl/sync-collection.cjs.map +0 -1
  140. package/dist/assertion/impl/sync-collection.d.cts +0 -607
  141. package/dist/assertion/impl/sync-collection.d.cts.map +0 -1
  142. package/dist/assertion/impl/sync-collection.d.ts +0 -607
  143. package/dist/assertion/impl/sync-collection.d.ts.map +0 -1
  144. package/dist/assertion/impl/sync-collection.js +0 -850
  145. package/dist/assertion/impl/sync-collection.js.map +0 -1
  146. package/dist/assertion/impl/sync-date.cjs +0 -341
  147. package/dist/assertion/impl/sync-date.cjs.map +0 -1
  148. package/dist/assertion/impl/sync-date.d.cts +0 -209
  149. package/dist/assertion/impl/sync-date.d.cts.map +0 -1
  150. package/dist/assertion/impl/sync-date.d.ts +0 -209
  151. package/dist/assertion/impl/sync-date.d.ts.map +0 -1
  152. package/dist/assertion/impl/sync-date.js +0 -338
  153. package/dist/assertion/impl/sync-date.js.map +0 -1
  154. package/dist/assertion/impl/sync-esoteric.cjs +0 -214
  155. package/dist/assertion/impl/sync-esoteric.cjs.map +0 -1
  156. package/dist/assertion/impl/sync-esoteric.d.cts +0 -191
  157. package/dist/assertion/impl/sync-esoteric.d.cts.map +0 -1
  158. package/dist/assertion/impl/sync-esoteric.d.ts +0 -191
  159. package/dist/assertion/impl/sync-esoteric.d.ts.map +0 -1
  160. package/dist/assertion/impl/sync-esoteric.js +0 -211
  161. package/dist/assertion/impl/sync-esoteric.js.map +0 -1
  162. package/dist/assertion/impl/sync-iterable.cjs +0 -512
  163. package/dist/assertion/impl/sync-iterable.cjs.map +0 -1
  164. package/dist/assertion/impl/sync-iterable.d.cts +0 -334
  165. package/dist/assertion/impl/sync-iterable.d.cts.map +0 -1
  166. package/dist/assertion/impl/sync-iterable.d.ts +0 -334
  167. package/dist/assertion/impl/sync-iterable.d.ts.map +0 -1
  168. package/dist/assertion/impl/sync-iterable.js +0 -509
  169. package/dist/assertion/impl/sync-iterable.js.map +0 -1
  170. package/dist/assertion/impl/sync-parametric.cjs +0 -812
  171. package/dist/assertion/impl/sync-parametric.cjs.map +0 -1
  172. package/dist/assertion/impl/sync-parametric.d.cts +0 -560
  173. package/dist/assertion/impl/sync-parametric.d.cts.map +0 -1
  174. package/dist/assertion/impl/sync-parametric.d.ts +0 -560
  175. package/dist/assertion/impl/sync-parametric.d.ts.map +0 -1
  176. package/dist/assertion/impl/sync-parametric.js +0 -809
  177. package/dist/assertion/impl/sync-parametric.js.map +0 -1
  178. package/dist/assertion/impl/sync.cjs +0 -214
  179. package/dist/assertion/impl/sync.cjs.map +0 -1
  180. package/dist/assertion/impl/sync.d.cts +0 -512
  181. package/dist/assertion/impl/sync.d.cts.map +0 -1
  182. package/dist/assertion/impl/sync.d.ts +0 -512
  183. package/dist/assertion/impl/sync.d.ts.map +0 -1
  184. package/dist/assertion/impl/sync.js +0 -197
  185. package/dist/assertion/impl/sync.js.map +0 -1
  186. package/dist/assertion/index.cjs +0 -38
  187. package/dist/assertion/index.cjs.map +0 -1
  188. package/dist/assertion/index.d.cts +0 -18
  189. package/dist/assertion/index.d.cts.map +0 -1
  190. package/dist/assertion/index.d.ts +0 -18
  191. package/dist/assertion/index.d.ts.map +0 -1
  192. package/dist/assertion/index.js +0 -17
  193. package/dist/assertion/index.js.map +0 -1
  194. package/dist/assertion/slotify.cjs +0 -165
  195. package/dist/assertion/slotify.cjs.map +0 -1
  196. package/dist/assertion/slotify.d.cts +0 -11
  197. package/dist/assertion/slotify.d.cts.map +0 -1
  198. package/dist/assertion/slotify.d.ts +0 -11
  199. package/dist/assertion/slotify.d.ts.map +0 -1
  200. package/dist/assertion/slotify.js +0 -161
  201. package/dist/assertion/slotify.js.map +0 -1
  202. package/dist/bootstrap.cjs +0 -43
  203. package/dist/bootstrap.cjs.map +0 -1
  204. package/dist/bootstrap.d.cts +0 -27
  205. package/dist/bootstrap.d.cts.map +0 -1
  206. package/dist/bootstrap.d.ts +0 -27
  207. package/dist/bootstrap.d.ts.map +0 -1
  208. package/dist/bootstrap.js +0 -40
  209. package/dist/bootstrap.js.map +0 -1
  210. package/dist/constant.cjs +0 -82
  211. package/dist/constant.cjs.map +0 -1
  212. package/dist/constant.d.cts +0 -69
  213. package/dist/constant.d.cts.map +0 -1
  214. package/dist/constant.d.ts +0 -69
  215. package/dist/constant.d.ts.map +0 -1
  216. package/dist/constant.js +0 -79
  217. package/dist/constant.js.map +0 -1
  218. package/dist/diff.cjs +0 -340
  219. package/dist/diff.cjs.map +0 -1
  220. package/dist/diff.d.cts +0 -51
  221. package/dist/diff.d.cts.map +0 -1
  222. package/dist/diff.d.ts +0 -51
  223. package/dist/diff.d.ts.map +0 -1
  224. package/dist/diff.js +0 -334
  225. package/dist/diff.js.map +0 -1
  226. package/dist/error.cjs +0 -204
  227. package/dist/error.cjs.map +0 -1
  228. package/dist/error.d.cts +0 -212
  229. package/dist/error.d.cts.map +0 -1
  230. package/dist/error.d.ts +0 -212
  231. package/dist/error.d.ts.map +0 -1
  232. package/dist/error.js +0 -191
  233. package/dist/error.js.map +0 -1
  234. package/dist/expect.cjs +0 -590
  235. package/dist/expect.cjs.map +0 -1
  236. package/dist/expect.d.cts +0 -138
  237. package/dist/expect.d.cts.map +0 -1
  238. package/dist/expect.d.ts +0 -138
  239. package/dist/expect.d.ts.map +0 -1
  240. package/dist/expect.js +0 -582
  241. package/dist/expect.js.map +0 -1
  242. package/dist/guards.cjs +0 -297
  243. package/dist/guards.cjs.map +0 -1
  244. package/dist/guards.d.cts +0 -231
  245. package/dist/guards.d.cts.map +0 -1
  246. package/dist/guards.d.ts +0 -231
  247. package/dist/guards.d.ts.map +0 -1
  248. package/dist/guards.js +0 -277
  249. package/dist/guards.js.map +0 -1
  250. package/dist/index.cjs +0 -111
  251. package/dist/index.cjs.map +0 -1
  252. package/dist/index.d.cts +0 -448
  253. package/dist/index.d.cts.map +0 -1
  254. package/dist/index.d.ts +0 -448
  255. package/dist/index.d.ts.map +0 -1
  256. package/dist/index.js +0 -71
  257. package/dist/index.js.map +0 -1
  258. package/dist/internal-schema.cjs +0 -253
  259. package/dist/internal-schema.cjs.map +0 -1
  260. package/dist/internal-schema.d.cts +0 -8
  261. package/dist/internal-schema.d.cts.map +0 -1
  262. package/dist/internal-schema.d.ts +0 -8
  263. package/dist/internal-schema.d.ts.map +0 -1
  264. package/dist/internal-schema.js +0 -248
  265. package/dist/internal-schema.js.map +0 -1
  266. package/dist/metadata.cjs +0 -57
  267. package/dist/metadata.cjs.map +0 -1
  268. package/dist/metadata.d.cts +0 -27
  269. package/dist/metadata.d.cts.map +0 -1
  270. package/dist/metadata.d.ts +0 -27
  271. package/dist/metadata.d.ts.map +0 -1
  272. package/dist/metadata.js +0 -54
  273. package/dist/metadata.js.map +0 -1
  274. package/dist/schema.cjs +0 -1522
  275. package/dist/schema.cjs.map +0 -1
  276. package/dist/schema.d.cts +0 -1196
  277. package/dist/schema.d.cts.map +0 -1
  278. package/dist/schema.d.ts +0 -1196
  279. package/dist/schema.d.ts.map +0 -1
  280. package/dist/schema.js +0 -1516
  281. package/dist/schema.js.map +0 -1
  282. package/dist/snapshot/adapter.cjs +0 -31
  283. package/dist/snapshot/adapter.cjs.map +0 -1
  284. package/dist/snapshot/adapter.d.cts +0 -258
  285. package/dist/snapshot/adapter.d.cts.map +0 -1
  286. package/dist/snapshot/adapter.d.ts +0 -258
  287. package/dist/snapshot/adapter.d.ts.map +0 -1
  288. package/dist/snapshot/adapter.js +0 -27
  289. package/dist/snapshot/adapter.js.map +0 -1
  290. package/dist/snapshot/adapters/fallback.cjs +0 -453
  291. package/dist/snapshot/adapters/fallback.cjs.map +0 -1
  292. package/dist/snapshot/adapters/fallback.d.cts +0 -185
  293. package/dist/snapshot/adapters/fallback.d.cts.map +0 -1
  294. package/dist/snapshot/adapters/fallback.d.ts +0 -185
  295. package/dist/snapshot/adapters/fallback.d.ts.map +0 -1
  296. package/dist/snapshot/adapters/fallback.js +0 -446
  297. package/dist/snapshot/adapters/fallback.js.map +0 -1
  298. package/dist/snapshot/adapters/node-test.cjs +0 -301
  299. package/dist/snapshot/adapters/node-test.cjs.map +0 -1
  300. package/dist/snapshot/adapters/node-test.d.cts +0 -131
  301. package/dist/snapshot/adapters/node-test.d.cts.map +0 -1
  302. package/dist/snapshot/adapters/node-test.d.ts +0 -131
  303. package/dist/snapshot/adapters/node-test.d.ts.map +0 -1
  304. package/dist/snapshot/adapters/node-test.js +0 -297
  305. package/dist/snapshot/adapters/node-test.js.map +0 -1
  306. package/dist/snapshot/index.cjs +0 -61
  307. package/dist/snapshot/index.cjs.map +0 -1
  308. package/dist/snapshot/index.d.cts +0 -40
  309. package/dist/snapshot/index.d.cts.map +0 -1
  310. package/dist/snapshot/index.d.ts +0 -40
  311. package/dist/snapshot/index.d.ts.map +0 -1
  312. package/dist/snapshot/index.js +0 -44
  313. package/dist/snapshot/index.js.map +0 -1
  314. package/dist/snapshot/node-version.cjs +0 -49
  315. package/dist/snapshot/node-version.cjs.map +0 -1
  316. package/dist/snapshot/node-version.d.cts +0 -34
  317. package/dist/snapshot/node-version.d.cts.map +0 -1
  318. package/dist/snapshot/node-version.d.ts +0 -34
  319. package/dist/snapshot/node-version.d.ts.map +0 -1
  320. package/dist/snapshot/node-version.js +0 -44
  321. package/dist/snapshot/node-version.js.map +0 -1
  322. package/dist/snapshot/select-adapter.cjs +0 -170
  323. package/dist/snapshot/select-adapter.cjs.map +0 -1
  324. package/dist/snapshot/select-adapter.d.cts +0 -128
  325. package/dist/snapshot/select-adapter.d.cts.map +0 -1
  326. package/dist/snapshot/select-adapter.d.ts +0 -128
  327. package/dist/snapshot/select-adapter.d.ts.map +0 -1
  328. package/dist/snapshot/select-adapter.js +0 -164
  329. package/dist/snapshot/select-adapter.js.map +0 -1
  330. package/dist/snapshot/serializer.cjs +0 -246
  331. package/dist/snapshot/serializer.cjs.map +0 -1
  332. package/dist/snapshot/serializer.d.cts +0 -126
  333. package/dist/snapshot/serializer.d.cts.map +0 -1
  334. package/dist/snapshot/serializer.d.ts +0 -126
  335. package/dist/snapshot/serializer.d.ts.map +0 -1
  336. package/dist/snapshot/serializer.js +0 -238
  337. package/dist/snapshot/serializer.js.map +0 -1
  338. package/dist/standard-schema.cjs +0 -13
  339. package/dist/standard-schema.cjs.map +0 -1
  340. package/dist/standard-schema.d.cts +0 -192
  341. package/dist/standard-schema.d.cts.map +0 -1
  342. package/dist/standard-schema.d.ts +0 -192
  343. package/dist/standard-schema.d.ts.map +0 -1
  344. package/dist/standard-schema.js +0 -12
  345. package/dist/standard-schema.js.map +0 -1
  346. package/dist/types.cjs +0 -22
  347. package/dist/types.cjs.map +0 -1
  348. package/dist/types.d.cts +0 -905
  349. package/dist/types.d.cts.map +0 -1
  350. package/dist/types.d.ts +0 -905
  351. package/dist/types.d.ts.map +0 -1
  352. package/dist/types.js +0 -21
  353. package/dist/types.js.map +0 -1
  354. package/dist/use.cjs +0 -240
  355. package/dist/use.cjs.map +0 -1
  356. package/dist/use.d.cts +0 -8
  357. package/dist/use.d.cts.map +0 -1
  358. package/dist/use.d.ts +0 -8
  359. package/dist/use.d.ts.map +0 -1
  360. package/dist/use.js +0 -236
  361. package/dist/use.js.map +0 -1
  362. package/dist/util.cjs +0 -255
  363. package/dist/util.cjs.map +0 -1
  364. package/dist/util.d.cts +0 -141
  365. package/dist/util.d.cts.map +0 -1
  366. package/dist/util.d.ts +0 -141
  367. package/dist/util.d.ts.map +0 -1
  368. package/dist/util.js +0 -234
  369. package/dist/util.js.map +0 -1
  370. package/dist/value-to-schema.cjs +0 -537
  371. package/dist/value-to-schema.cjs.map +0 -1
  372. package/dist/value-to-schema.d.cts +0 -144
  373. package/dist/value-to-schema.d.cts.map +0 -1
  374. package/dist/value-to-schema.d.ts +0 -144
  375. package/dist/value-to-schema.d.ts.map +0 -1
  376. package/dist/value-to-schema.js +0 -533
  377. package/dist/value-to-schema.js.map +0 -1
@@ -1,856 +0,0 @@
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.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 set_prototype_difference_1 = __importDefault(require("set.prototype.difference"));
24
- const set_prototype_intersection_1 = __importDefault(require("set.prototype.intersection"));
25
- const set_prototype_isdisjointfrom_1 = __importDefault(require("set.prototype.isdisjointfrom"));
26
- const set_prototype_issubsetof_1 = __importDefault(require("set.prototype.issubsetof"));
27
- const set_prototype_issupersetof_1 = __importDefault(require("set.prototype.issupersetof"));
28
- const set_prototype_symmetricdifference_1 = __importDefault(require("set.prototype.symmetricdifference"));
29
- const set_prototype_union_1 = __importDefault(require("set.prototype.union"));
30
- const zod_1 = require("zod");
31
- const guards_js_1 = require("../../guards.cjs");
32
- const schema_js_1 = require("../../schema.cjs");
33
- const util_js_1 = require("../../util.cjs");
34
- const value_to_schema_js_1 = require("../../value-to-schema.cjs");
35
- const create_js_1 = require("../create.cjs");
36
- const { hasOwn, keys } = Object;
37
- /**
38
- * Asserts that a Map or WeakMap contains a specific key. For WeakMap, the key
39
- * must be an object.
40
- *
41
- * @example
42
- *
43
- * ```ts
44
- * const map = new Map([['key', 'value']]);
45
- * expect(map, 'to contain', 'key'); // passes
46
- *
47
- * const obj = {};
48
- * const weakMap = new WeakMap([[obj, 'value']]);
49
- * expect(weakMap, 'to contain', obj); // passes
50
- * expect(weakMap, 'to contain', 'string'); // fails (not an object)
51
- * ```
52
- *
53
- * @group Collection Assertions
54
- * @bupkisAnchor map-to-contain-any
55
- * @bupkisAssertionCategory collections
56
- */
57
- exports.mapContainsAssertion = (0, create_js_1.createAssertion)([schema_js_1.AnyMapSchema, ['to contain', 'to include'], schema_js_1.UnknownSchema], (subject, key) => {
58
- // WeakMap.has only works with object or symbol keys
59
- let hasKey;
60
- if (subject instanceof WeakMap) {
61
- if (!(0, guards_js_1.isWeakKey)(key)) {
62
- return {
63
- message: `WeakMap keys must be objects or symbols, got ${typeof key}`,
64
- };
65
- }
66
- hasKey = subject.has(key);
67
- }
68
- else {
69
- hasKey = subject.has(key);
70
- }
71
- if (!hasKey) {
72
- return {
73
- actual: key,
74
- expected: `key to exist in ${subject.constructor.name}`,
75
- message: `Expected ${subject.constructor.name} to contain key`,
76
- };
77
- }
78
- });
79
- /**
80
- * Asserts that a Map has a specific size.
81
- *
82
- * @example
83
- *
84
- * ```ts
85
- * const map = new Map([
86
- * ['a', 1],
87
- * ['b', 2],
88
- * ]);
89
- * expect(map, 'to have size', 2); // passes
90
- * expect(map, 'to have size', 3); // fails
91
- * ```
92
- *
93
- * @group Collection Assertions
94
- * @bupkisAnchor map-to-have-size-nonnegative-integer
95
- * @bupkisAssertionCategory collections
96
- */
97
- 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, {
98
- error: `Expected Map to have size ${expectedSize}`,
99
- }));
100
- /**
101
- * Asserts that a Map is empty.
102
- *
103
- * @example
104
- *
105
- * ```ts
106
- * expect(new Map(), 'to be empty'); // passes
107
- * expect(new Map([['key', 'value']]), 'to be empty'); // fails
108
- * ```
109
- *
110
- * @group Collection Assertions
111
- * @bupkisAnchor map-to-be-empty
112
- * @bupkisAssertionCategory collections
113
- */
114
- exports.emptyMapAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to be empty'], schema_js_1.MapSchema.refine((map) => map.size === 0, {
115
- error: 'Expected Map to be empty',
116
- }));
117
- /**
118
- * Asserts that a Set or WeakSet contains a specific value. For WeakSet, the
119
- * value must be an object.
120
- *
121
- * @example
122
- *
123
- * ```ts
124
- * const set = new Set(['a', 'b']);
125
- * expect(set, 'to contain', 'a'); // passes
126
- *
127
- * const obj = {};
128
- * const weakSet = new WeakSet([obj]);
129
- * expect(weakSet, 'to contain', obj); // passes
130
- * expect(weakSet, 'to contain', 'string'); // fails (not an object)
131
- * ```
132
- *
133
- * @group Collection Assertions
134
- * @bupkisAnchor set-to-contain-any
135
- * @bupkisAssertionCategory collections
136
- */
137
- exports.setContainsAssertion = (0, create_js_1.createAssertion)([schema_js_1.AnySetSchema, ['to contain', 'to include'], schema_js_1.UnknownSchema], (subject, value) => {
138
- // WeakSet.has only works with object or symbol values
139
- if (subject instanceof WeakSet && !(0, guards_js_1.isWeakKey)(value)) {
140
- return {
141
- message: `WeakSet values must be objects or symbols, got ${typeof value}`,
142
- };
143
- }
144
- // At this point, if it's a WeakSet, we know value is a WeakKey
145
- const hasValue = subject instanceof WeakSet
146
- ? subject.has(value)
147
- : subject.has(value);
148
- if (!hasValue) {
149
- return {
150
- actual: value,
151
- expected: `value to exist in ${subject.constructor.name}`,
152
- message: `Expected ${subject.constructor.name} to contain value`,
153
- };
154
- }
155
- });
156
- /**
157
- * Asserts that a Set has a specific size.
158
- *
159
- * @example
160
- *
161
- * ```ts
162
- * const set = new Set(['a', 'b']);
163
- * expect(set, 'to have size', 2); // passes
164
- * expect(set, 'to have size', 3); // fails
165
- * ```
166
- *
167
- * @group Collection Assertions
168
- * @bupkisAnchor set-to-have-size-nonnegative-integer
169
- * @bupkisAssertionCategory collections
170
- */
171
- exports.setSizeAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to have size', schema_js_1.NonNegativeIntegerSchema], (_subject, expectedSize) => zod_1.z
172
- .set(zod_1.z.unknown())
173
- .min(expectedSize, { error: `Expected Set to have size ${expectedSize}` })
174
- .max(expectedSize, {
175
- error: `Expected Set to have size ${expectedSize}`,
176
- }));
177
- /**
178
- * Asserts that a Set is empty.
179
- *
180
- * @example
181
- *
182
- * ```ts
183
- * expect(new Set(), 'to be empty'); // passes
184
- * expect(new Set(['value']), 'to be empty'); // fails
185
- * ```
186
- *
187
- * @group Collection Assertions
188
- * @bupkisAnchor set-to-be-empty
189
- * @bupkisAssertionCategory collections
190
- */
191
- exports.emptySetAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to be empty'], schema_js_1.SetSchema.refine(({ size }) => size === 0, {
192
- error: 'Expected Set to be empty',
193
- }));
194
- /**
195
- * Asserts that an array contains a specific value.
196
- *
197
- * @example
198
- *
199
- * ```ts
200
- * expect([1, 2, 3], 'to contain', 2); // passes
201
- * expect([1, 2, 3], 'to contain', 4); // fails
202
- * ```
203
- *
204
- * @group Collection Assertions
205
- * @bupkisAnchor array-to-contain-any
206
- * @bupkisAssertionCategory collections
207
- */
208
- exports.arrayContainsAssertion = (0, create_js_1.createAssertion)([schema_js_1.UnknownArraySchema, ['to contain', 'to include'], schema_js_1.UnknownSchema], (subject, value) => {
209
- if (!subject.includes(value)) {
210
- return {
211
- message: `Expected array to contain value`,
212
- };
213
- }
214
- });
215
- /**
216
- * Asserts that an array contains an item that satisfies a given shape or
217
- * pattern. Uses partial matching semantics - the item only needs to match the
218
- * specified properties.
219
- *
220
- * @example
221
- *
222
- * ```ts
223
- * expect([{ a: 1, b: 2 }, { c: 3 }], 'to have item satisfying', { a: 1 }); // passes
224
- * expect([{ a: 1 }, { b: 2 }], 'to have an item satisfying', { c: 3 }); // fails
225
- * expect([1, 2, 3], 'to contain item satisfying', 2); // passes (exact match)
226
- * ```
227
- *
228
- * @group Collection Assertions
229
- * @bupkisAnchor array-to-have-item-satisfying
230
- * @bupkisAssertionCategory collections
231
- */
232
- exports.arrayItemSatisfiesAssertion = (0, create_js_1.createAssertion)([
233
- schema_js_1.UnknownArraySchema,
234
- [
235
- 'to have item satisfying',
236
- 'to have an item satisfying',
237
- 'to contain item satisfying',
238
- ],
239
- schema_js_1.UnknownSchema,
240
- ], (subject, shape) => {
241
- const schema = (0, value_to_schema_js_1.valueToSchema)(shape, value_to_schema_js_1.valueToSchemaOptionsForSatisfies);
242
- for (const item of subject) {
243
- const result = schema.safeParse(item);
244
- if (result.success) {
245
- return;
246
- }
247
- }
248
- return {
249
- message: `Expected array to contain an item satisfying the given shape`,
250
- };
251
- });
252
- /**
253
- * Asserts that an array has a specific size.
254
- *
255
- * @example
256
- *
257
- * ```ts
258
- * expect([1, 2, 3], 'to have length', 3); // passes
259
- * expect([1, 2, 3], 'to have size', 2); // fails
260
- * ```
261
- *
262
- * @group Collection Assertions
263
- * @bupkisAnchor array-to-have-size-nonnegative-integer
264
- * @bupkisAssertionCategory collections
265
- */
266
- exports.arraySizeAssertion = (0, create_js_1.createAssertion)([
267
- schema_js_1.UnknownArraySchema,
268
- ['to have length', 'to have size'],
269
- schema_js_1.NonNegativeIntegerSchema,
270
- ], (_subject, expectedSize) => schema_js_1.UnknownArraySchema.min(expectedSize, {
271
- error: `Expected array to have size ${expectedSize}}`,
272
- }).max(expectedSize, {
273
- error: `Expected array to have size ${expectedSize}}`,
274
- }));
275
- /**
276
- * Asserts that an array is non-empty.
277
- *
278
- * @example
279
- *
280
- * ```ts
281
- * expect([1, 2, 3], 'to be non-empty'); // passes
282
- * expect([], 'to be non-empty'); // fails
283
- * ```
284
- *
285
- * @group Collection Assertions
286
- * @bupkisAnchor array-not-to-be-empty
287
- * @bupkisAssertionCategory collections
288
- */
289
- 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' }));
290
- /**
291
- * Asserts that an object has specific keys/properties.
292
- *
293
- * @example
294
- *
295
- * ```ts
296
- * expect({ a: 1, b: 2 }, 'to have keys', 'a', 'b'); // passes
297
- * expect({ a: 1 }, 'to have keys', 'a', 'b'); // fails
298
- * ```
299
- *
300
- * @group Collection Assertions
301
- * @bupkisAnchor object-to-have-keys-array
302
- * @bupkisAssertionCategory object
303
- */
304
- // TODO support keypaths, maybe.
305
- // TODO support `undefined` values (will require moving away from Zod schema)
306
- exports.objectKeysAssertion = (0, create_js_1.createAssertion)([
307
- schema_js_1.NonCollectionObjectSchema,
308
- [
309
- 'to have keys',
310
- 'to have properties',
311
- 'to have props',
312
- 'to contain keys',
313
- 'to contain properties',
314
- 'to contain props',
315
- 'to include keys',
316
- 'to include properties',
317
- 'to include props',
318
- ],
319
- zod_1.z.array(schema_js_1.PropertyKeySchema).nonempty(),
320
- ], (_subject, keys) => schema_js_1.NonCollectionObjectSchema.superRefine((subject, ctx) => {
321
- // iterate thru keys and add an issue for each missing
322
- for (const k of keys) {
323
- if (!hasOwn(subject, k)) {
324
- ctx.addIssue({
325
- code: 'custom',
326
- input: subject,
327
- message: `Expected object to contain key "${String(k)}"`,
328
- params: { bupkisType: 'missing_key' },
329
- });
330
- }
331
- }
332
- }));
333
- /**
334
- * Asserts that an object has a property at the specified keypath using dot or
335
- * bracket notation. Uses the `has()` function to traverse nested properties and
336
- * supports complex keypaths like 'foo.bar[0]["baz"]'.
337
- *
338
- * This assertion supports:
339
- *
340
- * - Dot notation: 'prop.nested'
341
- * - Bracket notation with numbers: 'arr[0]'
342
- * - Bracket notation with quoted strings: 'obj["key"]' or "obj['key']"
343
- * - Mixed notation: 'data.items[1].name'
344
- *
345
- * @example
346
- *
347
- * ```ts
348
- * const obj = {
349
- * foo: { bar: [{ baz: 'value' }] },
350
- * 'kebab-case': 'works',
351
- * };
352
- *
353
- * expect(obj, 'to have key', 'foo.bar'); // passes
354
- * expect(obj, 'to have property', 'foo.bar[0].baz'); // passes
355
- * expect(obj, 'to have prop', 'foo["kebab-case"]'); // passes
356
- * expect(obj, 'to have key', 'nonexistent.path'); // fails
357
- * ```
358
- *
359
- * @group Collection Assertions
360
- * @bupkisAnchor object-to-have-key-string-number-symbol
361
- * @bupkisAssertionCategory object
362
- */
363
- exports.objectKeyAssertion = (0, create_js_1.createAssertion)([
364
- schema_js_1.NonCollectionObjectSchema,
365
- [
366
- 'to have key',
367
- 'to have property',
368
- 'to have prop',
369
- 'to contain key',
370
- 'to contain property',
371
- 'to contain prop',
372
- 'to include key',
373
- 'to include property',
374
- 'to include prop',
375
- ],
376
- schema_js_1.KeypathSchema,
377
- ], (subject, keypath) => {
378
- const result = (0, util_js_1.has)(subject, keypath);
379
- if (!result) {
380
- return {
381
- actual: 'no such keypath',
382
- expect: `to have keypath ${keypath}`,
383
- message: `Expected object to contain keypath ${keypath}`,
384
- };
385
- }
386
- });
387
- /**
388
- * Asserts that an object has an exact property key without keypath traversal.
389
- * This assertion checks for direct properties on the object and supports
390
- * symbols and keys that would conflict with bracket/dot notation.
391
- *
392
- * Unlike `objectKeyAssertion`, this does not use the `has()` function and
393
- * therefore:
394
- *
395
- * - Does not support keypath traversal (no dots or brackets)
396
- * - Can check for symbol keys
397
- * - Can check for keys containing dots, brackets, or other special characters
398
- * - Only checks direct properties (no nested access)
399
- *
400
- * @example
401
- *
402
- * ```ts
403
- * const sym = Symbol('test');
404
- * const obj = {
405
- * simple: 'value',
406
- * 'key.with.dots': 'direct property',
407
- * 'key[with]brackets': 'another direct property',
408
- * [sym]: 'symbol value',
409
- * };
410
- *
411
- * expect(obj, 'to have exact key', 'simple'); // passes
412
- * expect(obj, 'to have exact property', 'key.with.dots'); // passes (literal key)
413
- * expect(obj, 'to have exact prop', 'key[with]brackets'); // passes (literal key)
414
- * expect(obj, 'to have exact key', sym); // passes (symbol key)
415
- *
416
- * // These would fail because they're not direct properties:
417
- * expect(obj, 'to have exact key', 'nested.path'); // fails (no keypath traversal)
418
- * ```
419
- *
420
- * @group Collection Assertions
421
- * @bupkisAnchor object-to-have-only-keys-array
422
- * @bupkisAssertionCategory object
423
- */
424
- exports.objectExactKeyAssertion = (0, create_js_1.createAssertion)([
425
- schema_js_1.NonCollectionObjectSchema,
426
- ['to have exact key', 'to have exact property', 'to have exact prop'],
427
- schema_js_1.PropertyKeySchema,
428
- ], (_, key) => schema_js_1.NonCollectionObjectSchema.transform((v) => ({ ...v })).refine((value) => hasOwn(value, key), { error: `Expected object to have own exact key "${String(key)}"` }));
429
- /**
430
- * Asserts that an object has a specific number of keys.
431
- *
432
- * @example
433
- *
434
- * ```ts
435
- * expect({ a: 1, b: 2 }, 'to have size', 2); // passes
436
- * expect({ a: 1 }, 'to have size', 2); // fails
437
- * ```
438
- *
439
- * @group Collection Assertions
440
- * @bupkisAnchor unknown-to-be-an-object
441
- * @bupkisAssertionCategory object
442
- */
443
- exports.objectSizeAssertion = (0, create_js_1.createAssertion)([schema_js_1.UnknownRecordSchema, 'to have size', schema_js_1.NonNegativeIntegerSchema], (subject, expectedSize) => {
444
- const actual = keys(subject).length;
445
- if (actual !== expectedSize) {
446
- return {
447
- actual,
448
- expected: expectedSize,
449
- message: `Expected object to have ${expectedSize} keys, but it has ${actual} keys`,
450
- };
451
- }
452
- });
453
- /**
454
- * Asserts that two Sets are equal (same elements, order-independent).
455
- *
456
- * @example
457
- *
458
- * ```ts
459
- * expect(new Set([1, 2]), 'to equal', new Set([2, 1])); // passes
460
- * expect(new Set([1, 2]), 'to equal', new Set([1, 3])); // fails
461
- * ```
462
- *
463
- * @group Collection Assertions
464
- * @bupkisAnchor set-to-equal-set
465
- * @bupkisAssertionCategory collections
466
- */
467
- exports.setEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.SetSchema, 'to equal', schema_js_1.SetSchema], (actual, expected) => {
468
- return actual.size === expected.size && (0, set_prototype_issubsetof_1.default)(actual, expected);
469
- });
470
- /**
471
- * Asserts that one Set is a subset of another.
472
- *
473
- * @example
474
- *
475
- * ```ts
476
- * expect(new Set([1, 2]), 'to be a subset of', new Set([1, 2, 3])); // passes
477
- * expect(new Set([1, 4]), 'to be a subset of', new Set([1, 2, 3])); // fails
478
- * ```
479
- *
480
- * @group Collection Assertions
481
- * @bupkisAnchor set-to-be-a-subset-of-set
482
- * @bupkisAssertionCategory collections
483
- */
484
- 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));
485
- /**
486
- * Asserts that one Set is a superset of another.
487
- *
488
- * @example
489
- *
490
- * ```ts
491
- * expect(new Set([1, 2, 3]), 'to be a superset of', new Set([1, 2])); // passes
492
- * expect(new Set([1, 2]), 'to be a superset of', new Set([1, 2, 3])); // fails
493
- * ```
494
- *
495
- * @group Collection Assertions
496
- * @bupkisAnchor set-to-be-a-superset-of-set
497
- * @bupkisAssertionCategory collections
498
- */
499
- 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));
500
- /**
501
- * Asserts that two Sets intersect (have common elements).
502
- *
503
- * @example
504
- *
505
- * ```ts
506
- * expect(new Set([1, 2]), 'to intersect with', new Set([2, 3])); // passes
507
- * expect(new Set([1, 2]), 'to intersect with', new Set([3, 4])); // fails
508
- * ```
509
- *
510
- * @group Collection Assertions
511
- * @bupkisAnchor set-to-have-intersection-with-set-satisfying-any
512
- * @bupkisAssertionCategory collections
513
- */
514
- 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));
515
- /**
516
- * Asserts that two Sets are disjoint (have no common elements).
517
- *
518
- * @example
519
- *
520
- * ```ts
521
- * expect(new Set([1, 2]), 'to be disjoint from', new Set([3, 4])); // passes
522
- * expect(new Set([1, 2]), 'to be disjoint from', new Set([2, 3])); // fails
523
- * ```
524
- *
525
- * @group Collection Assertions
526
- * @bupkisAnchor set-to-be-disjoint-from-set
527
- * @bupkisAssertionCategory collections
528
- */
529
- 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));
530
- /**
531
- * Asserts that the union of two Sets equals a third Set.
532
- *
533
- * @example
534
- *
535
- * ```ts
536
- * expect(
537
- * new Set([1, 2]),
538
- * 'to have union',
539
- * new Set([3]),
540
- * 'equal to',
541
- * new Set([1, 2, 3]),
542
- * ); // passes
543
- * ```
544
- *
545
- * @group Collection Assertions
546
- * @bupkisAnchor set-union-with-set-to-equal-set
547
- * @bupkisAssertionCategory collections
548
- */
549
- 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) => {
550
- const result = (0, set_prototype_union_1.default)(setA, setB);
551
- return (result.size === expected.size &&
552
- (0, set_prototype_issubsetof_1.default)(result, expected) &&
553
- (0, set_prototype_issubsetof_1.default)(expected, result));
554
- });
555
- /**
556
- * Asserts that the intersection of two Sets equals a third Set.
557
- *
558
- * @example
559
- *
560
- * ```ts
561
- * expect(
562
- * new Set([1, 2, 3]),
563
- * 'to have intersection',
564
- * new Set([2, 3, 4]),
565
- * 'equal to',
566
- * new Set([2, 3]),
567
- * ); // passes
568
- * ```
569
- *
570
- * @group Collection Assertions
571
- * @bupkisAnchor set-intersection-with-set-to-equal-set
572
- * @bupkisAssertionCategory collections
573
- */
574
- 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) => {
575
- const result = (0, set_prototype_intersection_1.default)(setA, setB);
576
- return (result.size === expected.size &&
577
- (0, set_prototype_issubsetof_1.default)(result, expected) &&
578
- (0, set_prototype_issubsetof_1.default)(expected, result));
579
- });
580
- /**
581
- * Asserts that the difference between two Sets equals a third Set.
582
- *
583
- * @example
584
- *
585
- * ```ts
586
- * expect(
587
- * new Set([1, 2, 3]),
588
- * 'to have difference',
589
- * new Set([2, 4]),
590
- * 'equal to',
591
- * new Set([1, 3]),
592
- * ); // passes
593
- * ```
594
- *
595
- * @group Collection Assertions
596
- * @bupkisAnchor set-difference-with-set-to-equal-set
597
- * @bupkisAssertionCategory collections
598
- */
599
- 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) => {
600
- const result = (0, set_prototype_difference_1.default)(setA, setB);
601
- return (result.size === expected.size &&
602
- (0, set_prototype_issubsetof_1.default)(result, expected) &&
603
- (0, set_prototype_issubsetof_1.default)(expected, result));
604
- });
605
- /**
606
- * Asserts that the symmetric difference between two Sets equals a third Set.
607
- *
608
- * @example
609
- *
610
- * ```ts
611
- * expect(
612
- * new Set([1, 2]),
613
- * 'to have symmetric difference',
614
- * new Set([2, 3]),
615
- * 'equal to',
616
- * new Set([1, 3]),
617
- * ); // passes
618
- * ```
619
- *
620
- * @group Collection Assertions
621
- * @bupkisAnchor set-symmetric-difference-with-set-to-equal-set
622
- * @bupkisAssertionCategory collections
623
- */
624
- 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) => {
625
- const result = (0, set_prototype_symmetricdifference_1.default)(setA, setB);
626
- return (result.size === expected.size &&
627
- (0, set_prototype_issubsetof_1.default)(result, expected) &&
628
- (0, set_prototype_issubsetof_1.default)(expected, result));
629
- });
630
- /**
631
- * Asserts that a Map has a specific key.
632
- *
633
- * @example
634
- *
635
- * ```ts
636
- * const map = new Map([['key', 'value']]);
637
- * expect(map, 'to have key', 'key'); // passes
638
- * expect(map, 'to have key', 'missing'); // fails
639
- * ```
640
- *
641
- * @group Collection Assertions
642
- * @bupkisAnchor map-to-have-key-any
643
- * @bupkisAssertionCategory collections
644
- */
645
- exports.mapKeyAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to have key', schema_js_1.UnknownSchema], (map, key) => {
646
- if (!map.has(key)) {
647
- return {
648
- actual: [...map.keys()],
649
- expected: [...map.keys(), key],
650
- message: 'Expected Map to have key',
651
- };
652
- }
653
- });
654
- /**
655
- * Asserts that a Map contains a specific value.
656
- *
657
- * @example
658
- *
659
- * ```ts
660
- * const map = new Map([['key', 'value']]);
661
- * expect(map, 'to have value', 'value'); // passes
662
- * expect(map, 'to have value', 'missing'); // fails
663
- * ```
664
- *
665
- * @group Collection Assertions
666
- * @bupkisAnchor map-to-have-value-any
667
- * @bupkisAssertionCategory collections
668
- */
669
- exports.mapValueAssertion = (0, create_js_1.createAssertion)([
670
- schema_js_1.MapSchema,
671
- ['to have value', 'to contain value', 'to include value'],
672
- schema_js_1.UnknownSchema,
673
- ], (map, value) => {
674
- for (const mapValue of map.values()) {
675
- if (mapValue === value) {
676
- return;
677
- }
678
- }
679
- return {
680
- actual: [...map.values()],
681
- expected: value,
682
- message: `Expected Map to have value`,
683
- };
684
- });
685
- /**
686
- * Asserts that a Map has a specific key-value entry.
687
- *
688
- * @example
689
- *
690
- * ```ts
691
- * const map = new Map([['key', 'value']]);
692
- * expect(map, 'to have entry', ['key', 'value']); // passes
693
- * expect(map, 'to have entry', ['key', 'wrong']); // fails
694
- * ```
695
- *
696
- * @group Collection Assertions
697
- * @bupkisAnchor map-to-have-entry-any-any
698
- * @bupkisAssertionCategory collections
699
- */
700
- exports.mapEntryAssertion = (0, create_js_1.createAssertion)([
701
- schema_js_1.AnyMapSchema,
702
- [
703
- 'to have entry',
704
- 'to have key/value pair',
705
- 'to contain entry',
706
- 'to contain key/value pair',
707
- 'to include entry',
708
- 'to include key/value pair',
709
- ],
710
- zod_1.z.tuple([schema_js_1.UnknownSchema, schema_js_1.UnknownSchema]),
711
- ], (map, [key, value]) => {
712
- // WeakMap operations only work with object or symbol keys
713
- if (map instanceof WeakMap && !(0, guards_js_1.isWeakKey)(key)) {
714
- return {
715
- message: `WeakMap keys must be objects or symbols, got ${typeof key}`,
716
- };
717
- }
718
- // At this point, if it's a WeakMap, we know key is a WeakKey
719
- const actualValue = map instanceof WeakMap ? map.get(key) : map.get(key);
720
- if (actualValue === value) {
721
- return;
722
- }
723
- const hasKey = map instanceof WeakMap ? map.has(key) : map.has(key);
724
- return {
725
- actual: hasKey ? [key, actualValue] : undefined,
726
- expected: [key, value],
727
- message: hasKey
728
- ? `Expected ${map.constructor.name} entry [${String(key)}, ${String(actualValue)}] to equal [${String(key)}, ${String(value)}]`
729
- : `Expected ${map.constructor.name} to have key ${String(key)}`,
730
- };
731
- });
732
- /**
733
- * Asserts that two Maps are equal (same key-value pairs, order-independent).
734
- *
735
- * @example
736
- *
737
- * ```ts
738
- * const map1 = new Map([
739
- * ['a', 1],
740
- * ['b', 2],
741
- * ]);
742
- * const map2 = new Map([
743
- * ['b', 2],
744
- * ['a', 1],
745
- * ]);
746
- * expect(map1, 'to equal', map2); // passes
747
- * ```
748
- *
749
- * @group Collection Assertions
750
- * @bupkisAnchor map-to-equal-map
751
- * @bupkisAssertionCategory collections
752
- */
753
- exports.mapEqualityAssertion = (0, create_js_1.createAssertion)([schema_js_1.MapSchema, 'to equal', schema_js_1.MapSchema], (mapA, mapB) => {
754
- if (mapA.size !== mapB.size) {
755
- return {
756
- actual: mapA.size,
757
- expected: mapB.size,
758
- message: `Expected Maps to have equal sizes, got ${mapA.size} and ${mapB.size}`,
759
- };
760
- }
761
- for (const [key, value] of mapA) {
762
- if (!mapB.has(key)) {
763
- return {
764
- message: `Expected second Map to contain key ${String(key)}`,
765
- };
766
- }
767
- if (mapB.get(key) !== value) {
768
- return {
769
- actual: [key, mapB.get(key)],
770
- expected: [key, value],
771
- message: `Expected Maps to have equal value for key ${String(key)}`,
772
- };
773
- }
774
- }
775
- });
776
- /**
777
- * Asserts that a collection (Map or Set) has a size greater than a threshold.
778
- *
779
- * @example
780
- *
781
- * ```ts
782
- * expect(new Set([1, 2, 3]), 'to have size greater than', 2); // passes
783
- * expect(new Set([1]), 'to have size greater than', 2); // fails
784
- * ```
785
- *
786
- * @group Collection Assertions
787
- * @bupkisAnchor collection-to-have-size-greater-than-nonnegative-integer
788
- * @bupkisAssertionCategory collections
789
- */
790
- exports.collectionSizeGreaterThanAssertion = (0, create_js_1.createAssertion)([
791
- zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema]),
792
- 'to have size greater than',
793
- schema_js_1.NonNegativeIntegerSchema,
794
- ], (collection, minSize) => {
795
- if (collection.size <= minSize) {
796
- return {
797
- actual: collection.size,
798
- expected: minSize,
799
- message: `Expected ${collection.constructor.name} to have size greater than ${minSize}, got ${collection.size}`,
800
- };
801
- }
802
- });
803
- /**
804
- * Asserts that a collection (Map or Set) has a size less than a threshold.
805
- *
806
- * @example
807
- *
808
- * ```ts
809
- * expect(new Set([1]), 'to have size less than', 2); // passes
810
- * expect(new Set([1, 2, 3]), 'to have size less than', 2); // fails
811
- * ```
812
- *
813
- * @group Collection Assertions
814
- * @bupkisAnchor collection-to-have-size-less-than-nonnegative-integer
815
- * @bupkisAssertionCategory collections
816
- */
817
- exports.collectionSizeLessThanAssertion = (0, create_js_1.createAssertion)([
818
- zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema]),
819
- 'to have size less than',
820
- schema_js_1.NonNegativeIntegerSchema,
821
- ], (collection, maxSize) => {
822
- if (collection.size >= maxSize) {
823
- return {
824
- actual: collection.size,
825
- expected: maxSize,
826
- message: `Expected ${collection.constructor.name} to have size less than ${maxSize}, got ${collection.size}`,
827
- };
828
- }
829
- });
830
- /**
831
- * Asserts that a collection (Map or Set) has a size within a specific range.
832
- *
833
- * @example
834
- *
835
- * ```ts
836
- * expect(new Set([1, 2]), 'to have size between', [1, 3]); // passes
837
- * expect(new Set([1, 2, 3, 4]), 'to have size between', [1, 3]); // fails
838
- * ```
839
- *
840
- * @group Collection Assertions
841
- * @bupkisAnchor collection-to-have-size-between-nonnegative-integer-and-nonnegative-integer
842
- * @bupkisAssertionCategory collections
843
- */
844
- exports.collectionSizeBetweenAssertion = (0, create_js_1.createAssertion)([
845
- zod_1.z.union([schema_js_1.MapSchema, schema_js_1.SetSchema]),
846
- 'to have size between',
847
- zod_1.z.tuple([schema_js_1.NonNegativeIntegerSchema, schema_js_1.NonNegativeIntegerSchema]),
848
- ], (collection, [min, max]) => {
849
- const size = collection.size;
850
- if (!(size >= min && size <= max)) {
851
- return {
852
- message: `Expected ${collection.constructor.name} to have size between ${min} and ${max}, got ${size}`,
853
- };
854
- }
855
- });
856
- //# sourceMappingURL=sync-collection.js.map