lay-sing 0.2.0 → 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 (282) hide show
  1. package/README.md +64 -29
  2. package/esm/{test-utils → main}/expect.d.ts +79 -9
  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 +29 -11
  6. package/esm/main/index.d.ts.map +1 -1
  7. package/esm/main/index.js +10 -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 -8
  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/esm/utils/logic/switch.d.ts +87 -0
  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} +40 -38
  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 +79 -9
  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 +29 -11
  90. package/script/main/index.d.ts.map +1 -1
  91. package/script/main/index.js +13 -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 -10
  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/script/utils/logic/switch.d.ts +87 -0
  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} +40 -38
  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 -5
  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 -35
  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 +0 -83
  178. package/esm/main/control.d.ts.map +0 -1
  179. package/esm/main/control.js +0 -2
  180. package/esm/main/control.js.map +0 -1
  181. package/esm/main/doc.d.ts +0 -30
  182. package/esm/main/doc.d.ts.map +0 -1
  183. package/esm/main/doc.js +0 -2
  184. package/esm/main/doc.js.map +0 -1
  185. package/esm/main/function.d.ts +0 -19
  186. package/esm/main/function.d.ts.map +0 -1
  187. package/esm/main/function.js +0 -3
  188. package/esm/main/function.js.map +0 -1
  189. package/esm/main/json.d.ts +0 -44
  190. package/esm/main/json.d.ts.map +0 -1
  191. package/esm/main/json.js +0 -2
  192. package/esm/main/json.js.map +0 -1
  193. package/esm/main/key.d.ts.map +0 -1
  194. package/esm/main/key.js +0 -2
  195. package/esm/main/key.js.map +0 -1
  196. package/esm/main/object.d.ts +0 -95
  197. package/esm/main/object.d.ts.map +0 -1
  198. package/esm/main/object.js +0 -2
  199. package/esm/main/object.js.map +0 -1
  200. package/esm/main/tuple.d.ts +0 -40
  201. package/esm/main/tuple.d.ts.map +0 -1
  202. package/esm/main/tuple.js +0 -2
  203. package/esm/main/tuple.js.map +0 -1
  204. package/esm/main/type/compare.d.ts +0 -79
  205. package/esm/main/type/compare.d.ts.map +0 -1
  206. package/esm/main/type/compare.js +0 -2
  207. package/esm/main/type/compare.js.map +0 -1
  208. package/esm/main/type/index.d.ts +0 -3
  209. package/esm/main/type/index.d.ts.map +0 -1
  210. package/esm/main/type/index.js +0 -5
  211. package/esm/main/type/index.js.map +0 -1
  212. package/esm/main/type/set.d.ts +0 -27
  213. package/esm/main/type/set.d.ts.map +0 -1
  214. package/esm/main/type/set.js +0 -2
  215. package/esm/main/type/set.js.map +0 -1
  216. package/esm/main/typed-array.d.ts +0 -5
  217. package/esm/main/typed-array.d.ts.map +0 -1
  218. package/esm/main/typed-array.js +0 -2
  219. package/esm/main/typed-array.js.map +0 -1
  220. package/esm/test-utils/compare.d.ts +0 -69
  221. package/esm/test-utils/compare.d.ts.map +0 -1
  222. package/esm/test-utils/compare.js +0 -2
  223. package/esm/test-utils/compare.js.map +0 -1
  224. package/esm/test-utils/expect.d.ts.map +0 -1
  225. package/esm/test-utils/expect.js.map +0 -1
  226. package/esm/test-utils/index.d.ts +0 -72
  227. package/esm/test-utils/index.d.ts.map +0 -1
  228. package/esm/test-utils/index.js.map +0 -1
  229. package/script/main/async.d.ts +0 -5
  230. package/script/main/async.d.ts.map +0 -1
  231. package/script/main/async.js.map +0 -1
  232. package/script/main/boolean.d.ts +0 -35
  233. package/script/main/boolean.d.ts.map +0 -1
  234. package/script/main/boolean.js.map +0 -1
  235. package/script/main/control.d.ts +0 -83
  236. package/script/main/control.d.ts.map +0 -1
  237. package/script/main/control.js.map +0 -1
  238. package/script/main/doc.d.ts +0 -30
  239. package/script/main/doc.d.ts.map +0 -1
  240. package/script/main/doc.js.map +0 -1
  241. package/script/main/function.d.ts +0 -19
  242. package/script/main/function.d.ts.map +0 -1
  243. package/script/main/function.js +0 -4
  244. package/script/main/function.js.map +0 -1
  245. package/script/main/json.d.ts +0 -44
  246. package/script/main/json.d.ts.map +0 -1
  247. package/script/main/json.js.map +0 -1
  248. package/script/main/key.d.ts.map +0 -1
  249. package/script/main/key.js.map +0 -1
  250. package/script/main/object.d.ts +0 -95
  251. package/script/main/object.d.ts.map +0 -1
  252. package/script/main/object.js +0 -3
  253. package/script/main/object.js.map +0 -1
  254. package/script/main/tuple.d.ts +0 -40
  255. package/script/main/tuple.d.ts.map +0 -1
  256. package/script/main/tuple.js +0 -3
  257. package/script/main/tuple.js.map +0 -1
  258. package/script/main/type/compare.d.ts +0 -79
  259. package/script/main/type/compare.d.ts.map +0 -1
  260. package/script/main/type/compare.js +0 -3
  261. package/script/main/type/compare.js.map +0 -1
  262. package/script/main/type/index.d.ts +0 -3
  263. package/script/main/type/index.d.ts.map +0 -1
  264. package/script/main/type/index.js.map +0 -1
  265. package/script/main/type/set.d.ts +0 -27
  266. package/script/main/type/set.d.ts.map +0 -1
  267. package/script/main/type/set.js.map +0 -1
  268. package/script/main/typed-array.d.ts +0 -5
  269. package/script/main/typed-array.d.ts.map +0 -1
  270. package/script/main/typed-array.js +0 -3
  271. package/script/main/typed-array.js.map +0 -1
  272. package/script/test-utils/compare.d.ts +0 -69
  273. package/script/test-utils/compare.d.ts.map +0 -1
  274. package/script/test-utils/compare.js +0 -3
  275. package/script/test-utils/compare.js.map +0 -1
  276. package/script/test-utils/expect.d.ts.map +0 -1
  277. package/script/test-utils/expect.js.map +0 -1
  278. package/script/test-utils/index.d.ts +0 -72
  279. package/script/test-utils/index.d.ts.map +0 -1
  280. package/script/test-utils/index.js.map +0 -1
  281. /package/esm/{test-utils → main}/expect.js +0 -0
  282. /package/script/{test-utils → main}/expect.js +0 -0
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NOOP = void 0;
4
- exports.compare = compare;
5
- exports.expect = expect;
6
4
  /**
7
5
  * A universal no-op placeholder implemented via `Proxy`.
8
6
  *
@@ -28,7 +26,6 @@ exports.expect = expect;
28
26
  * await NOOP; // does not await (not thenable)
29
27
  * ```
30
28
  */
