lay-sing 0.2.1 → 0.4.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 (340) hide show
  1. package/README.md +31 -35
  2. package/esm/main/expect/index.d.ts +31 -0
  3. package/esm/main/expect/index.d.ts.map +1 -0
  4. package/esm/main/expect/index.js +2 -0
  5. package/esm/main/expect/index.js.map +1 -0
  6. package/esm/main/expect/to/be.d.ts +23 -0
  7. package/esm/main/expect/to/be.d.ts.map +1 -0
  8. package/esm/main/expect/to/be.js +2 -0
  9. package/esm/main/expect/to/be.js.map +1 -0
  10. package/esm/main/expect/to/equal.d.ts +26 -0
  11. package/esm/main/expect/to/equal.d.ts.map +1 -0
  12. package/esm/main/expect/to/equal.js +2 -0
  13. package/esm/main/expect/to/equal.js.map +1 -0
  14. package/esm/main/expect/to/extend.d.ts +31 -0
  15. package/esm/main/expect/to/extend.d.ts.map +1 -0
  16. package/esm/main/expect/to/extend.js +2 -0
  17. package/esm/main/expect/to/extend.js.map +1 -0
  18. package/esm/main/expect/to/have-key.d.ts +38 -0
  19. package/esm/main/expect/to/have-key.d.ts.map +1 -0
  20. package/esm/main/expect/to/have-key.js +2 -0
  21. package/esm/main/expect/to/have-key.js.map +1 -0
  22. package/esm/main/expect/to/index.d.ts +13 -0
  23. package/esm/main/expect/to/index.d.ts.map +1 -0
  24. package/esm/main/expect/to/index.js +2 -0
  25. package/esm/main/expect/to/index.js.map +1 -0
  26. package/esm/main/expect/to/proper-extends.d.ts +21 -0
  27. package/esm/main/expect/to/proper-extends.d.ts.map +1 -0
  28. package/esm/main/expect/to/proper-extends.js +2 -0
  29. package/esm/main/expect/to/proper-extends.js.map +1 -0
  30. package/esm/main/index.d.ts +26 -11
  31. package/esm/main/index.d.ts.map +1 -1
  32. package/esm/main/index.js +22 -13
  33. package/esm/main/index.js.map +1 -1
  34. package/esm/main/noop.d.ts +27 -0
  35. package/esm/main/noop.d.ts.map +1 -0
  36. package/esm/{test-utils/index.js → main/noop.js} +1 -12
  37. package/esm/main/noop.js.map +1 -0
  38. package/esm/utils/compare/assignable.d.ts +30 -0
  39. package/esm/utils/compare/assignable.d.ts.map +1 -0
  40. package/esm/utils/compare/assignable.js +2 -0
  41. package/esm/utils/compare/assignable.js.map +1 -0
  42. package/esm/utils/compare/exact.d.ts +50 -0
  43. package/esm/utils/compare/exact.d.ts.map +1 -0
  44. package/esm/utils/compare/exact.js +2 -0
  45. package/esm/utils/compare/exact.js.map +1 -0
  46. package/esm/utils/compare/extends.d.ts +46 -0
  47. package/esm/utils/compare/extends.d.ts.map +1 -0
  48. package/esm/utils/compare/extends.js +2 -0
  49. package/esm/utils/compare/extends.js.map +1 -0
  50. package/esm/utils/compare/index.d.ts +5 -0
  51. package/esm/utils/compare/index.d.ts.map +1 -0
  52. package/esm/utils/compare/index.js +7 -0
  53. package/esm/utils/compare/index.js.map +1 -0
  54. package/esm/utils/compare/overlap.d.ts +47 -0
  55. package/esm/utils/compare/overlap.d.ts.map +1 -0
  56. package/esm/utils/compare/overlap.js +2 -0
  57. package/esm/utils/compare/overlap.js.map +1 -0
  58. package/esm/utils/index.d.ts +11 -0
  59. package/esm/utils/index.d.ts.map +1 -0
  60. package/esm/utils/index.js +13 -0
  61. package/esm/utils/index.js.map +1 -0
  62. package/esm/utils/logic/assert.d.ts +18 -0
  63. package/esm/utils/logic/assert.d.ts.map +1 -0
  64. package/esm/utils/logic/assert.js +2 -0
  65. package/esm/utils/logic/assert.js.map +1 -0
  66. package/esm/utils/logic/if.d.ts +37 -0
  67. package/esm/utils/logic/if.d.ts.map +1 -0
  68. package/esm/utils/logic/if.js +2 -0
  69. package/esm/utils/logic/if.js.map +1 -0
  70. package/esm/utils/logic/index.d.ts +4 -0
  71. package/esm/utils/logic/index.d.ts.map +1 -0
  72. package/esm/utils/logic/index.js +6 -0
  73. package/esm/utils/logic/index.js.map +1 -0
  74. package/{script/main/control.d.ts → esm/utils/logic/switch.d.ts} +15 -40
  75. package/esm/utils/logic/switch.d.ts.map +1 -0
  76. package/esm/utils/logic/switch.js +2 -0
  77. package/esm/utils/logic/switch.js.map +1 -0
  78. package/esm/utils/misc.d.ts +34 -0
  79. package/esm/utils/misc.d.ts.map +1 -0
  80. package/esm/utils/misc.js +2 -0
  81. package/esm/utils/misc.js.map +1 -0
  82. package/esm/utils/object/index.d.ts +4 -0
  83. package/esm/utils/object/index.d.ts.map +1 -0
  84. package/esm/utils/object/index.js +6 -0
  85. package/esm/utils/object/index.js.map +1 -0
  86. package/{script/main/key.d.ts → esm/utils/object/keys.d.ts} +34 -34
  87. package/esm/utils/object/keys.d.ts.map +1 -0
  88. package/esm/utils/object/keys.js +2 -0
  89. package/esm/utils/object/keys.js.map +1 -0
  90. package/esm/utils/object/pick.d.ts +16 -0
  91. package/esm/utils/object/pick.d.ts.map +1 -0
  92. package/esm/utils/object/pick.js +2 -0
  93. package/esm/utils/object/pick.js.map +1 -0
  94. package/esm/utils/object/props.d.ts +17 -0
  95. package/esm/utils/object/props.d.ts.map +1 -0
  96. package/esm/utils/object/props.js +2 -0
  97. package/esm/utils/object/props.js.map +1 -0
  98. package/esm/utils/tuple/append.d.ts +17 -0
  99. package/esm/utils/tuple/append.d.ts.map +1 -0
  100. package/esm/utils/tuple/append.js +2 -0
  101. package/esm/utils/tuple/append.js.map +1 -0
  102. package/esm/utils/tuple/concat.d.ts +31 -0
  103. package/esm/utils/tuple/concat.d.ts.map +1 -0
  104. package/esm/utils/tuple/concat.js +2 -0
  105. package/esm/utils/tuple/concat.js.map +1 -0
  106. package/esm/utils/tuple/includes.d.ts +20 -0
  107. package/esm/utils/tuple/includes.d.ts.map +1 -0
  108. package/esm/utils/tuple/includes.js +2 -0
  109. package/esm/utils/tuple/includes.js.map +1 -0
  110. package/esm/utils/tuple/index.d.ts +4 -0
  111. package/esm/utils/tuple/index.d.ts.map +1 -0
  112. package/esm/utils/tuple/index.js +6 -0
  113. package/esm/utils/tuple/index.js.map +1 -0
  114. package/package.json +5 -5
  115. package/script/main/expect/index.d.ts +31 -0
  116. package/script/main/expect/index.d.ts.map +1 -0
  117. package/script/main/{async.js → expect/index.js} +1 -1
  118. package/script/main/expect/index.js.map +1 -0
  119. package/script/main/expect/to/be.d.ts +23 -0
  120. package/script/main/expect/to/be.d.ts.map +1 -0
  121. package/script/main/{type/set.js → expect/to/be.js} +1 -1
  122. package/script/main/expect/to/be.js.map +1 -0
  123. package/script/main/expect/to/equal.d.ts +26 -0
  124. package/script/main/expect/to/equal.d.ts.map +1 -0
  125. package/script/main/expect/to/equal.js +3 -0
  126. package/script/main/expect/to/equal.js.map +1 -0
  127. package/script/main/expect/to/extend.d.ts +31 -0
  128. package/script/main/expect/to/extend.d.ts.map +1 -0
  129. package/script/main/expect/to/extend.js +3 -0
  130. package/script/main/expect/to/extend.js.map +1 -0
  131. package/script/main/expect/to/have-key.d.ts +38 -0
  132. package/script/main/expect/to/have-key.d.ts.map +1 -0
  133. package/script/main/expect/to/have-key.js +3 -0
  134. package/script/main/expect/to/have-key.js.map +1 -0
  135. package/script/main/expect/to/index.d.ts +13 -0
  136. package/script/main/expect/to/index.d.ts.map +1 -0
  137. package/script/main/expect/to/index.js +3 -0
  138. package/script/main/expect/to/index.js.map +1 -0
  139. package/script/main/expect/to/proper-extends.d.ts +21 -0
  140. package/script/main/expect/to/proper-extends.d.ts.map +1 -0
  141. package/script/main/expect/to/proper-extends.js +3 -0
  142. package/script/main/expect/to/proper-extends.js.map +1 -0
  143. package/script/main/index.d.ts +26 -11
  144. package/script/main/index.d.ts.map +1 -1
  145. package/script/main/index.js +24 -27
  146. package/script/main/index.js.map +1 -1
  147. package/script/main/noop.d.ts +27 -0
  148. package/script/main/noop.d.ts.map +1 -0
  149. package/script/{test-utils/index.js → main/noop.js} +1 -14
  150. package/script/main/noop.js.map +1 -0
  151. package/script/utils/compare/assignable.d.ts +30 -0
  152. package/script/utils/compare/assignable.d.ts.map +1 -0
  153. package/script/utils/compare/assignable.js +3 -0
  154. package/script/utils/compare/assignable.js.map +1 -0
  155. package/script/utils/compare/exact.d.ts +50 -0
  156. package/script/utils/compare/exact.d.ts.map +1 -0
  157. package/script/utils/compare/exact.js +3 -0
  158. package/script/utils/compare/exact.js.map +1 -0
  159. package/script/utils/compare/extends.d.ts +46 -0
  160. package/script/utils/compare/extends.d.ts.map +1 -0
  161. package/script/{main/boolean.js → utils/compare/extends.js} +1 -1
  162. package/script/utils/compare/extends.js.map +1 -0
  163. package/script/utils/compare/index.d.ts +5 -0
  164. package/script/utils/compare/index.d.ts.map +1 -0
  165. package/script/utils/compare/index.js +23 -0
  166. package/script/utils/compare/index.js.map +1 -0
  167. package/script/utils/compare/overlap.d.ts +47 -0
  168. package/script/utils/compare/overlap.d.ts.map +1 -0
  169. package/script/{main/control.js → utils/compare/overlap.js} +1 -1
  170. package/script/utils/compare/overlap.js.map +1 -0
  171. package/script/utils/index.d.ts +11 -0
  172. package/script/utils/index.d.ts.map +1 -0
  173. package/script/utils/index.js +29 -0
  174. package/script/utils/index.js.map +1 -0
  175. package/script/utils/logic/assert.d.ts +18 -0
  176. package/script/utils/logic/assert.d.ts.map +1 -0
  177. package/script/utils/logic/assert.js +3 -0
  178. package/script/utils/logic/assert.js.map +1 -0
  179. package/script/utils/logic/if.d.ts +37 -0
  180. package/script/utils/logic/if.d.ts.map +1 -0
  181. package/script/{main/key.js → utils/logic/if.js} +1 -1
  182. package/script/utils/logic/if.js.map +1 -0
  183. package/script/utils/logic/index.d.ts +4 -0
  184. package/script/utils/logic/index.d.ts.map +1 -0
  185. package/script/utils/logic/index.js +22 -0
  186. package/script/utils/logic/index.js.map +1 -0
  187. package/{esm/main/control.d.ts → script/utils/logic/switch.d.ts} +15 -40
  188. package/script/utils/logic/switch.d.ts.map +1 -0
  189. package/script/utils/logic/switch.js +3 -0
  190. package/script/utils/logic/switch.js.map +1 -0
  191. package/script/utils/misc.d.ts +34 -0
  192. package/script/utils/misc.d.ts.map +1 -0
  193. package/script/{main/json.js → utils/misc.js} +1 -1
  194. package/script/utils/misc.js.map +1 -0
  195. package/script/utils/object/index.d.ts +4 -0
  196. package/script/utils/object/index.d.ts.map +1 -0
  197. package/script/{main/type → utils/object}/index.js +3 -2
  198. package/script/utils/object/index.js.map +1 -0
  199. package/{esm/main/key.d.ts → script/utils/object/keys.d.ts} +34 -34
  200. package/script/utils/object/keys.d.ts.map +1 -0
  201. package/script/{main/doc.js → utils/object/keys.js} +1 -1
  202. package/script/utils/object/keys.js.map +1 -0
  203. package/script/utils/object/pick.d.ts +16 -0
  204. package/script/utils/object/pick.d.ts.map +1 -0
  205. package/script/utils/object/pick.js +3 -0
  206. package/script/utils/object/pick.js.map +1 -0
  207. package/script/utils/object/props.d.ts +17 -0
  208. package/script/utils/object/props.d.ts.map +1 -0
  209. package/script/utils/object/props.js +3 -0
  210. package/script/utils/object/props.js.map +1 -0
  211. package/script/utils/tuple/append.d.ts +17 -0
  212. package/script/utils/tuple/append.d.ts.map +1 -0
  213. package/script/utils/tuple/append.js +3 -0
  214. package/script/utils/tuple/append.js.map +1 -0
  215. package/script/utils/tuple/concat.d.ts +31 -0
  216. package/script/utils/tuple/concat.d.ts.map +1 -0
  217. package/script/utils/tuple/concat.js +3 -0
  218. package/script/utils/tuple/concat.js.map +1 -0
  219. package/script/utils/tuple/includes.d.ts +20 -0
  220. package/script/utils/tuple/includes.d.ts.map +1 -0
  221. package/script/utils/tuple/includes.js +3 -0
  222. package/script/utils/tuple/includes.js.map +1 -0
  223. package/script/utils/tuple/index.d.ts +4 -0
  224. package/script/utils/tuple/index.d.ts.map +1 -0
  225. package/script/utils/tuple/index.js +22 -0
  226. package/script/utils/tuple/index.js.map +1 -0
  227. package/esm/main/async.d.ts +0 -13
  228. package/esm/main/async.d.ts.map +0 -1
  229. package/esm/main/async.js +0 -2
  230. package/esm/main/async.js.map +0 -1
  231. package/esm/main/boolean.d.ts +0 -59
  232. package/esm/main/boolean.d.ts.map +0 -1
  233. package/esm/main/boolean.js +0 -2
  234. package/esm/main/boolean.js.map +0 -1
  235. package/esm/main/control.d.ts.map +0 -1
  236. package/esm/main/control.js +0 -2
  237. package/esm/main/control.js.map +0 -1
  238. package/esm/main/doc.d.ts +0 -56
  239. package/esm/main/doc.d.ts.map +0 -1
  240. package/esm/main/doc.js +0 -2
  241. package/esm/main/doc.js.map +0 -1
  242. package/esm/main/function.d.ts +0 -27
  243. package/esm/main/function.d.ts.map +0 -1
  244. package/esm/main/function.js +0 -2
  245. package/esm/main/function.js.map +0 -1
  246. package/esm/main/json.d.ts +0 -44
  247. package/esm/main/json.d.ts.map +0 -1
  248. package/esm/main/json.js +0 -2
  249. package/esm/main/json.js.map +0 -1
  250. package/esm/main/key.d.ts.map +0 -1
  251. package/esm/main/key.js +0 -2
  252. package/esm/main/key.js.map +0 -1
  253. package/esm/main/object.d.ts +0 -120
  254. package/esm/main/object.d.ts.map +0 -1
  255. package/esm/main/object.js +0 -2
  256. package/esm/main/object.js.map +0 -1
  257. package/esm/main/tuple.d.ts +0 -64
  258. package/esm/main/tuple.d.ts.map +0 -1
  259. package/esm/main/tuple.js +0 -2
  260. package/esm/main/tuple.js.map +0 -1
  261. package/esm/main/type/compare.d.ts +0 -169
  262. package/esm/main/type/compare.d.ts.map +0 -1
  263. package/esm/main/type/compare.js +0 -2
  264. package/esm/main/type/compare.js.map +0 -1
  265. package/esm/main/type/index.d.ts +0 -3
  266. package/esm/main/type/index.d.ts.map +0 -1
  267. package/esm/main/type/index.js +0 -5
  268. package/esm/main/type/index.js.map +0 -1
  269. package/esm/main/type/set.d.ts +0 -34
  270. package/esm/main/type/set.d.ts.map +0 -1
  271. package/esm/main/type/set.js +0 -2
  272. package/esm/main/type/set.js.map +0 -1
  273. package/esm/main/typed-array.d.ts +0 -5
  274. package/esm/main/typed-array.d.ts.map +0 -1
  275. package/esm/main/typed-array.js +0 -2
  276. package/esm/main/typed-array.js.map +0 -1
  277. package/esm/test-utils/compare.d.ts +0 -81
  278. package/esm/test-utils/compare.d.ts.map +0 -1
  279. package/esm/test-utils/compare.js +0 -2
  280. package/esm/test-utils/compare.js.map +0 -1
  281. package/esm/test-utils/expect.d.ts +0 -278
  282. package/esm/test-utils/expect.d.ts.map +0 -1
  283. package/esm/test-utils/expect.js +0 -2
  284. package/esm/test-utils/expect.js.map +0 -1
  285. package/esm/test-utils/index.d.ts +0 -77
  286. package/esm/test-utils/index.d.ts.map +0 -1
  287. package/esm/test-utils/index.js.map +0 -1
  288. package/script/main/async.d.ts +0 -13
  289. package/script/main/async.d.ts.map +0 -1
  290. package/script/main/async.js.map +0 -1
  291. package/script/main/boolean.d.ts +0 -59
  292. package/script/main/boolean.d.ts.map +0 -1
  293. package/script/main/boolean.js.map +0 -1
  294. package/script/main/control.d.ts.map +0 -1
  295. package/script/main/control.js.map +0 -1
  296. package/script/main/doc.d.ts +0 -56
  297. package/script/main/doc.d.ts.map +0 -1
  298. package/script/main/doc.js.map +0 -1
  299. package/script/main/function.d.ts +0 -27
  300. package/script/main/function.d.ts.map +0 -1
  301. package/script/main/function.js +0 -3
  302. package/script/main/function.js.map +0 -1
  303. package/script/main/json.d.ts +0 -44
  304. package/script/main/json.d.ts.map +0 -1
  305. package/script/main/json.js.map +0 -1
  306. package/script/main/key.d.ts.map +0 -1
  307. package/script/main/key.js.map +0 -1
  308. package/script/main/object.d.ts +0 -120
  309. package/script/main/object.d.ts.map +0 -1
  310. package/script/main/object.js +0 -3
  311. package/script/main/object.js.map +0 -1
  312. package/script/main/tuple.d.ts +0 -64
  313. package/script/main/tuple.d.ts.map +0 -1
  314. package/script/main/tuple.js +0 -3
  315. package/script/main/tuple.js.map +0 -1
  316. package/script/main/type/compare.d.ts +0 -169
  317. package/script/main/type/compare.d.ts.map +0 -1
  318. package/script/main/type/compare.js +0 -3
  319. package/script/main/type/compare.js.map +0 -1
  320. package/script/main/type/index.d.ts +0 -3
  321. package/script/main/type/index.d.ts.map +0 -1
  322. package/script/main/type/index.js.map +0 -1
  323. package/script/main/type/set.d.ts +0 -34
  324. package/script/main/type/set.d.ts.map +0 -1
  325. package/script/main/type/set.js.map +0 -1
  326. package/script/main/typed-array.d.ts +0 -5
  327. package/script/main/typed-array.d.ts.map +0 -1
  328. package/script/main/typed-array.js +0 -3
  329. package/script/main/typed-array.js.map +0 -1
  330. package/script/test-utils/compare.d.ts +0 -81
  331. package/script/test-utils/compare.d.ts.map +0 -1
  332. package/script/test-utils/compare.js +0 -3
  333. package/script/test-utils/compare.js.map +0 -1
  334. package/script/test-utils/expect.d.ts +0 -278
  335. package/script/test-utils/expect.d.ts.map +0 -1
  336. package/script/test-utils/expect.js +0 -3
  337. package/script/test-utils/expect.js.map +0 -1
  338. package/script/test-utils/index.d.ts +0 -77
  339. package/script/test-utils/index.d.ts.map +0 -1
  340. package/script/test-utils/index.js.map +0 -1
