lay-sing 0.2.0 → 0.2.1

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 (92) hide show
  1. package/README.md +55 -16
  2. package/esm/main/async.d.ts +9 -1
  3. package/esm/main/async.d.ts.map +1 -1
  4. package/esm/main/async.js.map +1 -1
  5. package/esm/main/boolean.d.ts +43 -19
  6. package/esm/main/boolean.d.ts.map +1 -1
  7. package/esm/main/boolean.js.map +1 -1
  8. package/esm/main/control.d.ts +65 -36
  9. package/esm/main/control.d.ts.map +1 -1
  10. package/esm/main/control.js.map +1 -1
  11. package/esm/main/doc.d.ts +33 -7
  12. package/esm/main/doc.d.ts.map +1 -1
  13. package/esm/main/doc.js.map +1 -1
  14. package/esm/main/function.d.ts +11 -3
  15. package/esm/main/function.d.ts.map +1 -1
  16. package/esm/main/function.js +0 -1
  17. package/esm/main/function.js.map +1 -1
  18. package/esm/main/index.d.ts +5 -0
  19. package/esm/main/index.d.ts.map +1 -1
  20. package/esm/main/index.js +5 -0
  21. package/esm/main/index.js.map +1 -1
  22. package/esm/main/key.d.ts +20 -18
  23. package/esm/main/key.d.ts.map +1 -1
  24. package/esm/main/key.js.map +1 -1
  25. package/esm/main/object.d.ts +57 -32
  26. package/esm/main/object.d.ts.map +1 -1
  27. package/esm/main/object.js.map +1 -1
  28. package/esm/main/tuple.d.ts +30 -6
  29. package/esm/main/tuple.d.ts.map +1 -1
  30. package/esm/main/tuple.js.map +1 -1
  31. package/esm/main/type/compare.d.ts +108 -18
  32. package/esm/main/type/compare.d.ts.map +1 -1
  33. package/esm/main/type/compare.js.map +1 -1
  34. package/esm/main/type/set.d.ts +15 -8
  35. package/esm/main/type/set.d.ts.map +1 -1
  36. package/esm/main/type/set.js.map +1 -1
  37. package/esm/test-utils/compare.d.ts +12 -0
  38. package/esm/test-utils/compare.d.ts.map +1 -1
  39. package/esm/test-utils/compare.js.map +1 -1
  40. package/esm/test-utils/expect.d.ts +63 -8
  41. package/esm/test-utils/expect.d.ts.map +1 -1
  42. package/esm/test-utils/expect.js.map +1 -1
  43. package/esm/test-utils/index.d.ts +5 -0
  44. package/esm/test-utils/index.d.ts.map +1 -1
  45. package/esm/test-utils/index.js +5 -1
  46. package/esm/test-utils/index.js.map +1 -1
  47. package/package.json +1 -1
  48. package/script/main/async.d.ts +9 -1
  49. package/script/main/async.d.ts.map +1 -1
  50. package/script/main/async.js.map +1 -1
  51. package/script/main/boolean.d.ts +43 -19
  52. package/script/main/boolean.d.ts.map +1 -1
  53. package/script/main/boolean.js.map +1 -1
  54. package/script/main/control.d.ts +65 -36
  55. package/script/main/control.d.ts.map +1 -1
  56. package/script/main/control.js.map +1 -1
  57. package/script/main/doc.d.ts +33 -7
  58. package/script/main/doc.d.ts.map +1 -1
  59. package/script/main/doc.js.map +1 -1
  60. package/script/main/function.d.ts +11 -3
  61. package/script/main/function.d.ts.map +1 -1
  62. package/script/main/function.js +0 -1
  63. package/script/main/function.js.map +1 -1
  64. package/script/main/index.d.ts +5 -0
  65. package/script/main/index.d.ts.map +1 -1
  66. package/script/main/index.js +5 -0
  67. package/script/main/index.js.map +1 -1
  68. package/script/main/key.d.ts +20 -18
  69. package/script/main/key.d.ts.map +1 -1
  70. package/script/main/key.js.map +1 -1
  71. package/script/main/object.d.ts +57 -32
  72. package/script/main/object.d.ts.map +1 -1
  73. package/script/main/object.js.map +1 -1
  74. package/script/main/tuple.d.ts +30 -6
  75. package/script/main/tuple.d.ts.map +1 -1
  76. package/script/main/tuple.js.map +1 -1
  77. package/script/main/type/compare.d.ts +108 -18
  78. package/script/main/type/compare.d.ts.map +1 -1
  79. package/script/main/type/compare.js.map +1 -1
  80. package/script/main/type/set.d.ts +15 -8
  81. package/script/main/type/set.d.ts.map +1 -1
  82. package/script/main/type/set.js.map +1 -1
  83. package/script/test-utils/compare.d.ts +12 -0
  84. package/script/test-utils/compare.d.ts.map +1 -1
  85. package/script/test-utils/compare.js.map +1 -1
  86. package/script/test-utils/expect.d.ts +63 -8
  87. package/script/test-utils/expect.d.ts.map +1 -1
  88. package/script/test-utils/expect.js.map +1 -1
  89. package/script/test-utils/index.d.ts +5 -0
  90. package/script/test-utils/index.d.ts.map +1 -1
  91. package/script/test-utils/index.js +5 -1
  92. package/script/test-utils/index.js.map +1 -1
