lay-sing 0.2.1 → 0.3.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 (280) hide show
  1. package/README.md +14 -18
  2. package/esm/{test-utils → main}/expect.d.ts +34 -19
  3. package/esm/main/expect.d.ts.map +1 -0
  4. package/esm/main/expect.js.map +1 -0
  5. package/esm/main/index.d.ts +24 -11
  6. package/esm/main/index.d.ts.map +1 -1
  7. package/esm/main/index.js +5 -13
  8. package/esm/main/index.js.map +1 -1
  9. package/esm/main/noop.d.ts +27 -0
  10. package/esm/main/noop.d.ts.map +1 -0
  11. package/esm/{test-utils/index.js → main/noop.js} +1 -12
  12. package/esm/main/noop.js.map +1 -0
  13. package/esm/utils/compare/assignable.d.ts +30 -0
  14. package/esm/utils/compare/assignable.d.ts.map +1 -0
  15. package/esm/utils/compare/assignable.js +2 -0
  16. package/esm/utils/compare/assignable.js.map +1 -0
  17. package/esm/utils/compare/exact.d.ts +50 -0
  18. package/esm/utils/compare/exact.d.ts.map +1 -0
  19. package/esm/utils/compare/exact.js +2 -0
  20. package/esm/utils/compare/exact.js.map +1 -0
  21. package/esm/utils/compare/extends.d.ts +46 -0
  22. package/esm/utils/compare/extends.d.ts.map +1 -0
  23. package/esm/utils/compare/extends.js +2 -0
  24. package/esm/utils/compare/extends.js.map +1 -0
  25. package/esm/utils/compare/index.d.ts +5 -0
  26. package/esm/utils/compare/index.d.ts.map +1 -0
  27. package/esm/utils/compare/index.js +7 -0
  28. package/esm/utils/compare/index.js.map +1 -0
  29. package/esm/utils/compare/overlap.d.ts +47 -0
  30. package/esm/utils/compare/overlap.d.ts.map +1 -0
  31. package/esm/utils/compare/overlap.js +2 -0
  32. package/esm/utils/compare/overlap.js.map +1 -0
  33. package/esm/utils/index.d.ts +10 -0
  34. package/esm/utils/index.d.ts.map +1 -0
  35. package/esm/utils/index.js +12 -0
  36. package/esm/utils/index.js.map +1 -0
  37. package/esm/utils/logic/assert.d.ts +18 -0
  38. package/esm/utils/logic/assert.d.ts.map +1 -0
  39. package/esm/utils/logic/assert.js +2 -0
  40. package/esm/utils/logic/assert.js.map +1 -0
  41. package/esm/utils/logic/if.d.ts +37 -0
  42. package/esm/utils/logic/if.d.ts.map +1 -0
  43. package/esm/utils/logic/if.js +2 -0
  44. package/esm/utils/logic/if.js.map +1 -0
  45. package/esm/utils/logic/index.d.ts +4 -0
  46. package/esm/utils/logic/index.d.ts.map +1 -0
  47. package/esm/utils/logic/index.js +6 -0
  48. package/esm/utils/logic/index.js.map +1 -0
  49. package/{script/main/control.d.ts → esm/utils/logic/switch.d.ts} +14 -39
  50. package/esm/utils/logic/switch.d.ts.map +1 -0
  51. package/esm/utils/logic/switch.js +2 -0
  52. package/esm/utils/logic/switch.js.map +1 -0
  53. package/esm/utils/object/index.d.ts +4 -0
  54. package/esm/utils/object/index.d.ts.map +1 -0
  55. package/esm/utils/object/index.js +6 -0
  56. package/esm/utils/object/index.js.map +1 -0
  57. package/{script/main/key.d.ts → esm/utils/object/keys.d.ts} +34 -34
  58. package/esm/utils/object/keys.d.ts.map +1 -0
  59. package/esm/utils/object/keys.js +2 -0
  60. package/esm/utils/object/keys.js.map +1 -0
  61. package/esm/utils/object/pick.d.ts +16 -0
  62. package/esm/utils/object/pick.d.ts.map +1 -0
  63. package/esm/utils/object/pick.js +2 -0
  64. package/esm/utils/object/pick.js.map +1 -0
  65. package/esm/utils/object/props.d.ts +17 -0
  66. package/esm/utils/object/props.d.ts.map +1 -0
  67. package/esm/utils/object/props.js +2 -0
  68. package/esm/utils/object/props.js.map +1 -0
  69. package/esm/utils/tuple/append.d.ts +17 -0
  70. package/esm/utils/tuple/append.d.ts.map +1 -0
  71. package/esm/utils/tuple/append.js +2 -0
  72. package/esm/utils/tuple/append.js.map +1 -0
  73. package/esm/utils/tuple/concat.d.ts +31 -0
  74. package/esm/utils/tuple/concat.d.ts.map +1 -0
  75. package/esm/utils/tuple/concat.js +2 -0
  76. package/esm/utils/tuple/concat.js.map +1 -0
  77. package/esm/utils/tuple/includes.d.ts +20 -0
  78. package/esm/utils/tuple/includes.d.ts.map +1 -0
  79. package/esm/utils/tuple/includes.js +2 -0
  80. package/esm/utils/tuple/includes.js.map +1 -0
  81. package/esm/utils/tuple/index.d.ts +4 -0
  82. package/esm/utils/tuple/index.d.ts.map +1 -0
  83. package/esm/utils/tuple/index.js +6 -0
  84. package/esm/utils/tuple/index.js.map +1 -0
  85. package/package.json +5 -5
  86. package/script/{test-utils → main}/expect.d.ts +34 -19
  87. package/script/main/expect.d.ts.map +1 -0
  88. package/script/main/expect.js.map +1 -0
  89. package/script/main/index.d.ts +24 -11
  90. package/script/main/index.d.ts.map +1 -1
  91. package/script/main/index.js +8 -27
  92. package/script/main/index.js.map +1 -1
  93. package/script/main/noop.d.ts +27 -0
  94. package/script/main/noop.d.ts.map +1 -0
  95. package/script/{test-utils/index.js → main/noop.js} +1 -14
  96. package/script/main/noop.js.map +1 -0
  97. package/script/utils/compare/assignable.d.ts +30 -0
  98. package/script/utils/compare/assignable.d.ts.map +1 -0
  99. package/script/utils/compare/assignable.js +3 -0
  100. package/script/utils/compare/assignable.js.map +1 -0
  101. package/script/utils/compare/exact.d.ts +50 -0
  102. package/script/utils/compare/exact.d.ts.map +1 -0
  103. package/script/{main/async.js → utils/compare/exact.js} +1 -1
  104. package/script/utils/compare/exact.js.map +1 -0
  105. package/script/utils/compare/extends.d.ts +46 -0
  106. package/script/utils/compare/extends.d.ts.map +1 -0
  107. package/script/{main/boolean.js → utils/compare/extends.js} +1 -1
  108. package/script/utils/compare/extends.js.map +1 -0
  109. package/script/utils/compare/index.d.ts +5 -0
  110. package/script/utils/compare/index.d.ts.map +1 -0
  111. package/script/utils/compare/index.js +23 -0
  112. package/script/utils/compare/index.js.map +1 -0
  113. package/script/utils/compare/overlap.d.ts +47 -0
  114. package/script/utils/compare/overlap.d.ts.map +1 -0
  115. package/script/{main/control.js → utils/compare/overlap.js} +1 -1
  116. package/script/utils/compare/overlap.js.map +1 -0
  117. package/script/utils/index.d.ts +10 -0
  118. package/script/utils/index.d.ts.map +1 -0
  119. package/script/utils/index.js +28 -0
  120. package/script/utils/index.js.map +1 -0
  121. package/script/utils/logic/assert.d.ts +18 -0
  122. package/script/utils/logic/assert.d.ts.map +1 -0
  123. package/script/utils/logic/assert.js +3 -0
  124. package/script/utils/logic/assert.js.map +1 -0
  125. package/script/utils/logic/if.d.ts +37 -0
  126. package/script/utils/logic/if.d.ts.map +1 -0
  127. package/script/{main/type/set.js → utils/logic/if.js} +1 -1
  128. package/script/utils/logic/if.js.map +1 -0
  129. package/script/utils/logic/index.d.ts +4 -0
  130. package/script/utils/logic/index.d.ts.map +1 -0
  131. package/script/utils/logic/index.js +22 -0
  132. package/script/utils/logic/index.js.map +1 -0
  133. package/{esm/main/control.d.ts → script/utils/logic/switch.d.ts} +14 -39
  134. package/script/utils/logic/switch.d.ts.map +1 -0
  135. package/script/utils/logic/switch.js +3 -0
  136. package/script/utils/logic/switch.js.map +1 -0
  137. package/script/utils/object/index.d.ts +4 -0
  138. package/script/utils/object/index.d.ts.map +1 -0
  139. package/script/{main/type → utils/object}/index.js +3 -2
  140. package/script/utils/object/index.js.map +1 -0
  141. package/{esm/main/key.d.ts → script/utils/object/keys.d.ts} +34 -34
  142. package/script/utils/object/keys.d.ts.map +1 -0
  143. package/script/{main/json.js → utils/object/keys.js} +1 -1
  144. package/script/utils/object/keys.js.map +1 -0
  145. package/script/utils/object/pick.d.ts +16 -0
  146. package/script/utils/object/pick.d.ts.map +1 -0
  147. package/script/{main/key.js → utils/object/pick.js} +1 -1
  148. package/script/utils/object/pick.js.map +1 -0
  149. package/script/utils/object/props.d.ts +17 -0
  150. package/script/utils/object/props.d.ts.map +1 -0
  151. package/script/{main/doc.js → utils/object/props.js} +1 -1
  152. package/script/utils/object/props.js.map +1 -0
  153. package/script/utils/tuple/append.d.ts +17 -0
  154. package/script/utils/tuple/append.d.ts.map +1 -0
  155. package/script/utils/tuple/append.js +3 -0
  156. package/script/utils/tuple/append.js.map +1 -0
  157. package/script/utils/tuple/concat.d.ts +31 -0
  158. package/script/utils/tuple/concat.d.ts.map +1 -0
  159. package/script/utils/tuple/concat.js +3 -0
  160. package/script/utils/tuple/concat.js.map +1 -0
  161. package/script/utils/tuple/includes.d.ts +20 -0
  162. package/script/utils/tuple/includes.d.ts.map +1 -0
  163. package/script/utils/tuple/includes.js +3 -0
  164. package/script/utils/tuple/includes.js.map +1 -0
  165. package/script/utils/tuple/index.d.ts +4 -0
  166. package/script/utils/tuple/index.d.ts.map +1 -0
  167. package/script/utils/tuple/index.js +22 -0
  168. package/script/utils/tuple/index.js.map +1 -0
  169. package/esm/main/async.d.ts +0 -13
  170. package/esm/main/async.d.ts.map +0 -1
  171. package/esm/main/async.js +0 -2
  172. package/esm/main/async.js.map +0 -1
  173. package/esm/main/boolean.d.ts +0 -59
  174. package/esm/main/boolean.d.ts.map +0 -1
  175. package/esm/main/boolean.js +0 -2
  176. package/esm/main/boolean.js.map +0 -1
  177. package/esm/main/control.d.ts.map +0 -1
  178. package/esm/main/control.js +0 -2
  179. package/esm/main/control.js.map +0 -1
  180. package/esm/main/doc.d.ts +0 -56
  181. package/esm/main/doc.d.ts.map +0 -1
  182. package/esm/main/doc.js +0 -2
  183. package/esm/main/doc.js.map +0 -1
  184. package/esm/main/function.d.ts +0 -27
  185. package/esm/main/function.d.ts.map +0 -1
  186. package/esm/main/function.js +0 -2
  187. package/esm/main/function.js.map +0 -1
  188. package/esm/main/json.d.ts +0 -44
  189. package/esm/main/json.d.ts.map +0 -1
  190. package/esm/main/json.js +0 -2
  191. package/esm/main/json.js.map +0 -1
  192. package/esm/main/key.d.ts.map +0 -1
  193. package/esm/main/key.js +0 -2
  194. package/esm/main/key.js.map +0 -1
  195. package/esm/main/object.d.ts +0 -120
  196. package/esm/main/object.d.ts.map +0 -1
  197. package/esm/main/object.js +0 -2
  198. package/esm/main/object.js.map +0 -1
  199. package/esm/main/tuple.d.ts +0 -64
  200. package/esm/main/tuple.d.ts.map +0 -1
  201. package/esm/main/tuple.js +0 -2
  202. package/esm/main/tuple.js.map +0 -1
  203. package/esm/main/type/compare.d.ts +0 -169
  204. package/esm/main/type/compare.d.ts.map +0 -1
  205. package/esm/main/type/compare.js +0 -2
  206. package/esm/main/type/compare.js.map +0 -1
  207. package/esm/main/type/index.d.ts +0 -3
  208. package/esm/main/type/index.d.ts.map +0 -1
  209. package/esm/main/type/index.js +0 -5
  210. package/esm/main/type/index.js.map +0 -1
  211. package/esm/main/type/set.d.ts +0 -34
  212. package/esm/main/type/set.d.ts.map +0 -1
  213. package/esm/main/type/set.js +0 -2
  214. package/esm/main/type/set.js.map +0 -1
  215. package/esm/main/typed-array.d.ts +0 -5
  216. package/esm/main/typed-array.d.ts.map +0 -1
  217. package/esm/main/typed-array.js +0 -2
  218. package/esm/main/typed-array.js.map +0 -1
  219. package/esm/test-utils/compare.d.ts +0 -81
  220. package/esm/test-utils/compare.d.ts.map +0 -1
  221. package/esm/test-utils/compare.js +0 -2
  222. package/esm/test-utils/compare.js.map +0 -1
  223. package/esm/test-utils/expect.d.ts.map +0 -1
  224. package/esm/test-utils/expect.js.map +0 -1
  225. package/esm/test-utils/index.d.ts +0 -77
  226. package/esm/test-utils/index.d.ts.map +0 -1
  227. package/esm/test-utils/index.js.map +0 -1
  228. package/script/main/async.d.ts +0 -13
  229. package/script/main/async.d.ts.map +0 -1
  230. package/script/main/async.js.map +0 -1
  231. package/script/main/boolean.d.ts +0 -59
  232. package/script/main/boolean.d.ts.map +0 -1
  233. package/script/main/boolean.js.map +0 -1
  234. package/script/main/control.d.ts.map +0 -1
  235. package/script/main/control.js.map +0 -1
  236. package/script/main/doc.d.ts +0 -56
  237. package/script/main/doc.d.ts.map +0 -1
  238. package/script/main/doc.js.map +0 -1
  239. package/script/main/function.d.ts +0 -27
  240. package/script/main/function.d.ts.map +0 -1
  241. package/script/main/function.js +0 -3
  242. package/script/main/function.js.map +0 -1
  243. package/script/main/json.d.ts +0 -44
  244. package/script/main/json.d.ts.map +0 -1
  245. package/script/main/json.js.map +0 -1
  246. package/script/main/key.d.ts.map +0 -1
  247. package/script/main/key.js.map +0 -1
  248. package/script/main/object.d.ts +0 -120
  249. package/script/main/object.d.ts.map +0 -1
  250. package/script/main/object.js +0 -3
  251. package/script/main/object.js.map +0 -1
  252. package/script/main/tuple.d.ts +0 -64
  253. package/script/main/tuple.d.ts.map +0 -1
  254. package/script/main/tuple.js +0 -3
  255. package/script/main/tuple.js.map +0 -1
  256. package/script/main/type/compare.d.ts +0 -169
  257. package/script/main/type/compare.d.ts.map +0 -1
  258. package/script/main/type/compare.js +0 -3
  259. package/script/main/type/compare.js.map +0 -1
  260. package/script/main/type/index.d.ts +0 -3
  261. package/script/main/type/index.d.ts.map +0 -1
  262. package/script/main/type/index.js.map +0 -1
  263. package/script/main/type/set.d.ts +0 -34
  264. package/script/main/type/set.d.ts.map +0 -1
  265. package/script/main/type/set.js.map +0 -1
  266. package/script/main/typed-array.d.ts +0 -5
  267. package/script/main/typed-array.d.ts.map +0 -1
  268. package/script/main/typed-array.js +0 -3
  269. package/script/main/typed-array.js.map +0 -1
  270. package/script/test-utils/compare.d.ts +0 -81
  271. package/script/test-utils/compare.d.ts.map +0 -1
  272. package/script/test-utils/compare.js +0 -3
  273. package/script/test-utils/compare.js.map +0 -1
  274. package/script/test-utils/expect.d.ts.map +0 -1
  275. package/script/test-utils/expect.js.map +0 -1
  276. package/script/test-utils/index.d.ts +0 -77
  277. package/script/test-utils/index.d.ts.map +0 -1
  278. package/script/test-utils/index.js.map +0 -1
  279. /package/esm/{test-utils → main}/expect.js +0 -0
  280. /package/script/{test-utils → main}/expect.js +0 -0