@@ -1,169 +0,0 @@
1
- /**
2
- * Checks whether two types are exactly the same.
3
- *
4
- * **⚠️Important:** parameter `A` and `B` are not distributive. When they are union type, it does not check each member separately.
5
- *
6
- * @template A - The first type to compare
7
- * @template B - The second type to compare
8
- * @template Yes - The result if types are exactly the same (defaults to `true`)
9
- * @template No - The result if types are not exactly the same (defaults to `false`)
10
- *
11
- * ### Result
12
- *
13
- * - `Yes`: `A` and `B` are exactly the same
14
- * - `No`: Otherwise
15
- *
16
- * @example
17
- * ```ts
18
- * import { expect } from '@leawind/lay-sing/test-utils'
19
- *
20
- * expect<Exact<string, string>>().toBeTrue
21
- * expect<Exact<never, never>>().toBeTrue
22
- * expect<Exact<any, any>>().toBeTrue
23
- *
24
- * expect<Exact<{ a: 3 }, { a?: 3 }>>().toBeFalse
25
- * expect<Exact<1 | 2, 1>>().toBeFalse
26
- * expect<Exact<1, number>>().toBeFalse
27
- * expect<Exact<() => void, () => undefined>>().toBeFalse
28
- * ```
29
- */
30
- export type Exact<A, B, Yes = true, No = false> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? Yes : No;
31
- /**
32
- * Checks whether two types are not exactly the same.
33
- *
34
- * This is the logical negation of `Exact<A, B>`.
35
- *
36
- * @template A - The first type to compare
37
- * @template B - The second type to compare
38
- * @template Yes - The result if types are not exactly the same (defaults to `true`)
39
- * @template No - The result if types are exactly the same (defaults to `false`)
40
- *
41
- * @example
42
- * ```ts
43
- * type T1 = NotExact<number, string> // true
44
- * type T2 = NotExact<1, number> // true
45
- * type F1 = NotExact<number, number> // false
46
- * type F2 = NotExact<1, 1> // false
47
- * ```
48
- */
49
- export type NotExact<A, B, Yes = true, No = false> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? No : Yes;
50
- /**
51
- * Checks whether type `A` extends type `B`.
52
- *
53
- * **⚠️Important:** parameter `A` and `B` are not distributive. When they are union type, it treats them as a single entity.
54
- *
55
- * @template A - The type to check if it extends another type
56
- * @template B - The type to check if `A` extends
57
- * @template Yes - The result if `A` extends `B` (defaults to `true`)
58
- * @template No - The result if `A` does not extend `B` (defaults to `false`)
59
- *
60
- * ### Result
61
- *
62
- * - `Yes`: `A` is assignable to `B`
63
- * - `No`: Otherwise
64
- */
65
- export type Extends<A, B, Yes = true, No = false> = [A] extends [B] ? Yes : No;
66
- /**
67
- * Checks whether type `A` is a *proper* subtype of type `B`.
68
- *
69
- * A proper extension means:
70
- * - `A` extends `B`
71
- * - `A` is not exactly the same type as `B`
72
- *
73
- * @template A - The type to check if it is a proper subtype
74
- * @template B - The type to check against
75
- * @template Yes - The result if `A` is a proper subtype of `B` (defaults to `true`)
76
- * @template No - The result if `A` is not a proper subtype of `B` (defaults to `false`)
77
- *
78
- * ### Result
79
- *
80
- * - `Yes`: `A` is a proper subtype of `B`
81
- * - `No`: Otherwise
82
- *
83
- * **Note:** the result will never be `boolean`.
84
- *
85
- * @example
86
- * ```ts
87
- * type T1 = ProperExtend<true, boolean> // true
88
- * type T2 = ProperExtend<1, number> // true
89
- * type F1 = ProperExtend<boolean, boolean> // false
90
- * type F2 = ProperExtend<number, string> // false
91
- * ```
92
- */
93
- export type ProperExtend<A, B, Yes = true, No = false> = [A] extends [B] ? Exact<A, B> extends false ? Yes : No : No;
94
- /**
95
- * Checks whether two types have any overlapping members.
96
- *
97
- * @template A - The first type to check for overlap
98
- * @template B - The second type to check for overlap
99
- * @template Yes - The result if types overlap (defaults to `true`)
100
- * @template No - The result if types do not overlap (defaults to `false`)
101
- *
102
- * ### Result
103
- *
104
- * - `Yes`: `A` and `B` share at least one common type
105
- * - `No`: `A` and `B` are completely disjoint
106
- *
107
- * @example
108
- * ```ts
109
- * type T1 = Overlap<1 | 2, 2 | 3> // true
110
- * type T2 = Overlap<string, 'hello'> // true
111
- * type F1 = Overlap<string, number> // false
112
- * type F2 = Overlap<1, 'one'> // false
113
- * ```
114
- */
115
- export type Overlap<A, B, Yes = true, No = false> = [A & B] extends [never] ? No : Yes;
116
- /**
117
- * Checks whether two types are disjoint.
118
- *
119
- * This is the logical negation of `Overlap<A, B>`.
120
- *
121
- * @template A - The first type to check for disjointness
122
- * @template B - The second type to check for disjointness
123
- * @template Yes - The result if types are disjoint (defaults to `true`)
124
- * @template No - The result if types are not disjoint (defaults to `false`)
125
- *
126
- * ### Result
127
- *
128
- * - `Yes`: `A` and `B` have no overlap
129
- * - `No`: `A` and `B` share at least one common type
130
- *
131
- * @example
132
- * ```ts
133
- * type T1 = Disjoint<string, number> // true
134
- * type T2 = Disjoint<1, 'one'> // true
135
- * type F1 = Disjoint<1 | 2, 2 | 3> // false
136
- * type F2 = Disjoint<string, 'hello'> // false
137
- * ```
138
- */
139
- export type Disjoint<A, B, Yes = true, No = false> = [A & B] extends [never] ? Yes : No;
140
- /**
141
- * Checks whether two types are mutually assignable.
142
- *
143
- * This is equivalent to checking that:
144
- * - `A` extends `B`
145
- * - `B` extends `A`
146
- *
147
- * In other words, the two types describe the same set of values,
148
- * even if they are written differently.
149
- *
150
- * @template A - The first type to check
151
- * @template B - The second type to check
152
- * @template Yes - The result if types are mutually assignable (defaults to `true`)
153
- * @template No - The result if types are not mutually assignable (defaults to `false`)
154
- *
155
- * ### Result
156
- *
157
- * - `Yes`: `A` and `B` are mutually assignable
158
- * - `No`: Otherwise
159
- *
160
- * @example
161
- * ```ts
162
- * type T1 = MutuallyAssignable<number, number> // true
163
- * type T2 = MutuallyAssignable<1 | 2, 2 | 1> // true
164
- * type F1 = MutuallyAssignable<string, number> // false
165
- * type F2 = MutuallyAssignable<1, number> // false
166
- * ```
167
- */
168
- export type MutuallyAssignable<A, B, Yes = true, No = false> = [A] extends [B] ? [B] extends [A] ? Yes : No : No;
169
- //# sourceMappingURL=compare.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/main/type/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,KAAK,CACf,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA;AAEpF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,QAAQ,CAClB,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAA;AAEpF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,OAAO,CACjB,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,YAAY,CACtB,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,OAAO,CACjB,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,QAAQ,CAClB,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,kBAAkB,CAC5B,CAAC,EACD,CAAC,EACD,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=compare.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../../src/main/type/compare.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Checks whether two types are exactly the same.\n *\n * **⚠️Important:** parameter `A` and `B` are not distributive. When they are union type, it does not check each member separately.\n *\n * @template A - The first type to compare\n * @template B - The second type to compare\n * @template Yes - The result if types are exactly the same (defaults to `true`)\n * @template No - The result if types are not exactly the same (defaults to `false`)\n *\n * ### Result\n *\n * - `Yes`: `A` and `B` are exactly the same\n * - `No`: Otherwise\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<Exact<string, string>>().toBeTrue\n * expect<Exact<never, never>>().toBeTrue\n * expect<Exact<any, any>>().toBeTrue\n *\n * expect<Exact<{ a: 3 }, { a?: 3 }>>().toBeFalse\n * expect<Exact<1 | 2, 1>>().toBeFalse\n * expect<Exact<1, number>>().toBeFalse\n * expect<Exact<() => void, () => undefined>>().toBeFalse\n * ```\n */\nexport type Exact<\n A,\n B,\n Yes = true,\n No = false,\n> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? Yes : No\n\n/**\n * Checks whether two types are not exactly the same.\n *\n * This is the logical negation of `Exact<A, B>`.\n *\n * @template A - The first type to compare\n * @template B - The second type to compare\n * @template Yes - The result if types are not exactly the same (defaults to `true`)\n * @template No - The result if types are exactly the same (defaults to `false`)\n *\n * @example\n * ```ts\n * type T1 = NotExact<number, string> // true\n * type T2 = NotExact<1, number> // true\n * type F1 = NotExact<number, number> // false\n * type F2 = NotExact<1, 1> // false\n * ```\n */\nexport type NotExact<\n A,\n B,\n Yes = true,\n No = false,\n> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? No : Yes\n\n/**\n * Checks whether type `A` extends type `B`.\n *\n * **⚠️Important:** parameter `A` and `B` are not distributive. When they are union type, it treats them as a single entity.\n *\n * @template A - The type to check if it extends another type\n * @template B - The type to check if `A` extends\n * @template Yes - The result if `A` extends `B` (defaults to `true`)\n * @template No - The result if `A` does not extend `B` (defaults to `false`)\n *\n * ### Result\n *\n * - `Yes`: `A` is assignable to `B`\n * - `No`: Otherwise\n */\nexport type Extends<\n A,\n B,\n Yes = true,\n No = false,\n> = [A] extends [B] ? Yes : No\n\n/**\n * Checks whether type `A` is a *proper* subtype of type `B`.\n *\n * A proper extension means:\n * - `A` extends `B`\n * - `A` is not exactly the same type as `B`\n *\n * @template A - The type to check if it is a proper subtype\n * @template B - The type to check against\n * @template Yes - The result if `A` is a proper subtype of `B` (defaults to `true`)\n * @template No - The result if `A` is not a proper subtype of `B` (defaults to `false`)\n *\n * ### Result\n *\n * - `Yes`: `A` is a proper subtype of `B`\n * - `No`: Otherwise\n *\n * **Note:** the result will never be `boolean`.\n *\n * @example\n * ```ts\n * type T1 = ProperExtend<true, boolean> // true\n * type T2 = ProperExtend<1, number> // true\n * type F1 = ProperExtend<boolean, boolean> // false\n * type F2 = ProperExtend<number, string> // false\n * ```\n */\nexport type ProperExtend<\n A,\n B,\n Yes = true,\n No = false,\n> = [A] extends [B] ? Exact<A, B> extends false ? Yes : No : No\n\n/**\n * Checks whether two types have any overlapping members.\n *\n * @template A - The first type to check for overlap\n * @template B - The second type to check for overlap\n * @template Yes - The result if types overlap (defaults to `true`)\n * @template No - The result if types do not overlap (defaults to `false`)\n *\n * ### Result\n *\n * - `Yes`: `A` and `B` share at least one common type\n * - `No`: `A` and `B` are completely disjoint\n *\n * @example\n * ```ts\n * type T1 = Overlap<1 | 2, 2 | 3> // true\n * type T2 = Overlap<string, 'hello'> // true\n * type F1 = Overlap<string, number> // false\n * type F2 = Overlap<1, 'one'> // false\n * ```\n */\nexport type Overlap<\n A,\n B,\n Yes = true,\n No = false,\n> = [A & B] extends [never] ? No : Yes\n\n/**\n * Checks whether two types are disjoint.\n *\n * This is the logical negation of `Overlap<A, B>`.\n *\n * @template A - The first type to check for disjointness\n * @template B - The second type to check for disjointness\n * @template Yes - The result if types are disjoint (defaults to `true`)\n * @template No - The result if types are not disjoint (defaults to `false`)\n *\n * ### Result\n *\n * - `Yes`: `A` and `B` have no overlap\n * - `No`: `A` and `B` share at least one common type\n *\n * @example\n * ```ts\n * type T1 = Disjoint<string, number> // true\n * type T2 = Disjoint<1, 'one'> // true\n * type F1 = Disjoint<1 | 2, 2 | 3> // false\n * type F2 = Disjoint<string, 'hello'> // false\n * ```\n */\nexport type Disjoint<\n A,\n B,\n Yes = true,\n No = false,\n> = [A & B] extends [never] ? Yes : No\n\n/**\n * Checks whether two types are mutually assignable.\n *\n * This is equivalent to checking that:\n * - `A` extends `B`\n * - `B` extends `A`\n *\n * In other words, the two types describe the same set of values,\n * even if they are written differently.\n *\n * @template A - The first type to check\n * @template B - The second type to check\n * @template Yes - The result if types are mutually assignable (defaults to `true`)\n * @template No - The result if types are not mutually assignable (defaults to `false`)\n *\n * ### Result\n *\n * - `Yes`: `A` and `B` are mutually assignable\n * - `No`: Otherwise\n *\n * @example\n * ```ts\n * type T1 = MutuallyAssignable<number, number> // true\n * type T2 = MutuallyAssignable<1 | 2, 2 | 1> // true\n * type F1 = MutuallyAssignable<string, number> // false\n * type F2 = MutuallyAssignable<1, number> // false\n * ```\n */\nexport type MutuallyAssignable<\n A,\n B,\n Yes = true,\n No = false,\n> = [A] extends [B] ? [B] extends [A] ? Yes : No : No\n"]}
@@ -1,3 +0,0 @@
1
- export * from './compare.js';
2
- export * from './set.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/type/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA"}
@@ -1,5 +0,0 @@
1
- // Index start >>>>>>>>>>>>>>>>
2
- export * from './compare.js';
3
- export * from './set.js';
4
- // <<<<<<<<<<<<<<<< Index end
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/main/type/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './compare.js'\nexport * from './set.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
@@ -1,34 +0,0 @@
1
- /**
2
- * Creates an intersection of all types in the provided tuple
3
- *
4
- * ## `IntersectOf<[A, B, ... T]>` = `A & B & ... & T`
5
- *
6
- * @template Types - A tuple of types to create an intersection from
7
- *
8
- * @example
9
- * ```ts
10
- * import { expect } from '@leawind/lay-sing/test-utils'
11
- *
12
- * type Result = IntersectOf<[{ a: string }, { b: number }, { c: boolean }]>
13
- * expect<Result>().toExtend<{ a: string } & { b: number } & { c: boolean }>().success
14
- * expect<Result>().toExtend<{ a: string; b: number; c: boolean }>().success
15
- * ```
16
- */
17
- export type IntersectOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest] ? First & IntersectOf<Rest> : unknown;
18
- /**
19
- * Creates a union of all types in the provided tuple
20
- *
21
- * ## `UnionOf<[A, B, ... T]>` = `A | B | ... | T`
22
- *
23
- * @template Types - A tuple of types to create a union from
24
- *
25
- * @example
26
- * ```ts
27
- * import { expect } from '@leawind/lay-sing/test-utils'
28
- *
29
- * type Result = UnionOf<[string, number, boolean]>
30
- * expect<Result>().toBe<string | number | boolean>().success
31
- * ```
32
- */
33
- export type UnionOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest] ? First | UnionOf<Rest> : never;
34
- //# sourceMappingURL=set.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/main/type/set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAClG,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,GACzB,OAAO,CAAA;AAEX;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAC9F,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GACrB,KAAK,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=set.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/main/type/set.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Creates an intersection of all types in the provided tuple\n *\n * ## `IntersectOf<[A, B, ... T]>` = `A & B & ... & T`\n *\n * @template Types - A tuple of types to create an intersection from\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * type Result = IntersectOf<[{ a: string }, { b: number }, { c: boolean }]>\n * expect<Result>().toExtend<{ a: string } & { b: number } & { c: boolean }>().success\n * expect<Result>().toExtend<{ a: string; b: number; c: boolean }>().success\n * ```\n */\nexport type IntersectOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest]\n ? First & IntersectOf<Rest>\n : unknown\n\n/**\n * Creates a union of all types in the provided tuple\n *\n * ## `UnionOf<[A, B, ... T]>` = `A | B | ... | T`\n *\n * @template Types - A tuple of types to create a union from\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * type Result = UnionOf<[string, number, boolean]>\n * expect<Result>().toBe<string | number | boolean>().success\n * ```\n */\nexport type UnionOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest]\n ? First | UnionOf<Rest>\n : never\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Represents all possible TypedArray types
3
- */
4
- export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Float32Array | Float64Array | Uint32Array | BigInt64Array | BigUint64Array;
5
- //# sourceMappingURL=typed-array.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typed-array.d.ts","sourceRoot":"","sources":["../../src/main/typed-array.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,aAAa,GACb,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=typed-array.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typed-array.js","sourceRoot":"","sources":["../../src/main/typed-array.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents all possible TypedArray types\n */\nexport type TypedArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Float32Array\n | Float64Array\n | Uint32Array\n | BigInt64Array\n | BigUint64Array\n"]}
@@ -1,81 +0,0 @@
1
- import type { Disjoint, Exact, If, MutuallyAssignable, NotExact, Overlap, SafePick } from '../main/index.js';
2
- /**
3
- * Type-level utility that compares two types and provides methods to test their relationship.
4
- * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.
5
- *
6
- * @template T First type to compare
7
- * @template U Second type to compare
8
- * @template H Hidden property keys that are already used (internal tracking)
9
- *
10
- * @example
11
- * ```ts
12
- * import { compare } from '@leawind/lay-sing/test-utils'
13
- *
14
- * // Check if two types are the same
15
- * compare<number, number>().same // Available
16
- * // Check if two types are different
17
- * compare<number, string>().different // Available
18
- * // Check if two types overlap
19
- * compare<4, number>().overlap.different // Available
20
- * ```
21
- */
22
- export type CompareTypes<T, U, H extends PropertyKey = never> = Omit<SafePick<{
23
- /**
24
- * Available when types T and U are exactly the same.
25
- *
26
- * @example
27
- * ```ts
28
- * import { compare } from '@leawind/lay-sing/test-utils'
29
- *
30
- * compare<3, 3>().same // Available
31
- * compare<boolean, boolean>().same // Available
32
- * ```
33
- */
34
- same: CompareTypes<T, U, H | 'same'>;
35
- /**
36
- * Available when types T and U are different.
37
- *
38
- * @example
39
- * ```ts
40
- * import { compare } from '@leawind/lay-sing/test-utils'
41
- *
42
- * compare<4, 'abc'>().different // Available
43
- * compare<number, 4>().different // Available
44
- * ```
45
- */
46
- different: CompareTypes<T, U, H | 'different'>;
47
- /**
48
- * Available when types T and U have some overlap.
49
- *
50
- * @example
51
- * ```ts
52
- * import { compare } from '@leawind/lay-sing/test-utils'
53
- *
54
- * compare<4, number>().overlap // Available since 4 overlaps with number
55
- * ```
56
- */
57
- overlap: CompareTypes<T, U, H | 'overlap'>;
58
- /**
59
- * Available when types T and U have no overlap (are disjoint).
60
- *
61
- * @example
62
- * ```ts
63
- * import { compare } from '@leawind/lay-sing/test-utils'
64
- *
65
- * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint
66
- * ```
67
- */
68
- disjoint: CompareTypes<T, U, H | 'disjoint'>;
69
- /**
70
- * Available when types T and U are mutually assignable (each type can be assigned to the other).
71
- *
72
- * @example
73
- * ```ts
74
- * import { compare } from '@leawind/lay-sing/test-utils'
75
- *
76
- * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable
77
- * ```
78
- */
79
- mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>;
80
- }, If<Exact<T, U>, 'same'> | If<NotExact<T, U>, 'different'> | If<Overlap<T, U>, 'overlap'> | If<Disjoint<T, U>, 'disjoint'> | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>>, H>;
81
- //# sourceMappingURL=compare.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/test-utils/compare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5G;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,WAAW,GAAG,KAAK,IAAI,IAAI,CAClE,QAAQ,CACN;IACE;;;;;;;;;;OAUG;IACH,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAA;IAEpC;;;;;;;;;;OAUG;IACH,SAAS,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAA;IAE9C;;;;;;;;;OASG;IACH,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAA;IAE1C;;;;;;;;;OASG;IACH,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAA;IAE5C;;;;;;;;;OASG;IACH,kBAAkB,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,oBAAoB,CAAC,CAAA;CACjE,EACC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,GACvB,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,GAC/B,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,GAC5B,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,GAC9B,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,CAAC,CACrD,EACD,CAAC,CACF,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=compare.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/test-utils/compare.ts"],"names":[],"mappings":"","sourcesContent":["import type { Disjoint, Exact, If, MutuallyAssignable, NotExact, Overlap, SafePick } from '../main/index.js'\n\n/**\n * Type-level utility that compares two types and provides methods to test their relationship.\n * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.\n *\n * @template T First type to compare\n * @template U Second type to compare\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * @example\n * ```ts\n * import { compare } from '@leawind/lay-sing/test-utils'\n *\n * // Check if two types are the same\n * compare<number, number>().same // Available\n * // Check if two types are different\n * compare<number, string>().different // Available\n * // Check if two types overlap\n * compare<4, number>().overlap.different // Available\n * ```\n */\nexport type CompareTypes<T, U, H extends PropertyKey = never> = Omit<\n SafePick<\n {\n /**\n * Available when types T and U are exactly the same.\n *\n * @example\n * ```ts\n * import { compare } from '@leawind/lay-sing/test-utils'\n *\n * compare<3, 3>().same // Available\n * compare<boolean, boolean>().same // Available\n * ```\n */\n same: CompareTypes<T, U, H | 'same'>\n\n /**\n * Available when types T and U are different.\n *\n * @example\n * ```ts\n * import { compare } from '@leawind/lay-sing/test-utils'\n *\n * compare<4, 'abc'>().different // Available\n * compare<number, 4>().different // Available\n * ```\n */\n different: CompareTypes<T, U, H | 'different'>\n\n /**\n * Available when types T and U have some overlap.\n *\n * @example\n * ```ts\n * import { compare } from '@leawind/lay-sing/test-utils'\n *\n * compare<4, number>().overlap // Available since 4 overlaps with number\n * ```\n */\n overlap: CompareTypes<T, U, H | 'overlap'>\n\n /**\n * Available when types T and U have no overlap (are disjoint).\n *\n * @example\n * ```ts\n * import { compare } from '@leawind/lay-sing/test-utils'\n *\n * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint\n * ```\n */\n disjoint: CompareTypes<T, U, H | 'disjoint'>\n\n /**\n * Available when types T and U are mutually assignable (each type can be assigned to the other).\n *\n * @example\n * ```ts\n * import { compare } from '@leawind/lay-sing/test-utils'\n *\n * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable\n * ```\n */\n mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>\n },\n | If<Exact<T, U>, 'same'>\n | If<NotExact<T, U>, 'different'>\n | If<Overlap<T, U>, 'overlap'>\n | If<Disjoint<T, U>, 'disjoint'>\n | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>\n >,\n H\n>\n"]}
@@ -1,278 +0,0 @@
1
- import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../main/index.js';
2
- /**
3
- * Represents the result of a type assertion based on a boolean condition.
4
- *
5
- * - If `true`, the result has a `success` property;
6
- * - If `false`, the result has a `fail` property;
7
- * - Otherwise, the result is `never`
8
- *
9
- * @template B The boolean condition result (true or false)
10
- * @template R The type of the result value (default is void)
11
- */
12
- export type TypeAssertionResult<B extends boolean, R = void> = Exact<B, never> extends true ? never : [boolean] extends [B] ? never : [B] extends [true] ? {
13
- /**
14
- * This field exist only when this type assertion succeed
15
- *
16
- * If you expect this assertion to fail, use `.fail`
17
- */
18
- success: R;
19
- } : [B] extends [false] ? {
20
- /**
21
- * This field exist only when this type assertion failed
22
- *
23
- * If you expect this assertion to success, use `.success`
24
- */
25
- fail: R;
26
- } : never;
27
- type ExpectTypeMethods<T, H extends PropertyKey = never> = {
28
- /**
29
- * Tests if the current type is exactly the same as the provided type U.
30
- *
31
- * @template U The type to compare with
32
- *
33
- * @example
34
- * ```ts
35
- * import { expect } from '@leawind/lay-sing/test-utils'
36
- *
37
- * expect<any>().toBe<any>().success
38
- * expect<never>().toBe<never>().success
39
- * expect<false>().toBe<true>().fail
40
- * ```
41
- */
42
- toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
43
- /**
44
- * Tests if the current type is mutually assignable with the provided type U.
45
- *
46
- * It's like:
47
- *
48
- * ```ts ignore
49
- * [T] extends [U] ? [U] extends [T] ? Yes : No : No
50
- * ```
51
- *
52
- * @template U The type to compare with
53
- *
54
- * @example
55
- * ```ts
56
- * import { expect } from '@leawind/lay-sing/test-utils'
57
- *
58
- * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
59
- * expect<1>().toEqual<1 | 2>().fail
60
- * ```
61
- */
62
- toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
63
- /**
64
- * Tests if the current type T extends the provided type U.
65
- *
66
- * @template U The type to check extension against
67
- *
68
- * @example
69
- * ```ts
70
- * import { expect } from '@leawind/lay-sing/test-utils'
71
- *
72
- * expect<3.14>().toExtend<number>().success
73
- * expect<2>().toExtend<string>().fail
74
- * expect<'hello'>().toExtend<string>().success
75
- * ```
76
- */
77
- toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
78
- /**
79
- * Tests if the current type T properly extends the provided type U (extends but is not the same).
80
- *
81
- * @template U The type to check proper extension against
82
- *
83
- * @example
84
- * ```ts
85
- * import { expect } from '@leawind/lay-sing/test-utils'
86
- *
87
- * expect<2>().toProperExtend<number>().success
88
- * expect<'a' | 'b'>().toProperExtend<string>().success
89
- * expect<number>().toProperExtend<number>().fail
90
- * ```
91
- */
92
- toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
93
- /**
94
- * Tests if the current type `T` has a property with key `K`.
95
- *
96
- * @template K The property key to check for
97
- *
98
- * ### Behavior
99
- *
100
- * - For single keys: succeeds if the key exists in `T`
101
- * - For union types: succeeds only if **all** keys in the union exist in `T`
102
- *
103
- * ### Examples
104
- *
105
- * ```ts
106
- * import { expect } from '@leawind/lay-sing/test-utils'
107
- *
108
- * type WithProp = { prop: string; another: number; may?: 5 }
109
- *
110
- * // Single key checks
111
- * expect<WithProp>().toHaveKey<'prop'>().success
112
- * expect<WithProp>().toHaveKey<'missing'>().fail
113
- *
114
- * // Union type checks
115
- * expect<WithProp>().toHaveKey<'prop' | 'another'>().success
116
- * expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail
117
- * ```
118
- */
119
- toHaveKey<K extends PropertyKey>(): IfTupleIncludes<[
120
- never,
121
- any
122
- ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
123
- };
124
- /**
125
- * Type-level testing utility that allows checking various relationships between types.
126
- * Provides methods to test type equality, extension, properties, and more.
127
- *
128
- * @template T The type being tested
129
- * @template H Hidden property keys that are already used (internal tracking)
130
- *
131
- * @example
132
- * ```ts
133
- * import { expect } from '@leawind/lay-sing/test-utils'
134
- *
135
- * // Test if two types are identical
136
- * expect<number>().toBe<number>().success
137
- * expect<number>().toBe<string>().fail
138
- * // Test if one type extends another
139
- * expect<2>().toExtend<number>().success
140
- * expect<2>().toExtend<string>().fail
141
- * // Test if type has a specific property
142
- * expect<{name: string}>().toHaveKey<'name'>().success
143
- * ```
144
- */
145
- export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMethods<T, H> & {
146
- T: T;
147
- inspect: {
148
- [K in keyof T]: T[K];
149
- };
150
- } & SafePick<{
151
- /**
152
- * Tests if the current type extends the Number primitive type.
153
- * Available only if the current type extends number.
154
- *
155
- * @example
156
- * ```ts
157
- * import { expect } from '@leawind/lay-sing/test-utils'
158
- *
159
- * expect<3.14>().toExtendNumber
160
- * ```
161
- */
162
- toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>;
163
- /**
164
- * Tests if the current type extends the String primitive type.
165
- * Available only if the current type extends string.
166
- *
167
- * @example
168
- * ```ts
169
- * import { expect } from '@leawind/lay-sing/test-utils'
170
- *
171
- * expect<'hello'>().toExtendString
172
- * ```
173
- */
174
- toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>;
175
- /**
176
- * Tests if the current type extends the Boolean primitive type.
177
- * Available only if the current type extends boolean.
178
- *
179
- * @example
180
- * ```ts
181
- * import { expect } from '@leawind/lay-sing/test-utils'
182
- *
183
- * expect<true>().toExtendBoolean
184
- * ```
185
- */
186
- toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>;
187
- }, If<Extends<T, number>, 'toExtendNumber'> | If<Extends<T, string>, 'toExtendString'> | If<Extends<T, boolean>, 'toExtendBoolean'>> & SafePick<{
188
- /**
189
- * Alias for {@link ExpectTypeMethods.toBe} where `U = any`
190
- *
191
- * ```ts
192
- * import { expect } from '@leawind/lay-sing/test-utils'
193
- *
194
- * expect<any>().toBeAny
195
- * expect<any>().toBe<any>().success
196
- * ```
197
- */
198
- toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>;
199
- /**
200
- * Alias for {@link ExpectTypeMethods.toBe} where `U = never`
201
- *
202
- * ```ts
203
- * import { expect } from '@leawind/lay-sing/test-utils'
204
- *
205
- * expect<never>().toBeNever
206
- * expect<never>().toBe<never>().success
207
- * ```
208
- */
209
- toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>;
210
- /**
211
- * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`
212
- *
213
- * ```ts
214
- * import { expect } from '@leawind/lay-sing/test-utils'
215
- *
216
- * expect<unknown>().toBeUnknown
217
- * expect<unknown>().toBe<unknown>().success
218
- * ```
219
- */
220
- toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>;
221
- /**
222
- * Alias for {@link ExpectTypeMethods.toBe} where `U = void`
223
- *
224
- * ```ts
225
- * import { expect } from '@leawind/lay-sing/test-utils'
226
- *
227
- * expect<void>().toBeVoid
228
- * expect<void>().toBe<void>().success
229
- * ```
230
- */
231
- toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>;
232
- /**
233
- * Alias for {@link ExpectTypeMethods.toBe} where `U = null`
234
- *
235
- * ```ts
236
- * import { expect } from '@leawind/lay-sing/test-utils'
237
- *
238
- * expect<null>().toBeNull
239
- * expect<null>().toBe<null>().success
240
- * ```
241
- */
242
- toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>;
243
- /**
244
- * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`
245
- *
246
- * ```ts
247
- * import { expect } from '@leawind/lay-sing/test-utils'
248
- *
249
- * expect<undefined>().toBeUndefined
250
- * expect<undefined>().toBe<undefined>().success
251
- * ```
252
- */
253
- toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>;
254
- /**
255
- * Alias for {@link ExpectTypeMethods.toBe} where `U = true`
256
- *
257
- * ```ts
258
- * import { expect } from '@leawind/lay-sing/test-utils'
259
- *
260
- * expect<true>().toBeTrue
261
- * expect<true>().toBe<true>().success
262
- * ```
263
- */
264
- toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>;
265
- /**
266
- * Alias for {@link ExpectTypeMethods.toBe} where `U = false`
267
- *
268
- * ```ts
269
- * import { expect } from '@leawind/lay-sing/test-utils'
270
- *
271
- * expect<false>().toBeFalse
272
- * expect<false>().toBe<false>().success
273
- * ```
274
- */
275
- toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>;
276
- }, If<Exact<T, any>, 'toBeAny'> | If<Exact<T, never>, 'toBeNever'> | If<Exact<T, unknown>, 'toBeUnknown'> | If<Exact<T, void>, 'toBeVoid'> | If<Exact<T, null>, 'toBeNull'> | If<Exact<T, undefined>, 'toBeUndefined'> | If<Exact<T, true>, 'toBeTrue'> | If<Exact<T, false>, 'toBeFalse'>>), H>;
277
- export {};
278
- //# sourceMappingURL=expect.d.ts.map