package/README.md CHANGED
@@ -22,20 +22,54 @@ expect<never>().toBe<'should fail'>().success
22
22
  >
23
23
  > I know this library is quite simple and serves a specific purpose, so one of its API design principles is to minimize the cognitive load for users. You just need to remember to **start with an `expect<>()` call** and **end with some property access**. Leave the rest to editor suggestions and inline documentation.
24
24
 
25
- ## Install
25
+ ## Install & Import
26
26
 
27
- ### [NPM](https://www.npmjs.com/package/lay-sing)
27
+ <details>
28
+ <summary>NPM</summary>
28
29
 
29
30
  ```sh
30
31
  npm i -D lay-sing
31
32
  ```
32
33
 
33
34
  ```ts
34
- import type { Exact } from 'lay-sing'
35
35
  import { expect } from 'lay-sing/test-utils'
36
36
  ```
37
37
 
38
- > This library is also published to [JSR (`@leawind/lay-sing`)](https://jsr.io/@leawind/lay-sing)
38
+ </details>
39
+
40
+ <details>
41
+ <summary>Deno</summary>
42
+
43
+ ### From NPM
44
+
45
+ ```sh
46
+ deno add npm:lay-sing
47
+ ```
48
+
49
+ ```ts
50
+ import { expect } from 'lay-sing/test-utils'
51
+ ```
52
+
53
+ ### From JSR
54
+
55
+ This library is also published to [JSR (`@leawind/lay-sing`)](https://jsr.io/@leawind/lay-sing)
56
+
57
+ ```sh
58
+ deno add @leawind/lay-sing
59
+ ```
60
+
61
+ ```ts
62
+ import { expect } from '@leawind/lay-sing/test-utils'
63
+ ```
64
+
65
+ ### From Latest commit
66
+
67
+ ```ts
68
+ import { expect } from 'https://raw.githubusercontent.com/Leawind/lay-sing/refs/heads/main/src/test-utils/index.ts'
69
+ import { Exact } from 'https://raw.githubusercontent.com/Leawind/lay-sing/refs/heads/main/src/main/index.ts'
70
+ ```
71
+
72
+ </details>
39
73
 
40
74
  ---
41
75
 
@@ -44,7 +78,7 @@ import { expect } from 'lay-sing/test-utils'
44
78
  ### Testing Utilities
45
79
 
46
80
  ```ts
47
- import { compare, expect, NOOP } from 'lay-sing/test-utils'
81
+ import { expect } from 'lay-sing/test-utils'
48
82
  ```
49
83
 
50
84
  The `test-utils` module provides utilities for **compile-time** type validation. These utilities have **no runtime impact** — they always return a special [`NOOP`](https://jsr.io/@leawind/lay-sing/doc/test-utils/~/NOOP) value that safely supports almost any property access or method call.
@@ -73,22 +107,27 @@ At runtime, the function always returns the `NOOP` object, which performs **no o
73
107
  #### Common Usage
74
108
 
75
109
  ```ts
76
- // Exact equality
77
- expect<A>().toBe<B>().success // Passes only if A and B are identical
110
+ // Passes only if A and B are identical
111
+ expect<keyof { a: 2 }>().toBe<'a'>().success
78
112
 
79
- // Subtype check
80
- expect<A>().toExtend<B>().success // Passes if A extends B
113
+ // Passes if A extends B
114
+ expect<12138>().toExtend<number>().success
81
115
 
82
- // Property existence
116
+ // Passes if mutually assignable
117
+ expect<{ a: 1; b: 2 }>().toEqual<{ a: 1 } & { b: 2 }>().success
118
+
119
+ // Test property existence
83
120
  expect<{ name: string }>().toHaveKey<'name'>().success
121
+ ```
84
122
 
85
- // Primitive checks
86
- expect<true>().toBeTrue.success
87
- expect<'hello'>().toExtendString.success
123
+ Aliases:
124
+
125
+ ```ts
126
+ expect<never>().toBe<never>().success
127
+ expect<never>().toBeNever
88
128
 
89
- // Type comparison
90
- compare<A, B>().same // Available only if A ≡ B
91
- compare<A, B>().different // Available only if A ≠ B
129
+ expect<'hello'>().toExtend<string>().success
130
+ expect<'hello'>().toExtendString
92
131
  ```
93
132
 
94
133
  #### NOOP
@@ -1,5 +1,13 @@
1
1
  /**
2
- * Represents a value that can be either T or a Promise of T
2
+ * Represents a value that can be either `T` or a Promise of `T`
3
+ *
4
+ * @template T - The underlying type that may or may not be wrapped in a Promise
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * type StringOrPromise = Awaitable<string>
9
+ * // Equivalent to: string | Promise<string>
10
+ * ```
3
11
  */
4
12
  export type Awaitable<T> = Promise<T> | T;
5
13
  //# sourceMappingURL=async.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a value that can be either T or a Promise of T\n */\nexport type Awaitable<T> = Promise<T> | T\n"]}
1
+ {"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/main/async.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a value that can be either `T` or a Promise of `T`\n *\n * @template T - The underlying type that may or may not be wrapped in a Promise\n *\n * @example\n * ```ts\n * type StringOrPromise = Awaitable<string>\n * // Equivalent to: string | Promise<string>\n * ```\n */\nexport type Awaitable<T> = Promise<T> | T\n"]}
@@ -1,35 +1,59 @@
1
1
  /**
2
- * ### Result
2
+ * Negates a boolean type
3
3
  *
4
- * - `never`: if `T` is `never`
5
- * - `boolean`: if `T` is `boolean` or `any`
6
- * - `false`: if `T` is `true`
7
- * - `true`: if `T` is `false`
4
+ * @template T - The boolean type to negate
8
5
  *
9
6
  * @example
10
- * | `T` | `Not<T>` |
11
- * | --------- | --------- |
12
- * | `never` | `never` |
13
- * | `true` | `false` |
14
- * | `false` | `true` |
15
- * | `boolean` | `boolean` |
16
- * | `any` | `boolean` |
7
+ * ```ts
8
+ * import { expect } from '@leawind/lay-sing/test-utils'
9
+ *
10
+ * expect<Not<true>>().toBeFalse
11
+ * expect<Not<false>>().toBeTrue
12
+ * expect<Not<boolean>>().toBe<boolean>().success
13
+ * ```
17
14
  */
18
15
  export type Not<T extends boolean> = T extends true ? false : T extends false ? true : boolean;
19
16
  /**
20
- * - `never`: if anyone of A,B is `never`
21
- * - `boolean`: if anyone of A,B is `boolean` or `any`
22
- * - `true`: if both A,B are `true`
23
- * - `false`: otherwise
17
+ * Logical AND operation on two boolean types
18
+ *
19
+ * @template A - The first boolean type to compare
20
+ * @template B - The second boolean type to compare
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { expect } from '@leawind/lay-sing/test-utils'
25
+ *
26
+ * expect<And<true, true>>().toBeTrue
27
+ * expect<And<true, false>>().toBeFalse
28
+ * expect<And<false, true>>().toBeFalse
29
+ * expect<And<false, false>>().toBeFalse
30
+ * expect<And<boolean, boolean>>().toBe<boolean>().success
31
+ * ```
24
32
  */
25
33
  export type And<A extends boolean, B extends boolean> = A extends never ? never : [B] extends [never] ? never : (A extends true ? (B extends true ? true : false) : false);
26
34
  /**
35
+ * Logical OR operation on two boolean types
36
+ *
37
+ * @template A - The first boolean type to compare
38
+ * @template B - The second boolean type to compare
39
+ *
27
40
  * ### Result
28
41
  *
29
- * - `never`: if anyone of A,B is `never`
30
- * - `boolean`: if anyone of A,B is `boolean` or `any`
31
- * - `false`: if both A,B are `false`
42
+ * - `never`: if either `A` or `B` is `never`
43
+ * - `boolean`: if either `A` or `B` is `boolean` or `any`
44
+ * - `false`: if both `A` and `B` are `false`
32
45
  * - `true`: otherwise
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { expect } from '@leawind/lay-sing/test-utils'
50
+ *
51
+ * expect<Or<true, true>>().toBeTrue
52
+ * expect<Or<true, false>>().toBeTrue
53
+ * expect<Or<false, true>>().toBeTrue
54
+ * expect<Or<false, false>>().toBeFalse
55
+ * expect<Or<boolean, false>>().toBe<boolean>().success
56
+ * ```
33
57
  */
34
58
  export type Or<A extends boolean, B extends boolean> = [A] extends [never] ? never : [B] extends [never] ? never : [boolean] extends [A] ? boolean : [boolean] extends [B] ? boolean : true extends A ? true : true extends B ? true : false;
35
59
  //# sourceMappingURL=boolean.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,GACvD,CAAC,SAAS,KAAK,GAAG,IAAI,GACtB,OAAO,CAAA;AAEX;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,KAAK,GAAG,KAAK,GACvB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;AAE9D;;;;;;;GAOG;AACH,MAAM,MAAM,EAAE,CACZ,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,KAAK,CAAA"}
1
+ {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,GACvD,CAAC,SAAS,KAAK,GAAG,IAAI,GACtB,OAAO,CAAA;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,KAAK,GAAG,KAAK,GACvB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,EAAE,CACZ,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,KAAK,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * ### Result\n *\n * - `never`: if `T` is `never`\n * - `boolean`: if `T` is `boolean` or `any`\n * - `false`: if `T` is `true`\n * - `true`: if `T` is `false`\n *\n * @example\n * | `T` | `Not<T>` |\n * | --------- | --------- |\n * | `never` | `never` |\n * | `true` | `false` |\n * | `false` | `true` |\n * | `boolean` | `boolean` |\n * | `any` | `boolean` |\n */\nexport type Not<T extends boolean> = T extends true ? false\n : T extends false ? true\n : boolean\n\n/**\n * - `never`: if anyone of A,B is `never`\n * - `boolean`: if anyone of A,B is `boolean` or `any`\n * - `true`: if both A,B are `true`\n * - `false`: otherwise\n */\nexport type And<\n A extends boolean,\n B extends boolean,\n> = A extends never ? never\n : [B] extends [never] ? never\n : (A extends true ? (B extends true ? true : false) : false)\n\n/**\n * ### Result\n *\n * - `never`: if anyone of A,B is `never`\n * - `boolean`: if anyone of A,B is `boolean` or `any`\n * - `false`: if both A,B are `false`\n * - `true`: otherwise\n */\nexport type Or<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? true\n : true extends B ? true\n : false\n"]}
1
+ {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/main/boolean.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Negates a boolean type\n *\n * @template T - The boolean type to negate\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<Not<true>>().toBeFalse\n * expect<Not<false>>().toBeTrue\n * expect<Not<boolean>>().toBe<boolean>().success\n * ```\n */\nexport type Not<T extends boolean> = T extends true ? false\n : T extends false ? true\n : boolean\n\n/**\n * Logical AND operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<And<true, true>>().toBeTrue\n * expect<And<true, false>>().toBeFalse\n * expect<And<false, true>>().toBeFalse\n * expect<And<false, false>>().toBeFalse\n * expect<And<boolean, boolean>>().toBe<boolean>().success\n * ```\n */\nexport type And<\n A extends boolean,\n B extends boolean,\n> = A extends never ? never\n : [B] extends [never] ? never\n : (A extends true ? (B extends true ? true : false) : false)\n\n/**\n * Logical OR operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * ### Result\n *\n * - `never`: if either `A` or `B` is `never`\n * - `boolean`: if either `A` or `B` is `boolean` or `any`\n * - `false`: if both `A` and `B` are `false`\n * - `true`: otherwise\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * expect<Or<true, true>>().toBeTrue\n * expect<Or<true, false>>().toBeTrue\n * expect<Or<false, true>>().toBeTrue\n * expect<Or<false, false>>().toBeFalse\n * expect<Or<boolean, false>>().toBe<boolean>().success\n * ```\n */\nexport type Or<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? true\n : true extends B ? true\n : false\n"]}
@@ -1,83 +1,112 @@
1
1
  import type { Exact } from './type/compare.js';
2
2
  /**
3
- * Conditional type - returns `T` if condition `C` is true, otherwise returns `F`
3
+ * Conditional type - returns `Yes` if condition `Condition` is true, otherwise returns `No`
4
4
  *
5
- * ### Result
6
- *
7
- * - `never`: if `C` is `never`
8
- * - `Yes`: if `C` is `true`
9
- * - `No`: if `C` is `false`
5
+ * @template Condition - The boolean condition to check
6
+ * @template Yes - The type to return if condition is true
7
+ * @template No - The type to return if condition is false (defaults to `never`)
10
8
  *
11
9
  * @example
12
10
  * ```ts
13
11
  * type Result = If<true, 'yes', 'no'> // 'yes'
14
12
  * type Result2 = If<false, 'yes', 'no'> // 'no'
15
- * type NeverResult = If<never, 'yes', 'no'> // never
13
+ * type BoolResult = If<boolean, 'yes', 'no'> // boolean
16
14
  * ```
17
15
  */
18
- export type If<Condition extends boolean, Yes, No = never> = [Condition] extends [never] ? never : Condition extends true ? Yes : No;
16
+ export type If<Condition extends boolean, Yes, No = never> = Condition extends true ? Yes : No;
19
17
  /**
20
- * Conditional type - returns `T` if condition `C` is false, otherwise returns `F`
18
+ * Conditional type - returns `Yes` if condition `Condition` is false, otherwise returns `No`
19
+ *
20
+ * @template Condition - The boolean condition to check
21
+ * @template Yes - The type to return if condition is false
22
+ * @template No - The type to return if condition is true (defaults to `never`)
21
23
  *
22
24
  * ### Result
23
25
  *
24
- * - `never`: if `C` is `never`
25
- * - `Yes`: if `C` is `false`
26
- * - `No`: if `C` is `true`
26
+ * - `never`: if `Condition` is `never`
27
+ * - `Yes`: if `Condition` is `false`
28
+ * - `No`: if `Condition` is `true`
27
29
  *
28
30
  * @example
29
31
  * ```ts
30
32
  * type Result = IfFalse<false, 'yes', 'no'> // 'yes'
31
33
  * type Result2 = IfFalse<true, 'yes', 'no'> // 'no'
32
- * type NeverResult = IfFalse<never, 'yes', 'no'> // never
34
+ * type BoolResult = IfFalse<boolean, 'yes', 'no'> // boolean
33
35
  * ```
34
36
  */
35
- export type IfFalse<Condition extends boolean, Yes, No = never> = [Condition] extends [never] ? never : Condition extends false ? Yes : No;
37
+ export type IfFalse<Condition extends boolean, Yes, No = never> = Condition extends false ? Yes : No;
36
38
  /**
37
- * Used with:
38
- * - {@link Switch}
39
- * - {@link SwitchExtends}
39
+ * Case tuple type used with `SwitchExact` and `SwitchExtends`
40
+ *
41
+ * @template T - The condition type to match against
42
+ * @template Result - The result type to return if match is found
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * type MyCase = Case<1, 'one'>
47
+ * // Equivalent to: [1, 'one']
48
+ * ```
49
+ *
50
+ * @see SwitchExact
40
51
  */
41
52
  export type Case<T = unknown, Result = unknown> = [T, Result];
42
53
  /**
43
- * Used with:
54
+ * Default case type used with `SwitchExact` and `SwitchExtends`
44
55
  *
45
- * - {@link Switch}
46
- * - {@link SwitchExtends}
56
+ * @template T - The default result type
47
57
  *
48
58
  * @example
49
59
  * ```ts
50
- * type NameMap<id> = Switch<id, [
51
- * Case<1, 'Alice'>,
52
- * Case<2, 'Bob'>,
53
- * Case<3, 'Charlie'>,
60
+ * type NameMap<id> = SwitchExact<id, [
61
+ * [1, 'Alice'],
62
+ * [2, 'Bob'],
54
63
  * ], DefaultCase<'Steve'>>
55
64
  * ```
65
+ *
66
+ * @see SwitchExact
56
67
  */
57
68
  export type DefaultCase<T> = T;
58
69
  /**
70
+ * Switch type that uses exact matching logic
71
+ *
72
+ * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.
73
+ *
74
+ * @template T - The type to match against cases
75
+ * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]
76
+ * @template Default - Default result if no exact match is found (defaults to `never`)
77
+ *
59
78
  * @example
60
79
  * ```ts
61
- * type Result = Switch<2, [
62
- * Case<1, 'Alice'>,
63
- * Case<2, 'Bob'>,
64
- * Case<3, 'Charlie'>,
80
+ * type Result = SwitchExact<2, [
81
+ * [1, 'Alice'],
82
+ * [2, 'Bob'],
83
+ * [3, 'Charlie'],
65
84
  * ], DefaultCase<'Steve'>>
66
85
  *
67
86
  * // Result: 'Bob'
68
87
  * ```
69
88
  */
70
- export type Switch<T, Cases extends readonly Case[], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result : (Switch<T, Rest extends readonly Case[] ? Rest : never, Default>)) : (never)) : Default;
89
+ 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;
71
90
  /**
72
91
  * Switch type that uses 'extends' logic instead of 'Exact' logic
73
92
  *
74
- * @example ```ts
75
- * type Result = SwitchExtends<string | number, [
76
- * Case<string, 'string type'>,
77
- * Case<number, 'number type'>,
78
- * ], 'other'>
79
- * // Result: 'string type' | 'number type'
93
+ * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.
94
+ *
95
+ * @template T - The type to match against cases
96
+ * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]
97
+ * @template Default - Default result if no match is found (defaults to `never`)
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { expect } from '@leawind/lay-sing/test-utils'
102
+ *
103
+ * expect<
104
+ * SwitchExtends<string, [
105
+ * [number, boolean],
106
+ * [string, boolean],
107
+ * ], Error>
108
+ * >().toBe<boolean>().success
80
109
  * ```
81
110
  */
82
- export type SwitchExtends<T, Cases extends readonly Case[], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer C, infer R] ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly Case[] ? Rest : never, Default>) : never) : Default;
111
+ 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;
83
112
  //# sourceMappingURL=control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,EAAE,CACZ,SAAS,SAAS,OAAO,EACzB,GAAG,EACH,EAAE,GAAG,KAAK,IACR,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GACnC,SAAS,SAAS,IAAI,GAAG,GAAG,GAC5B,EAAE,CAAA;AAEN;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,OAAO,CACjB,SAAS,SAAS,OAAO,EACzB,GAAG,EACH,EAAE,GAAG,KAAK,IACR,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GACnC,SAAS,SAAS,KAAK,GAAG,GAAG,GAC7B,EAAE,CAAA;AAEN;;;;GAIG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAA;AAE9B;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,MAAM,CAChB,CAAC,EACD,KAAK,SAAS,SAAS,IAAI,EAAE,EAC7B,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,GACzC,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,IAAI,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,SAAS,SAAS,IAAI,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAC/G,CAAC,KAAK,CAAC,CACZ,GACC,OAAO,CAAA;AAEX;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,CACvB,CAAC,EACD,KAAK,SAAS,SAAS,IAAI,EAAE,EAC7B,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,IAAI,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC,GAC9F,KAAK,CACV,GACC,OAAO,CAAA"}
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C;;;;;;;;;;;;;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;AAEpG;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAA;AAE9B;;;;;;;;;;;;;;;;;;;GAmBG;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from './type/compare.js'\n\n/**\n * Conditional type - returns `T` if condition `C` is true, otherwise returns `F`\n *\n * ### Result\n *\n * - `never`: if `C` is `never`\n * - `Yes`: if `C` is `true`\n * - `No`: if `C` is `false`\n *\n * @example\n * ```ts\n * type Result = If<true, 'yes', 'no'> // 'yes'\n * type Result2 = If<false, 'yes', 'no'> // 'no'\n * type NeverResult = If<never, 'yes', 'no'> // never\n * ```\n */\nexport type If<\n Condition extends boolean,\n Yes,\n No = never,\n> = [Condition] extends [never] ? never\n : Condition extends true ? Yes\n : No\n\n/**\n * Conditional type - returns `T` if condition `C` is false, otherwise returns `F`\n *\n * ### Result\n *\n * - `never`: if `C` is `never`\n * - `Yes`: if `C` is `false`\n * - `No`: if `C` 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 NeverResult = IfFalse<never, 'yes', 'no'> // never\n * ```\n */\nexport type IfFalse<\n Condition extends boolean,\n Yes,\n No = never,\n> = [Condition] extends [never] ? never\n : Condition extends false ? Yes\n : No\n\n/**\n * Used with:\n * - {@link Switch}\n * - {@link SwitchExtends}\n */\nexport type Case<T = unknown, Result = unknown> = [T, Result]\n\n/**\n * Used with:\n *\n * - {@link Switch}\n * - {@link SwitchExtends}\n *\n * @example\n * ```ts\n * type NameMap<id> = Switch<id, [\n * Case<1, 'Alice'>,\n * Case<2, 'Bob'>,\n * Case<3, 'Charlie'>,\n * ], DefaultCase<'Steve'>>\n * ```\n */\nexport type DefaultCase<T> = T\n\n/**\n * @example\n * ```ts\n * type Result = Switch<2, [\n * Case<1, 'Alice'>,\n * Case<2, 'Bob'>,\n * Case<3, 'Charlie'>,\n * ], DefaultCase<'Steve'>>\n *\n * // Result: 'Bob'\n * ```\n */\nexport type Switch<\n T,\n Cases extends readonly Case[],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer Condition, infer Result]\n ? (Exact<T, Condition> extends true ? Result : (Switch<T, Rest extends readonly Case[] ? Rest : never, Default>))\n : (never)\n )\n : Default\n\n/**\n * Switch type that uses 'extends' logic instead of 'Exact' logic\n *\n * @example ```ts\n * type Result = SwitchExtends<string | number, [\n * Case<string, 'string type'>,\n * Case<number, 'number type'>,\n * ], 'other'>\n * // Result: 'string type' | 'number type'\n * ```\n */\nexport type SwitchExtends<\n T,\n Cases extends readonly Case[],\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 Case[] ? Rest : never, Default>)\n : never\n )\n : Default\n"]}
1
+ {"version":3,"file":"control.js","sourceRoot":"","sources":["../../src/main/control.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from './type/compare.js'\n\n/**\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\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 * @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 * 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 * 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/test-utils'\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"]}
package/esm/main/doc.d.ts CHANGED
@@ -1,30 +1,56 @@
1
1
  /**
2
- * Append documentation or auxiliary metadata to type `A`
2
+ * Append documentation or auxiliary metadata to type `T`
3
3
  * without changing its shape.
4
4
  *
5
- * This type intersects `Doc` onto `A`, but only keeps the keys
6
- * originally defined in `A`. As a result:
5
+ * This type intersects `Doc` onto `T`, but only keeps the keys
6
+ * originally defined in `T`. As a result:
7
7
  *
8
8
  * - `Doc` cannot introduce new properties
9
- * - Existing properties in `A` are preserved
9
+ * - Existing properties in `T` are preserved
10
10
  * - `Doc` may further constrain or annotate existing properties
11
11
  *
12
12
  * This is typically used to attach JSDoc comments, branding,
13
13
  * or editor-only metadata to an existing type while keeping
14
14
  * its public structure intact.
15
+ *
16
+ * @template T - The target type to append documentation to
17
+ * @template Doc - The documentation or metadata type to append
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { expect } from '@leawind/lay-sing/test-utils'
22
+ *
23
+ * type User = { name: string; age: number }
24
+ * type UserWithDoc = AppendDoc<User, { name: string }>
25
+ *
26
+ * expect<UserWithDoc>().toBe<User>().success
27
+ * ```
15
28
  */