@@ -0,0 +1,20 @@
1
+ import type { Exact } from '../index.js';
2
+ /**
3
+ * Checks whether a tuple includes a specific element type
4
+ *
5
+ * @template Tuple - The tuple type to check
6
+ * @template Element - The element type to look for
7
+ * @template Yes - The result if the element is found (defaults to `true`)
8
+ * @template No - The result if the element is not found (defaults to `false`)
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { expect } from '@leawind/lay-sing'
13
+ *
14
+ * expect<IfTupleIncludes<[1, 2, 3], 2>>().toBeTrue
15
+ * expect<IfTupleIncludes<[1, 2, 3], 4>>().toBeFalse
16
+ * expect<IfTupleIncludes<[1, 2, 1], 1>>().toBeTrue
17
+ * ```
18
+ */
19
+ export type IfTupleIncludes<Tuple extends readonly unknown[], Element, Yes = true, No = false> = Exact<Tuple, any> extends true ? never : Tuple extends readonly [infer First, ...infer Rest] ? (Exact<Element, First> extends true ? Yes : IfTupleIncludes<Rest, Element, Yes, No>) : No;
20
+ //# sourceMappingURL=includes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"includes.d.ts","sourceRoot":"","sources":["../../../src/utils/tuple/includes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,eAAe,CACzB,KAAK,SAAS,SAAS,OAAO,EAAE,EAChC,OAAO,EACP,GAAG,GAAG,IAAI,EACV,EAAE,GAAG,KAAK,IACR,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,IAAI,GAAG,KAAK,GACtC,KAAK,SAAS,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GACjD,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,IAAI,GAAG,GAAG,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GACtF,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=includes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"includes.js","sourceRoot":"","sources":["../../../src/utils/tuple/includes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Checks whether a tuple includes a specific element type\n *\n * @template Tuple - The tuple type to check\n * @template Element - The element type to look for\n * @template Yes - The result if the element is found (defaults to `true`)\n * @template No - The result if the element is not found (defaults to `false`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<IfTupleIncludes<[1, 2, 3], 2>>().toBeTrue\n * expect<IfTupleIncludes<[1, 2, 3], 4>>().toBeFalse\n * expect<IfTupleIncludes<[1, 2, 1], 1>>().toBeTrue\n * ```\n */\nexport type IfTupleIncludes<\n Tuple extends readonly unknown[],\n Element,\n Yes = true,\n No = false,\n> = Exact<Tuple, any> extends true ? never\n : Tuple extends readonly [infer First, ...infer Rest]\n ? (Exact<Element, First> extends true ? Yes : IfTupleIncludes<Rest, Element, Yes, No>)\n : No\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './append.js';
2
+ export * from './concat.js';
3
+ export * from './includes.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/tuple/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,6 @@
1
+ // Index start >>>>>>>>>>>>>>>>
2
+ export * from './append.js';
3
+ export * from './concat.js';
4
+ export * from './includes.js';
5
+ // <<<<<<<<<<<<<<<< Index end
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/tuple/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './append.js'\nexport * from './concat.js'\nexport * from './includes.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lay-sing",
3
- "version": "0.2.1",
4
- "description": "Utilities for compile-time type testing and utility types",
3
+ "version": "0.3.0",
4
+ "description": "Utilities for compile-time type testing",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Leawind/lay-sing.git"
@@ -10,9 +10,9 @@
10
10
  "main": "./esm/index.js",