31
- // deno-lint-ignore no-explicit-any
32
29
  exports.NOOP = new Proxy(function () {
33
30
  return exports.NOOP;
34
31
  }, {
@@ -53,10 +50,4 @@ exports.NOOP = new Proxy(function () {
53
50
  has: () => true,
54
51
  ownKeys: () => ['prototype'],
55
52
  });
56
- function compare() {
57
- return exports.NOOP;
58
- }
59
- function expect() {
60
- return exports.NOOP;
61
- }
62
- //# 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"]}
@@ -0,0 +1,46 @@
1
+ import type { Exact } from '../index.js';
2
+ /**
3
+ * Checks whether type `A` extends type `B`.
4
+ *
5
+ * **⚠️Important:** parameter `A` and `B` are not distributive. When they are union type, it treats them as a single entity.
6
+ *
7
+ * @template A - The type to check if it extends another type
8
+ * @template B - The type to check if `A` extends
9
+ * @template Yes - The result if `A` extends `B` (defaults to `true`)
10
+ * @template No - The result if `A` does not extend `B` (defaults to `false`)
11
+ *
12
+ * ### Result
13
+ *
14
+ * - `Yes`: `A` is assignable to `B`
15
+ * - `No`: Otherwise
16
+ */
17
+ export type Extends<A, B, Yes = true, No = false> = [A] extends [B] ? Yes : No;
18
+ /**
19
+ * Checks whether type `A` is a *proper* subtype of type `B`.
20
+ *
21
+ * A proper extension means:
22
+ * - `A` extends `B`
23
+ * - `A` is not exactly the same type as `B`
24
+ *
25
+ * @template A - The type to check if it is a proper subtype
26
+ * @template B - The type to check against
27
+ * @template Yes - The result if `A` is a proper subtype of `B` (defaults to `true`)
28
+ * @template No - The result if `A` is not a proper subtype of `B` (defaults to `false`)
29
+ *
30
+ * ### Result
31
+ *
32
+ * - `Yes`: `A` is a proper subtype of `B`
33
+ * - `No`: Otherwise
34
+ *
35
+ * **Note:** the result will never be `boolean`.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * type T1 = ProperExtend<true, boolean> // true
40
+ * type T2 = ProperExtend<1, number> // true
41
+ * type F1 = ProperExtend<boolean, boolean> // false
42
+ * type F2 = ProperExtend<number, string> // false
43
+ * ```
44
+ */
45
+ export type ProperExtend<A, B, Yes = true, No = false> = [A] extends [B] ? Exact<A, B> extends false ? Yes : No : No;
46
+ //# sourceMappingURL=extends.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extends.d.ts","sourceRoot":"","sources":["../../../src/utils/compare/extends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC;;;;;;;;;;;;;;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"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=boolean.js.map
3
+ //# sourceMappingURL=extends.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extends.js","sourceRoot":"","sources":["../../../src/utils/compare/extends.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\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"]}
@@ -0,0 +1,5 @@
1
+ export * from './assignable.js';
2
+ export * from './exact.js';
3
+ export * from './extends.js';
4
+ export * from './overlap.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/compare/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Index start >>>>>>>>>>>>>>>>
18
+ __exportStar(require("./assignable.js"), exports);
19
+ __exportStar(require("./exact.js"), exports);
20
+ __exportStar(require("./extends.js"), exports);
21
+ __exportStar(require("./overlap.js"), exports);
22
+ // <<<<<<<<<<<<<<<< Index end
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/compare/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,kDAA+B;AAC/B,6CAA0B;AAC1B,+CAA4B;AAC5B,+CAA4B;AAC5B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './assignable.js'\nexport * from './exact.js'\nexport * from './extends.js'\nexport * from './overlap.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Checks whether two types have any overlapping members.
3
+ *
4
+ * @template A - The first type to check for overlap
5
+ * @template B - The second type to check for overlap
6
+ * @template Yes - The result if types overlap (defaults to `true`)
7
+ * @template No - The result if types do not overlap (defaults to `false`)
8
+ *
9
+ * ### Result
10
+ *
11
+ * - `Yes`: `A` and `B` share at least one common type
12
+ * - `No`: `A` and `B` are completely disjoint
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * type T1 = Overlap<1 | 2, 2 | 3> // true
17
+ * type T2 = Overlap<string, 'hello'> // true
18
+ * type F1 = Overlap<string, number> // false
19
+ * type F2 = Overlap<1, 'one'> // false
20
+ * ```
21
+ */
22
+ export type Overlap<A, B, Yes = true, No = false> = [A & B] extends [never] ? No : Yes;
23
+ /**
24
+ * Checks whether two types are disjoint.
25
+ *
26
+ * This is the logical negation of `Overlap<A, B>`.
27
+ *
28
+ * @template A - The first type to check for disjointness
29
+ * @template B - The second type to check for disjointness
30
+ * @template Yes - The result if types are disjoint (defaults to `true`)
31
+ * @template No - The result if types are not disjoint (defaults to `false`)
32
+ *
33
+ * ### Result
34
+ *
35
+ * - `Yes`: `A` and `B` have no overlap
36
+ * - `No`: `A` and `B` share at least one common type
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * type T1 = Disjoint<string, number> // true
41
+ * type T2 = Disjoint<1, 'one'> // true
42
+ * type F1 = Disjoint<1 | 2, 2 | 3> // false
43
+ * type F2 = Disjoint<string, 'hello'> // false
44
+ * ```
45
+ */
46
+ export type Disjoint<A, B, Yes = true, No = false> = [A & B] extends [never] ? Yes : No;
47
+ //# sourceMappingURL=overlap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlap.d.ts","sourceRoot":"","sources":["../../../src/utils/compare/overlap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;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"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=control.js.map
3
+ //# sourceMappingURL=overlap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlap.js","sourceRoot":"","sources":["../../../src/utils/compare/overlap.ts"],"names":[],"mappings":"","sourcesContent":["/**\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"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
3
+ *
4
+ * @module
5
+ */
6
+ export * from './compare/index.js';
7
+ export * from './logic/index.js';
8
+ export * from './object/index.js';
9
+ export * from './tuple/index.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
4
+ *
5
+ * @module
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
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ // Index start >>>>>>>>>>>>>>>>
23
+ __exportStar(require("./compare/index.js"), exports);
24
+ __exportStar(require("./logic/index.js"), exports);
25
+ __exportStar(require("./object/index.js"), exports);
26
+ __exportStar(require("./tuple/index.js"), exports);
27
+ // <<<<<<<<<<<<<<<< Index end
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,+BAA+B;AAC/B,qDAAkC;AAClC,mDAAgC;AAChC,oDAAiC;AACjC,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 './compare/index.js'\nexport * from './logic/index.js'\nexport * from './object/index.js'\nexport * from './tuple/index.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * **⚠️Important:** parameter `T` and `U` are not distributive. When they are union type, it treats them as a single entity.
3
+ *
4
+ * @template T - The type to test (not distributed over unions)
5
+ * @template U - The constraint type to test against
6
+ *
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * import { expect } from '@leawind/lay-sing'
11
+ *
12
+ * expect<AssertExtends<string, number>>().toBeNever
13
+ * expect<AssertExtends<1 | 2, 1>>().toBeNever
14
+ * expect<AssertExtends<1, 1 | 2>>().toBe<1>().success
15
+ * ```
16
+ */
17
+ export type AssertExtends<T, U> = [T] extends [U] ? T : never;
18
+ //# sourceMappingURL=assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/assert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=assert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/utils/logic/assert.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * **⚠️Important:** parameter `T` and `U` are not distributive. When they are union type, it treats them as a single entity.\n *\n * @template T - The type to test (not distributed over unions)\n * @template U - The constraint type to test against\n *\n * @example\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<AssertExtends<string, number>>().toBeNever\n * expect<AssertExtends<1 | 2, 1>>().toBeNever\n * expect<AssertExtends<1, 1 | 2>>().toBe<1>().success\n * ```\n */\nexport type AssertExtends<T, U> = [T] extends [U] ? T : never\n"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Conditional type - returns `Yes` if condition `Condition` is true, otherwise returns `No`
3
+ *
4
+ * @template Condition - The boolean condition to check
5
+ * @template Yes - The type to return if condition is true
6
+ * @template No - The type to return if condition is false (defaults to `never`)
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * type Result = If<true, 'yes', 'no'> // 'yes'
11
+ * type Result2 = If<false, 'yes', 'no'> // 'no'
12
+ * type BoolResult = If<boolean, 'yes', 'no'> // boolean
13
+ * ```
14
+ */
15
+ export type If<Condition extends boolean, Yes, No = never> = Condition extends true ? Yes : No;
16
+ /**
17
+ * Conditional type - returns `Yes` if condition `Condition` is false, otherwise returns `No`
18
+ *
19
+ * @template Condition - The boolean condition to check
20
+ * @template Yes - The type to return if condition is false
21
+ * @template No - The type to return if condition is true (defaults to `never`)
22
+ *
23
+ * ### Result
24
+ *
25
+ * - `never`: if `Condition` is `never`
26
+ * - `Yes`: if `Condition` is `false`
27
+ * - `No`: if `Condition` is `true`
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * type Result = IfFalse<false, 'yes', 'no'> // 'yes'
32
+ * type Result2 = IfFalse<true, 'yes', 'no'> // 'no'
33
+ * type BoolResult = IfFalse<boolean, 'yes', 'no'> // boolean
34
+ * ```
35
+ */
36
+ export type IfFalse<Condition extends boolean, Yes, No = never> = Condition extends false ? Yes : No;
37
+ //# sourceMappingURL=if.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"if.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/if.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,EAAE,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,SAAS,SAAS,IAAI,GAAG,GAAG,GAAG,EAAE,CAAA;AAE9F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,OAAO,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,IAAI,SAAS,SAAS,KAAK,GAAG,GAAG,GAAG,EAAE,CAAA"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=set.js.map
3
+ //# sourceMappingURL=if.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"if.js","sourceRoot":"","sources":["../../../src/utils/logic/if.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Conditional type - returns `Yes` if condition `Condition` is true, otherwise returns `No`\n *\n * @template Condition - The boolean condition to check\n * @template Yes - The type to return if condition is true\n * @template No - The type to return if condition is false (defaults to `never`)\n *\n * @example\n * ```ts\n * type Result = If<true, 'yes', 'no'> // 'yes'\n * type Result2 = If<false, 'yes', 'no'> // 'no'\n * type BoolResult = If<boolean, 'yes', 'no'> // boolean\n * ```\n */\nexport type If<Condition extends boolean, Yes, No = never> = Condition extends true ? Yes : No\n\n/**\n * Conditional type - returns `Yes` if condition `Condition` is false, otherwise returns `No`\n *\n * @template Condition - The boolean condition to check\n * @template Yes - The type to return if condition is false\n * @template No - The type to return if condition is true (defaults to `never`)\n *\n * ### Result\n *\n * - `never`: if `Condition` is `never`\n * - `Yes`: if `Condition` is `false`\n * - `No`: if `Condition` is `true`\n *\n * @example\n * ```ts\n * type Result = IfFalse<false, 'yes', 'no'> // 'yes'\n * type Result2 = IfFalse<true, 'yes', 'no'> // 'no'\n * type BoolResult = IfFalse<boolean, 'yes', 'no'> // boolean\n * ```\n */\nexport type IfFalse<Condition extends boolean, Yes, No = never> = Condition extends false ? Yes : No\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './assert.js';
2
+ export * from './if.js';
3
+ export * from './switch.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Index start >>>>>>>>>>>>>>>>
18
+ __exportStar(require("./assert.js"), exports);
19
+ __exportStar(require("./if.js"), exports);
20
+ __exportStar(require("./switch.js"), exports);
21
+ // <<<<<<<<<<<<<<<< Index end
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,8CAA2B;AAC3B,0CAAuB;AACvB,8CAA2B;AAC3B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './assert.js'\nexport * from './if.js'\nexport * from './switch.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
@@ -0,0 +1,87 @@
1
+ import type { Exact } from '../index.js';
2
+ /**
3
+ * Case tuple type used with `SwitchExact` and `SwitchExtends`
4
+ *
5
+ * @template T - The condition type to match against
6
+ * @template Result - The result type to return if match is found
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * type MyCase = Case<1, 'one'>
11
+ * // Equivalent to: [1, 'one']
12
+ * ```
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'
17
+ * type NameMap<id> = SwitchExact<id, [
18
+ * [1, 'Alice'],
19
+ * [2, 'Bob'],
20
+ * ], DefaultCase<'Steve'>>
21
+ * ```
22
+ *
23
+ * @see SwitchExact
24
+ */
25
+ export type Case<T = unknown, Result = unknown> = [T, Result];
26
+ /**
27
+ * Default case type used with `SwitchExact` and `SwitchExtends`
28
+ *
29
+ * @template T - The default result type
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'
34
+ * type NameMap<id> = SwitchExact<id, [
35
+ * [1, 'Alice'],
36
+ * [2, 'Bob'],
37
+ * ], DefaultCase<'Steve'>>
38
+ * ```
39
+ *
40
+ * @see SwitchExact
41
+ */
42
+ export type DefaultCase<T> = T;
43
+ /**
44
+ * Switch type that uses exact matching logic
45
+ *
46
+ * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.
47
+ *
48
+ * @template T - The type to match against cases
49
+ * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]
50
+ * @template Default - Default result if no exact match is found (defaults to `never`)
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'
55
+ * type Result = SwitchExact<2, [
56
+ * [1, 'Alice'],
57
+ * [2, 'Bob'],
58
+ * [3, 'Charlie'],
59
+ * ], DefaultCase<'Steve'>>
60
+ *
61
+ * // Result: 'Bob'
62
+ * ```
63
+ */
64
+ export type SwitchExact<T, Cases extends readonly [unknown, unknown][], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result : (SwitchExact<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>)) : (never)) : Default;
65
+ /**
66
+ * Switch type that uses 'extends' logic instead of 'Exact' logic
67
+ *
68
+ * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.
69
+ *
70
+ * @template T - The type to match against cases
71
+ * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]
72
+ * @template Default - Default result if no match is found (defaults to `never`)
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { expect } from '@leawind/lay-sing'
77
+ *
78
+ * expect<
79
+ * SwitchExtends<string, [
80
+ * [number, boolean],
81
+ * [string, boolean],
82
+ * ], Error>
83
+ * >().toBe<boolean>().success
84
+ * ```
85
+ */
86
+ export type SwitchExtends<T, Cases extends readonly [unknown, unknown][], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer C, infer R] ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>) : never) : Default;
87
+ //# sourceMappingURL=switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,WAAW,CACrB,CAAC,EACD,KAAK,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAC3C,OAAO,GAAG,KAAK,IACb,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAC7C,KAAK,SAAS,CAAC,MAAM,SAAS,EAAE,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,IAAI,GAAG,MAAM,GACpF,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GACvF,CAAC,KAAK,CAAC,CACZ,GACC,OAAO,CAAA;AAEX;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,aAAa,CACvB,CAAC,EACD,KAAK,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAC3C,OAAO,GAAG,KAAK,IACb,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CAC7C,KAAK,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC5B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,GAC5G,KAAK,CACV,GACC,OAAO,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/utils/logic/switch.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Case tuple type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The condition type to match against\n * @template Result - The result type to return if match is found\n *\n * @example\n * ```ts\n * type MyCase = Case<1, 'one'>\n * // Equivalent to: [1, 'one']\n * ```\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type Case<T = unknown, Result = unknown> = [T, Result]\n\n/**\n * Default case type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The default result type\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type DefaultCase<T> = T\n\n/**\n * Switch type that uses exact matching logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no exact match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type Result = SwitchExact<2, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * [3, 'Charlie'],\n * ], DefaultCase<'Steve'>>\n *\n * // Result: 'Bob'\n * ```\n */\nexport type SwitchExact<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result\n : (SwitchExact<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>))\n : (never)\n )\n : Default\n\n/**\n * Switch type that uses 'extends' logic instead of 'Exact' logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<\n * SwitchExtends<string, [\n * [number, boolean],\n * [string, boolean],\n * ], Error>\n * >().toBe<boolean>().success\n * ```\n */\nexport type SwitchExtends<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer C, infer R]\n ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>)\n : never\n )\n : Default\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './keys.js';
2
+ export * from './pick.js';
3
+ export * from './props.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/object/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
@@ -15,7 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // Index start >>>>>>>>>>>>>>>>
18
- __exportStar(require("./compare.js"), exports);
19
- __exportStar(require("./set.js"), exports);
18
+ __exportStar(require("./keys.js"), exports);
19
+ __exportStar(require("./pick.js"), exports);
20
+ __exportStar(require("./props.js"), exports);
20
21
  // <<<<<<<<<<<<<<<< Index end
21
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/object/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,4CAAyB;AACzB,4CAAyB;AACzB,6CAA0B;AAC1B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './keys.js'\nexport * from './pick.js'\nexport * from './props.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}