16
29
  export type AppendDoc<T, Doc> = Pick<T & Doc, keyof T>;
17
30
  /**
18
- * Prepend documentation or auxiliary metadata to type `A`
31
+ * Prepend documentation or auxiliary metadata to type `T`
19
32
  * without changing its shape.
20
33
  *
21
34
  * This is similar to {@link AppendDoc}, but the intersection order
22
- * is reversed (`Doc & A`), which can affect how property types,
35
+ * is reversed (`Doc & T`), which can affect how property types,
23
36
  * documentation, and hover information are presented by tooling.
24
37
  *
25
38
  * In practice, this allows `Doc` to act as a non-invasive,
26
- * descriptive layer while ensuring `A` remains the authoritative
39
+ * descriptive layer while ensuring `T` remains the authoritative
27
40
  * source of truth for property types.
41
+ *
42
+ * @template T - The target type to prepend documentation to
43
+ * @template Doc - The documentation or metadata type to prepend
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { expect } from '@leawind/lay-sing/test-utils'
48
+ *
49
+ * type User = { name: string; age: number }
50
+ * type UserWithDoc = PrependDoc<User, { age: number }>
51
+ *
52
+ * expect<UserWithDoc>().toBe<User>().success
53
+ * ```
28
54
  */
29
55
  export type PrependDoc<T, Doc> = Pick<Doc & T, keyof T>;