11
11
  "module": "./esm/index.js",
12
12
  "exports": {
13
- "./test-utils": {
14
- "import": "./esm/test-utils/index.js",
15
- "require": "./script/test-utils/index.js"
13
+ "./utils": {
14
+ "import": "./esm/utils/index.js",
15
+ "require": "./script/utils/index.js"
16
16
  },
17
17
  ".": {
18
18
  "import": "./esm/main/index.js",
@@ -1,4 +1,4 @@
1
- import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../main/index.js';
1
+ import type { Exact, Extends, If, IfTupleIncludes, MutuallyAssignable, ProperExtend, SafePick } from '../utils/index.js';
2
2
  /**
3
3
  * Represents the result of a type assertion based on a boolean condition.
4
4
  *
@@ -32,7 +32,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
32
32
  *
33
33
  * @example
34
34
  * ```ts
35
- * import { expect } from '@leawind/lay-sing/test-utils'
35
+ * import { expect } from '@leawind/lay-sing'
36
36
  *
37
37
  * expect<any>().toBe<any>().success
38
38
  * expect<never>().toBe<never>().success
@@ -40,6 +40,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
40
40
  * ```
41
41
  */
42
42
  toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
43
+ toBe<U>(_: U): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>;
43
44
  /**
44
45
  * Tests if the current type is mutually assignable with the provided type U.
45
46
  *
@@ -53,13 +54,14 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
53
54
  *
54
55
  * @example
55
56
  * ```ts
56
- * import { expect } from '@leawind/lay-sing/test-utils'
57
+ * import { expect } from '@leawind/lay-sing'
57
58
  *
58
59
  * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
59
60
  * expect<1>().toEqual<1 | 2>().fail
60
61
  * ```
61
62
  */
62
63
  toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
64
+ toEqual<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>;
63
65
  /**
64
66
  * Tests if the current type T extends the provided type U.
65
67
  *
@@ -67,7 +69,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
67
69
  *
68
70
  * @example
69
71
  * ```ts
70
- * import { expect } from '@leawind/lay-sing/test-utils'
72
+ * import { expect } from '@leawind/lay-sing'
71
73
  *
72
74
  * expect<3.14>().toExtend<number>().success
73
75
  * expect<2>().toExtend<string>().fail
@@ -75,6 +77,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
75
77
  * ```
76
78
  */
77
79
  toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
80
+ toExtend<U>(_: U): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>;
78
81
  /**
79
82
  * Tests if the current type T properly extends the provided type U (extends but is not the same).
80
83
  *
@@ -82,7 +85,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
82
85
  *
83
86
  * @example
84
87
  * ```ts
85
- * import { expect } from '@leawind/lay-sing/test-utils'
88
+ * import { expect } from '@leawind/lay-sing'
86
89
  *
87
90
  * expect<2>().toProperExtend<number>().success
88
91
  * expect<'a' | 'b'>().toProperExtend<string>().success
@@ -90,6 +93,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
90
93
  * ```
91
94
  */
92
95
  toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
96
+ toProperExtend<U>(_: U): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>;
93
97
  /**
94
98
  * Tests if the current type `T` has a property with key `K`.
95
99
  *
@@ -103,7 +107,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
103
107
  * ### Examples
104
108
  *
105
109
  * ```ts
106
- * import { expect } from '@leawind/lay-sing/test-utils'
110
+ * import { expect } from '@leawind/lay-sing'
107
111
  *
108
112
  * type WithProp = { prop: string; another: number; may?: 5 }
109
113
  *
@@ -120,7 +124,18 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
120
124
  never,
121
125
  any
122
126
  ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
127
+ toHaveKey<K extends PropertyKey>(_: K): IfTupleIncludes<[
128
+ never,
129
+ any
130
+ ], K, never, TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>>;
123
131
  };
132
+ type ExpectFunction<T, H extends PropertyKey = never> = Exact<T, any> extends true ? unknown : Exact<T, never> extends true ? unknown : [T] extends [(...args: infer Args) => infer R] ? {
133
+ argsType(): ExpectType<Args, H>;
134
+ returnType(): ExpectType<R, H>;
135
+ } : [T] extends [new (...args: infer Args) => infer R] ? {
136
+ argsType(): ExpectType<Args, H>;
137
+ returnType(): ExpectType<R, H>;
138
+ } : unknown;
124
139
  /**
125
140
  * Type-level testing utility that allows checking various relationships between types.
126
141
  * Provides methods to test type equality, extension, properties, and more.
@@ -130,7 +145,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
130
145
  *
131
146
  * @example
132
147
  * ```ts
133
- * import { expect } from '@leawind/lay-sing/test-utils'
148
+ * import { expect } from '@leawind/lay-sing'
134
149
  *
135
150
  * // Test if two types are identical
136
151
  * expect<number>().toBe<number>().success
@@ -142,7 +157,7 @@ type ExpectTypeMethods<T, H extends PropertyKey = never> = {
142
157
  * expect<{name: string}>().toHaveKey<'name'>().success
143
158
  * ```
144
159
  */
145
- export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMethods<T, H> & {
160
+ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMethods<T, H> & ExpectFunction<T, H> & {
146
161
  T: T;
147
162
  inspect: {
148
163
  [K in keyof T]: T[K];
@@ -154,7 +169,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
154
169
  *
155
170
  * @example
156
171
  * ```ts
157
- * import { expect } from '@leawind/lay-sing/test-utils'
172
+ * import { expect } from '@leawind/lay-sing'
158
173
  *
159
174
  * expect<3.14>().toExtendNumber
160
175
  * ```
@@ -166,7 +181,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
166
181
  *
167
182
  * @example
168
183
  * ```ts
169
- * import { expect } from '@leawind/lay-sing/test-utils'
184
+ * import { expect } from '@leawind/lay-sing'
170
185
  *
171
186
  * expect<'hello'>().toExtendString
172
187
  * ```
@@ -178,7 +193,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
178
193
  *
179
194
  * @example
180
195
  * ```ts
181
- * import { expect } from '@leawind/lay-sing/test-utils'
196
+ * import { expect } from '@leawind/lay-sing'
182
197
  *
183
198
  * expect<true>().toExtendBoolean
184
199
  * ```
@@ -189,7 +204,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
189
204
  * Alias for {@link ExpectTypeMethods.toBe} where `U = any`
190
205
  *
191
206
  * ```ts
192
- * import { expect } from '@leawind/lay-sing/test-utils'
207
+ * import { expect } from '@leawind/lay-sing'
193
208
  *
194
209
  * expect<any>().toBeAny
195
210
  * expect<any>().toBe<any>().success
@@ -200,7 +215,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
200
215
  * Alias for {@link ExpectTypeMethods.toBe} where `U = never`
201
216
  *
202
217
  * ```ts
203
- * import { expect } from '@leawind/lay-sing/test-utils'
218
+ * import { expect } from '@leawind/lay-sing'
204
219
  *
205
220
  * expect<never>().toBeNever
206
221
  * expect<never>().toBe<never>().success
@@ -211,7 +226,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
211
226
  * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`
212
227
  *
213
228
  * ```ts
214
- * import { expect } from '@leawind/lay-sing/test-utils'
229
+ * import { expect } from '@leawind/lay-sing'
215
230
  *
216
231
  * expect<unknown>().toBeUnknown
217
232
  * expect<unknown>().toBe<unknown>().success
@@ -222,7 +237,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
222
237
  * Alias for {@link ExpectTypeMethods.toBe} where `U = void`
223
238
  *
224
239
  * ```ts
225
- * import { expect } from '@leawind/lay-sing/test-utils'
240
+ * import { expect } from '@leawind/lay-sing'
226
241
  *
227
242
  * expect<void>().toBeVoid
228
243
  * expect<void>().toBe<void>().success
@@ -233,7 +248,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
233
248
  * Alias for {@link ExpectTypeMethods.toBe} where `U = null`
234
249
  *
235
250
  * ```ts
236
- * import { expect } from '@leawind/lay-sing/test-utils'
251
+ * import { expect } from '@leawind/lay-sing'
237
252
  *
238
253
  * expect<null>().toBeNull
239
254
  * expect<null>().toBe<null>().success
@@ -244,7 +259,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
244
259
  * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`
245
260
  *
246
261
  * ```ts
247
- * import { expect } from '@leawind/lay-sing/test-utils'
262
+ * import { expect } from '@leawind/lay-sing'
248
263
  *
249
264
  * expect<undefined>().toBeUndefined
250
265
  * expect<undefined>().toBe<undefined>().success
@@ -255,7 +270,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
255
270
  * Alias for {@link ExpectTypeMethods.toBe} where `U = true`
256
271
  *
257
272
  * ```ts
258
- * import { expect } from '@leawind/lay-sing/test-utils'
273
+ * import { expect } from '@leawind/lay-sing'
259
274
  *
260
275
  * expect<true>().toBeTrue
261
276
  * expect<true>().toBe<true>().success
@@ -266,7 +281,7 @@ export type ExpectType<T, H extends PropertyKey = never> = Omit<(ExpectTypeMetho
266
281
  * Alias for {@link ExpectTypeMethods.toBe} where `U = false`
267
282
  *
268
283
  * ```ts
269
- * import { expect } from '@leawind/lay-sing/test-utils'
284
+ * import { expect } from '@leawind/lay-sing'
270
285
  *
271
286
  * expect<false>().toBeFalse
272
287
  * expect<false>().toBe<false>().success
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/main/expect.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/main/expect.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Exact,\n Extends,\n If,\n IfTupleIncludes,\n MutuallyAssignable,\n ProperExtend,\n SafePick,\n} from '../utils/index.js'\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n *\n * - If `true`, the result has a `success` property;\n * - If `false`, the result has a `fail` property;\n * - Otherwise, the result is `never`\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\nexport type TypeAssertionResult<B extends boolean, R = void> = Exact<B, never> extends true ? never\n : [boolean] extends [B] ? never\n : [B] extends [true] ? {\n /**\n * This field exist only when this type assertion succeed\n *\n * If you expect this assertion to fail, use `.fail`\n */\n success: R\n }\n : [B] extends [false] ? {\n /**\n * This field exist only when this type assertion failed\n *\n * If you expect this assertion to success, use `.success`\n */\n fail: R\n }\n : never\n\ntype ExpectTypeMethods<T, H extends PropertyKey = never> = {\n /**\n * Tests if the current type is exactly the same as the provided type U.\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>\n toBe<U>(_: U): TypeAssertionResult<Exact<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success\n * expect<1>().toEqual<1 | 2>().fail\n * ```\n */\n toEqual<U>(): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>\n toEqual<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>\n toExtend<U>(_: U): TypeAssertionResult<Extends<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>\n toProperExtend<U>(_: U): TypeAssertionResult<ProperExtend<T, U>, ExpectType<T, H>>\n\n /**\n * Tests if the current type `T` has a property with key `K`.\n *\n * @template K The property key to check for\n *\n * ### Behavior\n *\n * - For single keys: succeeds if the key exists in `T`\n * - For union types: succeeds only if **all** keys in the union exist in `T`\n *\n * ### Examples\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type WithProp = { prop: string; another: number; may?: 5 }\n *\n * // Single key checks\n * expect<WithProp>().toHaveKey<'prop'>().success\n * expect<WithProp>().toHaveKey<'missing'>().fail\n *\n * // Union type checks\n * expect<WithProp>().toHaveKey<'prop' | 'another'>().success\n * expect<WithProp>().toHaveKey<'may' | 'unexist'>().fail\n * ```\n */\n toHaveKey<K extends PropertyKey>(): IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>\n >\n toHaveKey<K extends PropertyKey>(_: K): IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T>, ExpectType<T, H>>\n >\n}\n\ntype ExpectFunction<T, H extends PropertyKey = never> = Exact<T, any> extends true ? unknown\n : Exact<T, never> extends true ? unknown\n : [T] extends [(...args: infer Args) => infer R] ? {\n argsType(): ExpectType<Args, H>\n returnType(): ExpectType<R, H>\n }\n : [T] extends [new (...args: infer Args) => infer R] ? {\n argsType(): ExpectType<Args, H>\n returnType(): ExpectType<R, H>\n }\n : unknown\n\n/**\n * Type-level testing utility that allows checking various relationships between types.\n * Provides methods to test type equality, extension, properties, and more.\n *\n * @template T The type being tested\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * // Test if two types are identical\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<2>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * // Test if type has a specific property\n * expect<{name: string}>().toHaveKey<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & ExpectTypeMethods<T, H>\n & ExpectFunction<T, H>\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n }\n & SafePick<\n {\n /**\n * Tests if the current type extends the Number primitive type.\n * Available only if the current type extends number.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().toExtendNumber\n * ```\n */\n toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>\n\n /**\n * Tests if the current type extends the String primitive type.\n * Available only if the current type extends string.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<'hello'>().toExtendString\n * ```\n */\n toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>\n\n /**\n * Tests if the current type extends the Boolean primitive type.\n * Available only if the current type extends boolean.\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<true>().toExtendBoolean\n * ```\n */\n toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>\n },\n | If<Extends<T, number>, 'toExtendNumber'>\n | If<Extends<T, string>, 'toExtendString'>\n | If<Extends<T, boolean>, 'toExtendBoolean'>\n >\n & SafePick<\n {\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = any`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<any>().toBeAny\n * expect<any>().toBe<any>().success\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = never`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<never>().toBeNever\n * expect<never>().toBe<never>().success\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = unknown`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<unknown>().toBeUnknown\n * expect<unknown>().toBe<unknown>().success\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = void`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<void>().toBeVoid\n * expect<void>().toBe<void>().success\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = null`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<null>().toBeNull\n * expect<null>().toBe<null>().success\n * ```\n */\n toBeNull: ExpectType<T, H | 'toBeNull' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = undefined`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<undefined>().toBeUndefined\n * expect<undefined>().toBe<undefined>().success\n * ```\n */\n toBeUndefined: ExpectType<T, H | 'toBeUndefined' | 'toBe'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = true`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<true>().toBeTrue\n * expect<true>().toBe<true>().success\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Alias for {@link ExpectTypeMethods.toBe} where `U = false`\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<false>().toBeFalse\n * expect<false>().toBe<false>().success\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Exact<T, any>, 'toBeAny'>\n | If<Exact<T, never>, 'toBeNever'>\n | If<Exact<T, unknown>, 'toBeUnknown'>\n | If<Exact<T, void>, 'toBeVoid'>\n | If<Exact<T, null>, 'toBeNull'>\n | If<Exact<T, undefined>, 'toBeUndefined'>\n | If<Exact<T, true>, 'toBeTrue'>\n | If<Exact<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n"]}
@@ -3,15 +3,28 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- export * from './async.js';
7
- export * from './boolean.js';
8
- export * from './control.js';
9
- export * from './doc.js';
10
- export * from './function.js';
11
- export * from './json.js';
12
- export * from './key.js';
13
- export * from './object.js';
14
- export * from './tuple.js';
15
- export * from './type/index.js';
16
- export * from './typed-array.js';
6
+ import type { ExpectType } from './expect.js';
7
+ export type { ExpectType } from './expect.js';
8
+ export { NOOP } from './noop.js';
9
+ /**
10
+ * Creates an instance of ExpectType to perform type-level assertions on the given type.
11
+ * This function enables testing various type relationships at compile time.
12
+ * NOTE: This function does nothing at runtime and is purely for type-level testing.
13
+ *
14
+ * @template T The type to be tested
15
+ *
16
+ * @returns An ExpectType instance with methods to test type relationships
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // Test exact type equality
21
+ * expect<number>().toBe<number>().success
22
+ * expect<number>().toBe<string>().fail
23
+ * // Test if one type extends another
24
+ * expect<3.14>().toExtend<number>().success
25
+ * expect<2>().toExtend<string>().fail
26
+ * ```
27
+ */
28
+ export declare function expect<T>(): ExpectType<T>;
29
+ export declare function expect<T>(_: T): ExpectType<T>;
17
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAA;AAC1C,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA"}
@@ -4,32 +4,13 @@
4
4
  *
5
5
  * @module
6
6
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
7
  Object.defineProperty(exports, "__esModule", { value: true });
22
- // Index start >>>>>>>>>>>>>>>>
23
- __exportStar(require("./async.js"), exports);
24
- __exportStar(require("./boolean.js"), exports);
25
- __exportStar(require("./control.js"), exports);
26
- __exportStar(require("./doc.js"), exports);
27
- __exportStar(require("./function.js"), exports);
28
- __exportStar(require("./json.js"), exports);
29
- __exportStar(require("./key.js"), exports);
30
- __exportStar(require("./object.js"), exports);
31
- __exportStar(require("./tuple.js"), exports);
32
- __exportStar(require("./type/index.js"), exports);
33
- __exportStar(require("./typed-array.js"), exports);
34
- // <<<<<<<<<<<<<<<< Index end
8
+ exports.NOOP = void 0;
9
+ exports.expect = expect;
10
+ const noop_js_1 = require("./noop.js");
11
+ var noop_js_2 = require("./noop.js");
12
+ Object.defineProperty(exports, "NOOP", { enumerable: true, get: function () { return noop_js_2.NOOP; } });
13
+ function expect() {
14
+ return noop_js_1.NOOP;
15
+ }
35
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,+BAA+B;AAC/B,6CAA0B;AAC1B,+CAA4B;AAC5B,+CAA4B;AAC5B,2CAAwB;AACxB,gDAA6B;AAC7B,4CAAyB;AACzB,2CAAwB;AACxB,8CAA2B;AAC3B,6CAA0B;AAC1B,kDAA+B;AAC/B,mDAAgC;AAChC,+BAA+B","sourcesContent":["/**\n * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)\n *\n * @module\n */\n\n// Index start >>>>>>>>>>>>>>>>\nexport * from './async.js'\nexport * from './boolean.js'\nexport * from './control.js'\nexport * from './doc.js'\nexport * from './function.js'\nexport * from './json.js'\nexport * from './key.js'\nexport * from './object.js'\nexport * from './tuple.js'\nexport * from './type/index.js'\nexport * from './typed-array.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA6BH,wBAEC;AA5BD,uCAAgC;AAGhC,qCAAgC;AAAvB,+FAAA,IAAI,OAAA;AAuBb,SAAgB,MAAM;IACpB,OAAO,cAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)\n *\n * @module\n */\n\nimport type { ExpectType } from './expect.js'\nimport { NOOP } from './noop.js'\n\nexport type { ExpectType } from './expect.js'\nexport { NOOP } from './noop.js'\n\n/**\n * Creates an instance of ExpectType to perform type-level assertions on the given type.\n * This function enables testing various type relationships at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T The type to be tested\n *\n * @returns An ExpectType instance with methods to test type relationships\n *\n * @example\n * ```ts\n * // Test exact type equality\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * ```\n */\nexport function expect<T>(): ExpectType<T>\nexport function expect<T>(_: T): ExpectType<T>\nexport function expect<T>(): ExpectType<T> {\n return NOOP\n}\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A universal no-op placeholder implemented via `Proxy`.
3
+ *
4
+ * `NOOP` can be accessed, called, or chained indefinitely without throwing.
5
+ * Every operation returns itself, making it safe to use as a dummy fallback
6
+ * for APIs, optional hooks, or unimplemented interfaces.
7
+ *
8
+ * ### Special behaviors
9
+ *
10
+ * - Callable: invoking `NOOP()` returns `NOOP`
11
+ * - Property access: `NOOP.anything` returns `NOOP`
12
+ * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise
13
+ * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields
14
+ * a stable string representation: `"[NOOP]"`
15
+ *
16
+ * This is useful in scenarios where a value is required syntactically but
17
+ * should perform no action and never fail at runtime.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * NOOP.foo.bar().baz.qux; // safe, returns NOOP
22
+ * String(NOOP); // "[NOOP]"
23
+ * await NOOP; // does not await (not thenable)
24
+ * ```
25
+ */
26
+ export declare const NOOP: any;
27
+ //# sourceMappingURL=noop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/main/noop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,IAAI,EAAE,GA0BlB,CAAA"}
@@ -1,13 +1,6 @@
1
1
  "use strict";
2
- /**
3
- * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
4
- *
5
- * @module
6
- */
7
2
  Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.NOOP = void 0;
9
- exports.compare = compare;
10
- exports.expect = expect;
11
4
  /**
12
5
  * A universal no-op placeholder implemented via `Proxy`.
13
6
  *
@@ -57,10 +50,4 @@ exports.NOOP = new Proxy(function () {
57
50
  has: () => true,
58
51
  ownKeys: () => ['prototype'],
59
52
  });
60
- function compare() {
61
- return exports.NOOP;
62
- }
63
- function expect() {
64
- return exports.NOOP;
65
- }
66
- //# sourceMappingURL=index.js.map
53
+ //# sourceMappingURL=noop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.js","sourceRoot":"","sources":["../../src/main/noop.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACU,QAAA,IAAI,GAAQ,IAAI,KAAK,CAChC;IACE,OAAO,YAAI,CAAA;AACb,CAAC,EACD;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,SAAS,CAAA;YAClB,KAAK,SAAS,CAAC;YACf,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC,WAAW;gBACrB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAA;YACvB;gBACE,OAAO,YAAI,CAAA;QACf,CAAC;IACH,CAAC;IACD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/B,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,YAAI;KACZ,CAAC;IACF,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;IAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC;CAC7B,CACF,CAAA","sourcesContent":["/**\n * A universal no-op placeholder implemented via `Proxy`.\n *\n * `NOOP` can be accessed, called, or chained indefinitely without throwing.\n * Every operation returns itself, making it safe to use as a dummy fallback\n * for APIs, optional hooks, or unimplemented interfaces.\n *\n * ### Special behaviors\n *\n * - Callable: invoking `NOOP()` returns `NOOP`\n * - Property access: `NOOP.anything` returns `NOOP`\n * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise\n * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields\n * a stable string representation: `\"[NOOP]\"`\n *\n * This is useful in scenarios where a value is required syntactically but\n * should perform no action and never fail at runtime.\n *\n * @example\n * ```ts\n * NOOP.foo.bar().baz.qux; // safe, returns NOOP\n * String(NOOP); // \"[NOOP]\"\n * await NOOP; // does not await (not thenable)\n * ```\n */\nexport const NOOP: any = new Proxy(\n function () {\n return NOOP\n },\n {\n get(_, prop) {\n switch (prop) {\n case 'then':\n return undefined\n case 'valueOf':\n case 'toString':\n case Symbol.toPrimitive:\n return () => '[NOOP]'\n default:\n return NOOP\n }\n },\n set: () => true,\n getOwnPropertyDescriptor: () => ({\n configurable: true,\n value: NOOP,\n }),\n getPrototypeOf: () => null,\n has: () => true,\n ownKeys: () => ['prototype'],\n },\n)\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Checks whether two types are mutually assignable.
3
+ *
4
+ * This is equivalent to checking that:
5
+ * - `A` extends `B`
6
+ * - `B` extends `A`
7
+ *
8
+ * In other words, the two types describe the same set of values,
9
+ * even if they are written differently.
10
+ *
11
+ * @template A - The first type to check
12
+ * @template B - The second type to check
13
+ * @template Yes - The result if types are mutually assignable (defaults to `true`)
14
+ * @template No - The result if types are not mutually assignable (defaults to `false`)
15
+ *
16
+ * ### Result
17
+ *
18
+ * - `Yes`: `A` and `B` are mutually assignable
19
+ * - `No`: Otherwise
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * type T1 = MutuallyAssignable<number, number> // true
24
+ * type T2 = MutuallyAssignable<1 | 2, 2 | 1> // true
25
+ * type F1 = MutuallyAssignable<string, number> // false
26
+ * type F2 = MutuallyAssignable<1, number> // false
27
+ * ```
28
+ */
29
+ export type MutuallyAssignable<A, B, Yes = true, No = false> = [A] extends [B] ? [B] extends [A] ? Yes : No : No;
30
+ //# sourceMappingURL=assignable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignable.d.ts","sourceRoot":"","sources":["../../../src/utils/compare/assignable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=assignable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assignable.js","sourceRoot":"","sources":["../../../src/utils/compare/assignable.ts"],"names":[],"mappings":"","sourcesContent":["/**\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"]}
@@ -0,0 +1,50 @@
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'
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
+ //# sourceMappingURL=exact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact.d.ts","sourceRoot":"","sources":["../../../src/utils/compare/exact.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"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=async.js.map
3
+ //# sourceMappingURL=exact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact.js","sourceRoot":"","sources":["../../../src/utils/compare/exact.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'\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"]}