30
56
  //# sourceMappingURL=doc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/main/doc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/main/doc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/main/doc.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Append documentation or auxiliary metadata to type `A`\n * without changing its shape.\n *\n * This type intersects `Doc` onto `A`, but only keeps the keys\n * originally defined in `A`. As a result:\n *\n * - `Doc` cannot introduce new properties\n * - Existing properties in `A` are preserved\n * - `Doc` may further constrain or annotate existing properties\n *\n * This is typically used to attach JSDoc comments, branding,\n * or editor-only metadata to an existing type while keeping\n * its public structure intact.\n */\nexport type AppendDoc<T, Doc> = Pick<T & Doc, keyof T>\n\n/**\n * Prepend documentation or auxiliary metadata to type `A`\n * without changing its shape.\n *\n * This is similar to {@link AppendDoc}, but the intersection order\n * is reversed (`Doc & A`), which can affect how property types,\n * documentation, and hover information are presented by tooling.\n *\n * In practice, this allows `Doc` to act as a non-invasive,\n * descriptive layer while ensuring `A` remains the authoritative\n * source of truth for property types.\n */\nexport type PrependDoc<T, Doc> = Pick<Doc & T, keyof T>\n"]}
1
+ {"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/main/doc.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Append documentation or auxiliary metadata to type `T`\n * without changing its shape.\n *\n * This type intersects `Doc` onto `T`, but only keeps the keys\n * originally defined in `T`. As a result:\n *\n * - `Doc` cannot introduce new properties\n * - Existing properties in `T` are preserved\n * - `Doc` may further constrain or annotate existing properties\n *\n * This is typically used to attach JSDoc comments, branding,\n * or editor-only metadata to an existing type while keeping\n * its public structure intact.\n *\n * @template T - The target type to append documentation to\n * @template Doc - The documentation or metadata type to append\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * type User = { name: string; age: number }\n * type UserWithDoc = AppendDoc<User, { name: string }>\n *\n * expect<UserWithDoc>().toBe<User>().success\n * ```\n */\nexport type AppendDoc<T, Doc> = Pick<T & Doc, keyof T>\n\n/**\n * Prepend documentation or auxiliary metadata to type `T`\n * without changing its shape.\n *\n * This is similar to {@link AppendDoc}, but the intersection order\n * is reversed (`Doc & T`), which can affect how property types,\n * documentation, and hover information are presented by tooling.\n *\n * In practice, this allows `Doc` to act as a non-invasive,\n * descriptive layer while ensuring `T` remains the authoritative\n * source of truth for property types.\n *\n * @template T - The target type to prepend documentation to\n * @template Doc - The documentation or metadata type to prepend\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing/test-utils'\n *\n * type User = { name: string; age: number }\n * type UserWithDoc = PrependDoc<User, { age: number }>\n *\n * expect<UserWithDoc>().toBe<User>().success\n * ```\n */\nexport type PrependDoc<T, Doc> = Pick<Doc & T, keyof T>\n"]}
@@ -1,18 +1,26 @@
1
1
  /**
2
2
  * Represents a function with any parameters and a specific return type
3
3
  *
4
+ * @template Return - The return type of the function
5
+ * @template Params - The parameters of the function as a tuple type
6
+ *
4
7
  * @example
5
8
  * ```ts
6
- * type _ = AnyFunction<string, [number]> // (arg: number) => string
9
+ * type NumberToStringFn = AnyFunction<string, [number]>
10
+ * // Equivalent to: (arg: number) => string
7
11
  * ```
8
12
  */
9
13
  export type AnyFunction<Return = any, Params extends any[] = any[]> = (...args: Params) => Return;
10
14
  /**
11
- * Represents a constructor with any parameters and a specific return type
15
+ * Represents a constructor function with any parameters and a specific return type
16
+ *
17
+ * @template Return - The type returned by the constructor function
18
+ * @template Params - The parameters of the constructor function as a tuple type
12
19
  *
13
20
  * @example
14
21
  * ```ts
15
- * type _ = Constructor<string, [number]> // new (arg: number) => string
22
+ * type StringConstructor = Constructor<string, [number]>
23
+ * // Equivalent to: new (arg: number) => string
16
24
  * ```
17
25
  */
18
26
  export type Constructor<Return = any, Params extends any[] = any[]> = new (...args: Params) => Return;
@@ -1 +1 @@
1
- {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/main/function.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CACrB,MAAM,GAAG,GAAG,EACZ,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,IAC1B,CAAC,GAAG,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;AAE/B;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CACrB,MAAM,GAAG,GAAG,EACZ,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,IAC1B,KAAK,GAAG,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA"}
1
+ {"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/main/function.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,CACrB,MAAM,GAAG,GAAG,EACZ,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,IAC1B,CAAC,GAAG,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;AAE/B;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,CACrB,MAAM,GAAG,GAAG,EACZ,MAAM,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,IAC1B,KAAK,GAAG,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA"}
@@ -1,3 +1,2 @@
1
- // deno-lint-ignore-file no-explicit-any
2
1
  export {};
3
2
  //# sourceMappingURL=function.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/main/function.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["// deno-lint-ignore-file no-explicit-any\n\n/**\n * Represents a function with any parameters and a specific return type\n *\n * @example\n * ```ts\n * type _ = AnyFunction<string, [number]> // (arg: number) => string\n * ```\n */\nexport type AnyFunction<\n Return = any,\n Params extends any[] = any[],\n> = (...args: Params) => Return\n\n/**\n * Represents a constructor with any parameters and a specific return type\n *\n * @example\n * ```ts\n * type _ = Constructor<string, [number]> // new (arg: number) => string\n * ```\n */\nexport type Constructor<\n Return = any,\n Params extends any[] = any[],\n> = new (...args: Params) => Return\n"]}
1
+ {"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/main/function.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a function with any parameters and a specific return type\n *\n * @template Return - The return type of the function\n * @template Params - The parameters of the function as a tuple type\n *\n * @example\n * ```ts\n * type NumberToStringFn = AnyFunction<string, [number]>\n * // Equivalent to: (arg: number) => string\n * ```\n */\nexport type AnyFunction<\n Return = any,\n Params extends any[] = any[],\n> = (...args: Params) => Return\n\n/**\n * Represents a constructor function with any parameters and a specific return type\n *\n * @template Return - The type returned by the constructor function\n * @template Params - The parameters of the constructor function as a tuple type\n *\n * @example\n * ```ts\n * type StringConstructor = Constructor<string, [number]>\n * // Equivalent to: new (arg: number) => string\n * ```\n */\nexport type Constructor<\n Return = any,\n Params extends any[] = any[],\n> = new (...args: Params) => Return\n"]}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
3
+ *
4
+ * @module
5
+ */
1
6
  export * from './async.js';
2
7
  export * from './boolean.js';
3
8
  export * from './control.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AACA,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;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"}
package/esm/main/index.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * [Full API documentation is available on JSR](https://jsr.io/@leawind/lay-sing/doc)
3
+ *
4
+ * @module
5
+ */
1
6
  // Index start >>>>>>>>>>>>>>>>
2
7
  export * from './async.js';
3
8
  export * from './boolean.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,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;AAChC,+BAA+B","sourcesContent":["// 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;AAEH,+BAA+B;AAC/B,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;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"]}