@sinclair/typebox 0.32.0-dev-25 → 0.32.0-dev-27

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 (206) hide show
  1. package/build/import/errors/errors.mjs +2 -2
  2. package/build/import/errors/function.d.mts +13 -3
  3. package/build/import/errors/function.mjs +39 -39
  4. package/build/import/index.d.mts +2 -2
  5. package/build/import/type/awaited/awaited.mjs +2 -6
  6. package/build/import/type/composite/composite.d.mts +1 -2
  7. package/build/import/type/composite/composite.mjs +2 -2
  8. package/build/import/type/const/const.mjs +6 -6
  9. package/build/import/type/constructor/constructor.d.mts +1 -1
  10. package/build/import/type/constructor/constructor.mjs +1 -1
  11. package/build/import/type/deref/deref.mjs +1 -2
  12. package/build/import/type/discard/discard.mjs +2 -2
  13. package/build/import/type/enum/enum.mjs +3 -0
  14. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +5 -5
  15. package/build/import/type/exclude/exclude-from-mapped-result.mjs +7 -7
  16. package/build/import/type/exclude/exclude.mjs +0 -1
  17. package/build/import/type/extends/extends-from-mapped-key.d.mts +1 -1
  18. package/build/import/type/extends/extends-from-mapped-key.mjs +4 -5
  19. package/build/import/type/extends/extends-from-mapped-result.d.mts +5 -5
  20. package/build/import/type/extends/extends-from-mapped-result.mjs +7 -7
  21. package/build/import/type/extends/extends.mjs +0 -1
  22. package/build/import/type/extract/extract-from-mapped-result.d.mts +5 -5
  23. package/build/import/type/extract/extract-from-mapped-result.mjs +7 -7
  24. package/build/import/type/extract/extract.d.mts +1 -2
  25. package/build/import/type/extract/extract.mjs +4 -2
  26. package/build/import/type/index.d.mts +1 -1
  27. package/build/import/type/index.mjs +1 -1
  28. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
  29. package/build/import/type/indexed/indexed-from-mapped-key.mjs +4 -5
  30. package/build/import/type/indexed/indexed-from-mapped-result.d.mts +2 -2
  31. package/build/import/type/indexed/indexed-from-mapped-result.mjs +1 -1
  32. package/build/import/type/indexed/indexed-property-keys.d.mts +6 -6
  33. package/build/import/type/indexed/indexed-property-keys.mjs +3 -5
  34. package/build/import/type/indexed/indexed.d.mts +1 -1
  35. package/build/import/type/indexed/indexed.mjs +9 -27
  36. package/build/import/type/intersect/intersect-evaluated.mjs +3 -13
  37. package/build/import/type/intrinsic/capitalize.d.mts +2 -2
  38. package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +1 -1
  39. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -5
  40. package/build/import/type/intrinsic/intrinsic.d.mts +2 -3
  41. package/build/import/type/intrinsic/intrinsic.mjs +2 -5
  42. package/build/import/type/intrinsic/lowercase.d.mts +2 -2
  43. package/build/import/type/intrinsic/uncapitalize.d.mts +2 -2
  44. package/build/import/type/intrinsic/uppercase.d.mts +2 -2
  45. package/build/import/type/iterator/iterator.mjs +1 -1
  46. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -3
  47. package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -4
  48. package/build/import/type/keyof/keyof-property-keys.d.mts +3 -3
  49. package/build/import/type/keyof/keyof-property-keys.mjs +9 -15
  50. package/build/import/type/keyof/keyof.mjs +2 -8
  51. package/build/import/type/mapped/mapped.d.mts +6 -1
  52. package/build/import/type/mapped/mapped.mjs +21 -14
  53. package/build/import/type/not/not.mjs +1 -1
  54. package/build/import/type/object/object.d.mts +1 -1
  55. package/build/import/type/object/object.mjs +0 -1
  56. package/build/import/type/omit/index.d.mts +1 -0
  57. package/build/import/type/omit/index.mjs +1 -0
  58. package/build/import/type/omit/omit-from-mapped-key.mjs +4 -5
  59. package/build/import/type/omit/omit-from-mapped-result.d.mts +11 -0
  60. package/build/import/type/omit/omit-from-mapped-result.mjs +17 -0
  61. package/build/import/type/omit/omit.d.mts +6 -3
  62. package/build/import/type/omit/omit.mjs +11 -9
  63. package/build/import/type/optional/optional-from-mapped-result.d.mts +5 -5
  64. package/build/import/type/optional/optional-from-mapped-result.mjs +7 -7
  65. package/build/import/type/partial/partial-from-mapped-result.d.mts +5 -5
  66. package/build/import/type/partial/partial-from-mapped-result.mjs +4 -4
  67. package/build/import/type/partial/partial.d.mts +2 -3
  68. package/build/import/type/partial/partial.mjs +8 -21
  69. package/build/import/type/pick/index.d.mts +1 -0
  70. package/build/import/type/pick/index.mjs +1 -0
  71. package/build/import/type/pick/pick-from-mapped-key.mjs +4 -5
  72. package/build/import/type/pick/pick-from-mapped-result.d.mts +11 -0
  73. package/build/import/type/pick/pick-from-mapped-result.mjs +17 -0
  74. package/build/import/type/pick/pick.d.mts +5 -2
  75. package/build/import/type/pick/pick.mjs +11 -10
  76. package/build/import/type/promise/promise.mjs +1 -1
  77. package/build/import/type/readonly/readonly-from-mapped-result.d.mts +5 -5
  78. package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -4
  79. package/build/import/type/record/record.d.mts +2 -2
  80. package/build/import/type/record/record.mjs +3 -0
  81. package/build/import/type/ref/ref.mjs +1 -1
  82. package/build/import/type/required/required-from-mapped-result.d.mts +5 -5
  83. package/build/import/type/required/required-from-mapped-result.mjs +7 -7
  84. package/build/import/type/required/required.d.mts +2 -3
  85. package/build/import/type/required/required.mjs +4 -14
  86. package/build/import/type/rest/rest.d.mts +2 -2
  87. package/build/import/type/rest/rest.mjs +1 -2
  88. package/build/import/type/sets/index.d.mts +1 -0
  89. package/build/import/type/sets/index.mjs +1 -0
  90. package/build/import/type/sets/set.d.mts +24 -0
  91. package/build/import/type/sets/set.mjs +35 -0
  92. package/build/import/type/strict/strict.d.mts +1 -1
  93. package/build/import/type/strict/strict.mjs +1 -1
  94. package/build/import/type/template-literal/syntax.d.mts +1 -1
  95. package/build/import/type/template-literal/template-literal.d.mts +1 -1
  96. package/build/import/type/transform/transform.mjs +1 -1
  97. package/build/import/type/type/json.d.mts +6 -2
  98. package/build/import/type/union/union-evaluated.mjs +3 -14
  99. package/build/require/errors/errors.js +2 -2
  100. package/build/require/errors/function.d.ts +13 -3
  101. package/build/require/errors/function.js +39 -39
  102. package/build/require/index.d.ts +2 -2
  103. package/build/require/type/awaited/awaited.js +2 -6
  104. package/build/require/type/composite/composite.d.ts +1 -2
  105. package/build/require/type/composite/composite.js +5 -6
  106. package/build/require/type/const/const.js +6 -6
  107. package/build/require/type/constructor/constructor.d.ts +1 -1
  108. package/build/require/type/constructor/constructor.js +1 -1
  109. package/build/require/type/deref/deref.js +0 -1
  110. package/build/require/type/discard/discard.js +2 -2
  111. package/build/require/type/enum/enum.js +3 -0
  112. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +5 -5
  113. package/build/require/type/exclude/exclude-from-mapped-result.js +7 -7
  114. package/build/require/type/exclude/exclude.js +0 -1
  115. package/build/require/type/extends/extends-from-mapped-key.d.ts +1 -1
  116. package/build/require/type/extends/extends-from-mapped-key.js +4 -5
  117. package/build/require/type/extends/extends-from-mapped-result.d.ts +5 -5
  118. package/build/require/type/extends/extends-from-mapped-result.js +7 -7
  119. package/build/require/type/extends/extends.js +0 -1
  120. package/build/require/type/extract/extract-from-mapped-result.d.ts +5 -5
  121. package/build/require/type/extract/extract-from-mapped-result.js +7 -7
  122. package/build/require/type/extract/extract.d.ts +1 -2
  123. package/build/require/type/extract/extract.js +4 -3
  124. package/build/require/type/index.d.ts +1 -1
  125. package/build/require/type/index.js +1 -1
  126. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
  127. package/build/require/type/indexed/indexed-from-mapped-key.js +4 -5
  128. package/build/require/type/indexed/indexed-from-mapped-result.d.ts +2 -2
  129. package/build/require/type/indexed/indexed-from-mapped-result.js +1 -1
  130. package/build/require/type/indexed/indexed-property-keys.d.ts +6 -6
  131. package/build/require/type/indexed/indexed-property-keys.js +3 -5
  132. package/build/require/type/indexed/indexed.d.ts +1 -1
  133. package/build/require/type/indexed/indexed.js +9 -27
  134. package/build/require/type/intersect/intersect-evaluated.js +3 -13
  135. package/build/require/type/intrinsic/capitalize.d.ts +2 -2
  136. package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +1 -1
  137. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +4 -5
  138. package/build/require/type/intrinsic/intrinsic.d.ts +2 -3
  139. package/build/require/type/intrinsic/intrinsic.js +2 -5
  140. package/build/require/type/intrinsic/lowercase.d.ts +2 -2
  141. package/build/require/type/intrinsic/uncapitalize.d.ts +2 -2
  142. package/build/require/type/intrinsic/uppercase.d.ts +2 -2
  143. package/build/require/type/iterator/iterator.js +1 -1
  144. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -3
  145. package/build/require/type/keyof/keyof-from-mapped-result.js +4 -4
  146. package/build/require/type/keyof/keyof-property-keys.d.ts +3 -3
  147. package/build/require/type/keyof/keyof-property-keys.js +9 -15
  148. package/build/require/type/keyof/keyof.js +2 -8
  149. package/build/require/type/mapped/mapped.d.ts +6 -1
  150. package/build/require/type/mapped/mapped.js +21 -14
  151. package/build/require/type/not/not.js +1 -1
  152. package/build/require/type/object/object.d.ts +1 -1
  153. package/build/require/type/object/object.js +0 -1
  154. package/build/require/type/omit/index.d.ts +1 -0
  155. package/build/require/type/omit/index.js +1 -0
  156. package/build/require/type/omit/omit-from-mapped-key.js +4 -5
  157. package/build/require/type/omit/omit-from-mapped-result.d.ts +11 -0
  158. package/build/require/type/omit/omit-from-mapped-result.js +22 -0
  159. package/build/require/type/omit/omit.d.ts +6 -3
  160. package/build/require/type/omit/omit.js +10 -8
  161. package/build/require/type/optional/optional-from-mapped-result.d.ts +5 -5
  162. package/build/require/type/optional/optional-from-mapped-result.js +7 -7
  163. package/build/require/type/partial/partial-from-mapped-result.d.ts +5 -5
  164. package/build/require/type/partial/partial-from-mapped-result.js +4 -4
  165. package/build/require/type/partial/partial.d.ts +2 -3
  166. package/build/require/type/partial/partial.js +8 -21
  167. package/build/require/type/pick/index.d.ts +1 -0
  168. package/build/require/type/pick/index.js +1 -0
  169. package/build/require/type/pick/pick-from-mapped-key.js +4 -5
  170. package/build/require/type/pick/pick-from-mapped-result.d.ts +11 -0
  171. package/build/require/type/pick/pick-from-mapped-result.js +22 -0
  172. package/build/require/type/pick/pick.d.ts +5 -2
  173. package/build/require/type/pick/pick.js +10 -9
  174. package/build/require/type/promise/promise.js +1 -1
  175. package/build/require/type/readonly/readonly-from-mapped-result.d.ts +5 -5
  176. package/build/require/type/readonly/readonly-from-mapped-result.js +4 -4
  177. package/build/require/type/record/record.d.ts +2 -2
  178. package/build/require/type/record/record.js +3 -0
  179. package/build/require/type/ref/ref.js +1 -1
  180. package/build/require/type/required/required-from-mapped-result.d.ts +5 -5
  181. package/build/require/type/required/required-from-mapped-result.js +7 -7
  182. package/build/require/type/required/required.d.ts +2 -3
  183. package/build/require/type/required/required.js +4 -14
  184. package/build/require/type/rest/rest.d.ts +2 -2
  185. package/build/require/type/rest/rest.js +1 -3
  186. package/build/require/type/sets/index.d.ts +1 -0
  187. package/build/require/type/{operators → sets}/index.js +1 -1
  188. package/build/require/type/sets/set.d.ts +24 -0
  189. package/build/require/type/sets/set.js +47 -0
  190. package/build/require/type/strict/strict.d.ts +1 -1
  191. package/build/require/type/strict/strict.js +1 -1
  192. package/build/require/type/template-literal/parse.js +1 -1
  193. package/build/require/type/template-literal/syntax.d.ts +1 -1
  194. package/build/require/type/template-literal/template-literal.d.ts +1 -1
  195. package/build/require/type/transform/transform.js +1 -1
  196. package/build/require/type/type/json.d.ts +6 -2
  197. package/build/require/type/union/union-evaluated.js +3 -14
  198. package/package.json +1 -1
  199. package/readme.md +67 -67
  200. package/build/import/type/operators/index.d.mts +0 -1
  201. package/build/import/type/operators/index.mjs +0 -1
  202. package/build/import/type/operators/operators.d.mts +0 -24
  203. package/build/import/type/operators/operators.mjs +0 -77
  204. package/build/require/type/operators/index.d.ts +0 -1
  205. package/build/require/type/operators/operators.d.ts +0 -24
  206. package/build/require/type/operators/operators.js +0 -89
@@ -6,10 +6,11 @@ import { Discard } from '../discard/index.mjs';
6
6
  import { TransformKind } from '../symbols/index.mjs';
7
7
  import { CloneType } from '../clone/type.mjs';
8
8
  import { OmitFromMappedKey } from './omit-from-mapped-key.mjs';
9
+ import { OmitFromMappedResult } from './omit-from-mapped-result.mjs';
9
10
  // ------------------------------------------------------------------
10
11
  // TypeGuard
11
12
  // ------------------------------------------------------------------
12
- import { IsMappedKey, IsIntersect, IsUnion, IsObject, IsSchema } from '../guard/type.mjs';
13
+ import { IsMappedKey, IsIntersect, IsUnion, IsObject, IsSchema, IsMappedResult } from '../guard/type.mjs';
13
14
  // prettier-ignore
14
15
  function FromIntersect(T, K) {
15
16
  return T.map((T) => OmitResolve(T, K));
@@ -40,13 +41,14 @@ export function OmitResolve(T, K) {
40
41
  Object({}));
41
42
  }
42
43
  export function Omit(T, K, options = {}) {
43
- if (IsMappedKey(K)) {
44
+ // mapped
45
+ if (IsMappedKey(K))
44
46
  return OmitFromMappedKey(T, K, options);
45
- }
46
- else {
47
- const I = IsSchema(K) ? IndexPropertyKeys(K) : K;
48
- const D = Discard(T, [TransformKind, '$id', 'required']);
49
- const R = CloneType(OmitResolve(T, I), options);
50
- return { ...D, ...R };
51
- }
47
+ if (IsMappedResult(T))
48
+ return OmitFromMappedResult(T, K, options);
49
+ // non-mapped
50
+ const I = IsSchema(K) ? IndexPropertyKeys(K) : K;
51
+ const D = Discard(T, [TransformKind, '$id', 'required']);
52
+ const R = CloneType(OmitResolve(T, I), options);
53
+ return { ...D, ...R };
52
54
  }
@@ -1,10 +1,10 @@
1
1
  import type { TProperties } from '../object/index.mjs';
2
2
  import { type TMappedResult } from '../mapped/index.mjs';
3
3
  import { type TOptionalWithFlag } from './optional.mjs';
4
- type TFromProperties<K extends TProperties, F extends boolean> = ({
5
- [K2 in keyof K]: TOptionalWithFlag<K[K2], F>;
4
+ type TFromProperties<P extends TProperties, F extends boolean> = ({
5
+ [K2 in keyof P]: TOptionalWithFlag<P[K2], F>;
6
6
  });
7
- type TFromMappedResult<K extends TMappedResult, F extends boolean> = (TFromProperties<K['properties'], F>);
8
- export type TOptionalFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>> = (TMappedResult<P>);
9
- export declare function OptionalFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>>(T: T, F: F): TMappedResult<P>;
7
+ type TFromMappedResult<R extends TMappedResult, F extends boolean> = (TFromProperties<R['properties'], F>);
8
+ export type TOptionalFromMappedResult<R extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<R, F>> = (TMappedResult<P>);
9
+ export declare function OptionalFromMappedResult<R extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<R, F>>(R: R, F: F): TMappedResult<P>;
10
10
  export {};
@@ -1,17 +1,17 @@
1
1
  import { MappedResult } from '../mapped/index.mjs';
2
2
  import { Optional } from './optional.mjs';
3
3
  // prettier-ignore
4
- function FromProperties(K, F) {
5
- return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
6
- return { ...Acc, [K2]: Optional(K[K2], F) };
4
+ function FromProperties(P, F) {
5
+ return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
6
+ return { ...Acc, [K2]: Optional(P[K2], F) };
7
7
  }, {});
8
8
  }
9
9
  // prettier-ignore
10
- function FromMappedResult(K, F) {
11
- return FromProperties(K.properties, F);
10
+ function FromMappedResult(R, F) {
11
+ return FromProperties(R.properties, F);
12
12
  }
13
13
  // prettier-ignore
14
- export function OptionalFromMappedResult(T, F) {
15
- const P = FromMappedResult(T, F);
14
+ export function OptionalFromMappedResult(R, F) {
15
+ const P = FromMappedResult(R, F);
16
16
  return MappedResult(P);
17
17
  }
@@ -2,10 +2,10 @@ import type { SchemaOptions } from '../schema/index.mjs';
2
2
  import type { TProperties } from '../object/index.mjs';
3
3
  import { type TMappedResult } from '../mapped/index.mjs';
4
4
  import { type TPartial } from './partial.mjs';
5
- type TFromProperties<K extends TProperties> = ({
6
- [K2 in keyof K]: TPartial<K[K2]>;
5
+ type TFromProperties<P extends TProperties> = ({
6
+ [K2 in keyof P]: TPartial<P[K2]>;
7
7
  });
8
- type TFromMappedResult<K extends TMappedResult> = (TFromProperties<K['properties']>);
9
- export type TPartialFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>> = (TMappedResult<P>);
10
- export declare function PartialFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
8
+ type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
9
+ export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
10
+ export declare function PartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
11
11
  export {};
@@ -7,11 +7,11 @@ function FromProperties(K, options) {
7
7
  }, {});
8
8
  }
9
9
  // prettier-ignore
10
- function FromMappedResult(K, options) {
11
- return FromProperties(K.properties, options);
10
+ function FromMappedResult(R, options) {
11
+ return FromProperties(R.properties, options);
12
12
  }
13
13
  // prettier-ignore
14
- export function PartialFromMappedResult(T, options) {
15
- const P = FromMappedResult(T, options);
14
+ export function PartialFromMappedResult(R, options) {
15
+ const P = FromMappedResult(R, options);
16
16
  return MappedResult(P);
17
17
  }
@@ -9,12 +9,11 @@ import { type TObject, type TProperties } from '../object/index.mjs';
9
9
  import { type TIntersect } from '../intersect/index.mjs';
10
10
  import { type TUnion } from '../union/index.mjs';
11
11
  import { type TPartialFromMappedResult } from './partial-from-mapped-result.mjs';
12
- type TFromIntersect<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, [...Acc, PartialResolve<L>]> : Acc);
13
- type TFromUnion<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...Acc, PartialResolve<L>]> : Acc);
12
+ type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, PartialResolve<L>]> : Acc);
14
13
  type TFromProperties<T extends TProperties> = Evaluate<{
15
14
  [K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
16
15
  }>;
17
- type PartialResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<PartialResolve<S>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
16
+ type PartialResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<PartialResolve<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
18
17
  declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
19
18
  export type TPartial<T extends TSchema> = PartialResolve<T>;
20
19
  /** `[Json]` Constructs a type where all properties are optional */
@@ -11,18 +11,8 @@ import { PartialFromMappedResult } from './partial-from-mapped-result.mjs';
11
11
  // ------------------------------------------------------------------
12
12
  import { IsMappedResult, IsIntersect, IsUnion, IsObject } from '../guard/type.mjs';
13
13
  // prettier-ignore
14
- function FromIntersect(T, Acc = []) {
15
- const [L, ...R] = T;
16
- return (T.length > 0
17
- ? FromIntersect(R, [...Acc, PartialResolve(L)])
18
- : Acc);
19
- }
20
- // prettier-ignore
21
- function FromUnion(T, Acc = []) {
22
- const [L, ...R] = T;
23
- return (T.length > 0
24
- ? FromUnion(R, [...Acc, PartialResolve(L)])
25
- : Acc);
14
+ function FromRest(T) {
15
+ return T.map(L => PartialResolve(L));
26
16
  }
27
17
  // prettier-ignore
28
18
  function FromProperties(T) {
@@ -32,19 +22,16 @@ function FromProperties(T) {
32
22
  }
33
23
  // prettier-ignore
34
24
  function PartialResolve(T) {
35
- return (IsIntersect(T) ? Intersect(FromIntersect(T.allOf)) :
36
- IsUnion(T) ? Union(FromUnion(T.anyOf)) :
25
+ return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
26
+ IsUnion(T) ? Union(FromRest(T.anyOf)) :
37
27
  IsObject(T) ? Object(FromProperties(T.properties)) :
38
28
  Object({}));
39
29
  }
40
30
  /** `[Json]` Constructs a type where all properties are optional */
41
31
  export function Partial(T, options = {}) {
42
- if (IsMappedResult(T)) {
32
+ if (IsMappedResult(T))
43
33
  return PartialFromMappedResult(T, options);
44
- }
45
- else {
46
- const D = Discard(T, [TransformKind, '$id', 'required']);
47
- const R = CloneType(PartialResolve(T), options);
48
- return { ...D, ...R };
49
- }
34
+ const D = Discard(T, [TransformKind, '$id', 'required']);
35
+ const R = CloneType(PartialResolve(T), options);
36
+ return { ...D, ...R };
50
37
  }
@@ -1,2 +1,3 @@
1
1
  export * from './pick-from-mapped-key.mjs';
2
+ export * from './pick-from-mapped-result.mjs';
2
3
  export * from './pick.mjs';
@@ -1,2 +1,3 @@
1
1
  export * from './pick-from-mapped-key.mjs';
2
+ export * from './pick-from-mapped-result.mjs';
2
3
  export * from './pick.mjs';
@@ -7,11 +7,10 @@ function FromPropertyKey(T, K, options) {
7
7
  };
8
8
  }
9
9
  // prettier-ignore
10
- function FromPropertyKeys(T, K, options, Acc = {}) {
11
- const [LK, ...RK] = K;
12
- return (K.length > 0
13
- ? FromPropertyKeys(T, RK, options, { ...Acc, ...FromPropertyKey(T, LK, options) })
14
- : Acc);
10
+ function FromPropertyKeys(T, K, options) {
11
+ return K.reduce((Acc, LK) => {
12
+ return { ...Acc, ...FromPropertyKey(T, LK, options) };
13
+ }, {});
15
14
  }
16
15
  // prettier-ignore
17
16
  function FromMappedKey(T, K, options) {
@@ -0,0 +1,11 @@
1
+ import type { SchemaOptions } from '../schema/index.mjs';
2
+ import type { TProperties } from '../object/index.mjs';
3
+ import { type TMappedResult } from '../mapped/index.mjs';
4
+ import { type TPick } from './pick.mjs';
5
+ type TFromProperties<P extends TProperties, K extends PropertyKey[]> = ({
6
+ [K2 in keyof P]: TPick<P[K2], K>;
7
+ });
8
+ type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (TFromProperties<R['properties'], K>);
9
+ export type TPickFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (TMappedResult<P>);
10
+ export declare function PickFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options: SchemaOptions): TMappedResult<P>;
11
+ export {};
@@ -0,0 +1,17 @@
1
+ import { MappedResult } from '../mapped/index.mjs';
2
+ import { Pick } from './pick.mjs';
3
+ // prettier-ignore
4
+ function FromProperties(P, K, options) {
5
+ return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
6
+ return { ...Acc, [K2]: Pick(P[K2], K, options) };
7
+ }, {});
8
+ }
9
+ // prettier-ignore
10
+ function FromMappedResult(R, K, options) {
11
+ return FromProperties(R.properties, K, options);
12
+ }
13
+ // prettier-ignore
14
+ export function PickFromMappedResult(R, K, options) {
15
+ const P = FromMappedResult(R, K, options);
16
+ return MappedResult(P);
17
+ }
@@ -4,9 +4,10 @@ import { type TRecursive } from '../recursive/index.mjs';
4
4
  import { type TIntersect } from '../intersect/index.mjs';
5
5
  import { type TUnion } from '../union/index.mjs';
6
6
  import { type TObject, type TProperties } from '../object/index.mjs';
7
+ import type { TMappedKey, TMappedResult } from '../mapped/index.mjs';
7
8
  import { type TIndexPropertyKeys } from '../indexed/index.mjs';
8
- import { TMappedKey } from '../mapped/index.mjs';
9
9
  import { type TPickFromMappedKey } from './pick-from-mapped-key.mjs';
10
+ import { type TPickFromMappedResult } from './pick-from-mapped-result.mjs';
10
11
  type FromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromIntersect<R, K, [...Acc, PickResolve<L, K>]> : Acc;
11
12
  declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K, []>;
12
13
  type FromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromUnion<R, K, [...Acc, PickResolve<L, K>]> : Acc;
@@ -17,7 +18,9 @@ export type PickResolve<T extends TProperties, K extends PropertyKey[]> = T exte
17
18
  export declare function PickResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): PickResolve<T, K>;
18
19
  export type TPick<T extends TSchema, K extends PropertyKey[]> = PickResolve<T, K>;
19
20
  /** `[Json]` Constructs a type whose keys are picked from the given type */
20
- export declare function Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
21
+ export declare function Pick<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TPickFromMappedResult<T, K>;
22
+ /** `[Json]` Constructs a type whose keys are picked from the given type */
23
+ export declare function Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TPickFromMappedKey<T, K>;
21
24
  /** `[Json]` Constructs a type whose keys are picked from the given type */
22
25
  export declare function Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
23
26
  /** `[Json]` Constructs a type whose keys are picked from the given type */
@@ -6,11 +6,11 @@ import { Discard } from '../discard/index.mjs';
6
6
  import { TransformKind } from '../symbols/index.mjs';
7
7
  import { CloneType } from '../clone/type.mjs';
8
8
  import { PickFromMappedKey } from './pick-from-mapped-key.mjs';
9
+ import { PickFromMappedResult } from './pick-from-mapped-result.mjs';
9
10
  // ------------------------------------------------------------------
10
11
  // TypeGuard
11
12
  // ------------------------------------------------------------------
12
- // prettier-ignore
13
- import { IsMappedKey, IsIntersect, IsUnion, IsObject, IsSchema, } from '../guard/type.mjs';
13
+ import { IsMappedKey, IsMappedResult, IsIntersect, IsUnion, IsObject, IsSchema } from '../guard/type.mjs';
14
14
  function FromIntersect(T, K) {
15
15
  return T.map((T) => PickResolve(T, K));
16
16
  }
@@ -32,13 +32,14 @@ export function PickResolve(T, K) {
32
32
  Object({}));
33
33
  }
34
34
  export function Pick(T, K, options = {}) {
35
- if (IsMappedKey(K)) {
35
+ // mapped
36
+ if (IsMappedKey(K))
36
37
  return PickFromMappedKey(T, K, options);
37
- }
38
- else {
39
- const I = IsSchema(K) ? IndexPropertyKeys(K) : K;
40
- const D = Discard(T, [TransformKind, '$id', 'required']);
41
- const R = CloneType(PickResolve(T, I), options);
42
- return { ...D, ...R };
43
- }
38
+ if (IsMappedResult(T))
39
+ return PickFromMappedResult(T, K, options);
40
+ // non-mapped
41
+ const I = IsSchema(K) ? IndexPropertyKeys(K) : K;
42
+ const D = Discard(T, [TransformKind, '$id', 'required']);
43
+ const R = CloneType(PickResolve(T, I), options);
44
+ return { ...D, ...R };
44
45
  }
@@ -1,5 +1,5 @@
1
- import { Kind } from '../symbols/index.mjs';
2
1
  import { CloneType } from '../clone/type.mjs';
2
+ import { Kind } from '../symbols/index.mjs';
3
3
  /** `[JavaScript]` Creates a Promise type */
4
4
  export function Promise(item, options = {}) {
5
5
  return {
@@ -1,10 +1,10 @@
1
1
  import type { TProperties } from '../object/index.mjs';
2
2
  import { type TMappedResult } from '../mapped/index.mjs';
3
3
  import { type TReadonlyWithFlag } from './readonly.mjs';
4
- type TFromProperties<K extends TProperties, F extends boolean> = ({
5
- [K2 in keyof K]: TReadonlyWithFlag<K[K2], F>;
4
+ type TFromProperties<P extends TProperties, F extends boolean> = ({
5
+ [K2 in keyof P]: TReadonlyWithFlag<P[K2], F>;
6
6
  });
7
- type TFromMappedResult<K extends TMappedResult, F extends boolean> = (TFromProperties<K['properties'], F>);
8
- export type TReadonlyFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>> = (TMappedResult<P>);
9
- export declare function ReadonlyFromMappedResult<T extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<T, F>>(T: T, F: F): TMappedResult<P>;
7
+ type TFromMappedResult<R extends TMappedResult, F extends boolean> = (TFromProperties<R['properties'], F>);
8
+ export type TReadonlyFromMappedResult<R extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<R, F>> = (TMappedResult<P>);
9
+ export declare function ReadonlyFromMappedResult<R extends TMappedResult, F extends boolean, P extends TProperties = TFromMappedResult<R, F>>(R: R, F: F): TMappedResult<P>;
10
10
  export {};
@@ -7,11 +7,11 @@ function FromProperties(K, F) {
7
7
  }, {});
8
8
  }
9
9
  // prettier-ignore
10
- function FromMappedResult(K, F) {
11
- return FromProperties(K.properties, F);
10
+ function FromMappedResult(R, F) {
11
+ return FromProperties(R.properties, F);
12
12
  }
13
13
  // prettier-ignore
14
- export function ReadonlyFromMappedResult(T, F) {
15
- const P = FromMappedResult(T, F);
14
+ export function ReadonlyFromMappedResult(R, F) {
15
+ const P = FromMappedResult(R, F);
16
16
  return MappedResult(P);
17
17
  }
@@ -2,14 +2,14 @@ import type { TSchema } from '../schema/index.mjs';
2
2
  import type { Static } from '../static/index.mjs';
3
3
  import type { Evaluate, Ensure, Assert } from '../helpers/index.mjs';
4
4
  import { type TObject, type TProperties, type TAdditionalProperties, type ObjectOptions } from '../object/index.mjs';
5
- import { type TLiteral, TLiteralValue } from '../literal/index.mjs';
5
+ import { type TLiteral, type TLiteralValue } from '../literal/index.mjs';
6
6
  import { type TNever } from '../never/index.mjs';
7
7
  import { type TUnion } from '../union/index.mjs';
8
8
  import { type TString } from '../string/index.mjs';
9
9
  import { type TInteger } from '../integer/index.mjs';
10
10
  import { type TNumber } from '../number/index.mjs';
11
11
  import { type TEnum } from '../enum/index.mjs';
12
- import { TTemplateLiteral, TIsTemplateLiteralFinite } from '../template-literal/index.mjs';
12
+ import { TIsTemplateLiteralFinite, type TTemplateLiteral } from '../template-literal/index.mjs';
13
13
  import { Kind } from '../symbols/index.mjs';
14
14
  type TFromTemplateLiteralKeyInfinite<K extends TTemplateLiteral, T extends TSchema> = Ensure<TRecord<K, T>>;
15
15
  type TFromTemplateLiteralKeyFinite<K extends TTemplateLiteral, T extends TSchema, I extends string = Static<K>> = (Ensure<TObject<Evaluate<{
@@ -6,6 +6,9 @@ import { PatternStringExact, PatternNumberExact } from '../patterns/index.mjs';
6
6
  import { IndexPropertyKeys } from '../indexed/index.mjs';
7
7
  import { Kind, Hint } from '../symbols/index.mjs';
8
8
  import { CloneType } from '../clone/type.mjs';
9
+ // ------------------------------------------------------------------
10
+ // ValueGuard
11
+ // ------------------------------------------------------------------
9
12
  import { IsUndefined } from '../guard/value.mjs';
10
13
  // ------------------------------------------------------------------
11
14
  // TypeGuard
@@ -1,6 +1,6 @@
1
1
  import { Kind } from '../symbols/index.mjs';
2
2
  // ------------------------------------------------------------------
3
- // TypeGuard
3
+ // ValueGuard
4
4
  // ------------------------------------------------------------------
5
5
  import { IsString, IsUndefined } from '../guard/value.mjs';
6
6
  /** `[Json]` Creates a Ref type. */
@@ -2,10 +2,10 @@ import type { SchemaOptions } from '../schema/index.mjs';
2
2
  import type { TProperties } from '../object/index.mjs';
3
3
  import { type TMappedResult } from '../mapped/index.mjs';
4
4
  import { type TRequired } from './required.mjs';
5
- type TFromProperties<K extends TProperties> = ({
6
- [K2 in keyof K]: TRequired<K[K2]>;
5
+ type TFromProperties<P extends TProperties> = ({
6
+ [K2 in keyof P]: TRequired<P[K2]>;
7
7
  });
8
- type TFromMappedResult<K extends TMappedResult> = (TFromProperties<K['properties']>);
9
- export type TRequiredFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>> = (TMappedResult<P>);
10
- export declare function RequiredFromMappedResult<T extends TMappedResult, P extends TProperties = TFromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
8
+ type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
9
+ export type TRequiredFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
10
+ export declare function RequiredFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
11
11
  export {};
@@ -1,17 +1,17 @@
1
1
  import { MappedResult } from '../mapped/index.mjs';
2
2
  import { Required } from './required.mjs';
3
3
  // prettier-ignore
4
- function FromProperties(K, options) {
5
- return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
6
- return { ...Acc, [K2]: Required(K[K2], options) };
4
+ function FromProperties(P, options) {
5
+ return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
6
+ return { ...Acc, [K2]: Required(P[K2], options) };
7
7
  }, {});
8
8
  }
9
9
  // prettier-ignore
10
- function FromMappedResult(K, options) {
11
- return FromProperties(K.properties, options);
10
+ function FromMappedResult(R, options) {
11
+ return FromProperties(R.properties, options);
12
12
  }
13
13
  // prettier-ignore
14
- export function RequiredFromMappedResult(T, options) {
15
- const P = FromMappedResult(T, options);
14
+ export function RequiredFromMappedResult(R, options) {
15
+ const P = FromMappedResult(R, options);
16
16
  return MappedResult(P);
17
17
  }
@@ -9,12 +9,11 @@ import { type TIntersect } from '../intersect/index.mjs';
9
9
  import { type TUnion } from '../union/index.mjs';
10
10
  import { type TObject, type TProperties } from '../object/index.mjs';
11
11
  import { type TRequiredFromMappedResult } from './required-from-mapped-result.mjs';
12
- type TFromIntersect<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, [...Acc, TRequiredResolve<L>]> : Acc);
13
- type TFromUnion<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, [...Acc, TRequiredResolve<L>]> : Acc);
12
+ type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TRequiredResolve<L>]> : Acc);
14
13
  type TFromProperties<T extends TProperties> = Evaluate<{
15
14
  [K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
16
15
  }>;
17
- type TRequiredResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequiredResolve<S>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
16
+ type TRequiredResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<TRequiredResolve<S>> : T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TObject<infer S> ? TObject<TFromProperties<S>> : TObject<{}>);
18
17
  export type TRequired<T extends TSchema> = TRequiredResolve<T>;
19
18
  /** `[Json]` Constructs a type where all properties are required */
20
19
  export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
@@ -10,18 +10,8 @@ import { RequiredFromMappedResult } from './required-from-mapped-result.mjs';
10
10
  // ------------------------------------------------------------------
11
11
  import { IsMappedResult, IsIntersect, IsUnion, IsObject } from '../guard/type.mjs';
12
12
  // prettier-ignore
13
- function FromIntersect(T, Acc = []) {
14
- const [L, ...R] = T;
15
- return (T.length > 0
16
- ? FromIntersect(R, [...Acc, RequiredResolve(L)])
17
- : Acc);
18
- }
19
- // prettier-ignore
20
- function FromUnion(T, Acc = []) {
21
- const [L, ...R] = T;
22
- return (T.length > 0
23
- ? FromUnion(R, [...Acc, RequiredResolve(L)])
24
- : Acc);
13
+ function FromRest(T) {
14
+ return T.map(L => RequiredResolve(L));
25
15
  }
26
16
  // prettier-ignore
27
17
  function FromProperties(T) {
@@ -31,8 +21,8 @@ function FromProperties(T) {
31
21
  }
32
22
  // prettier-ignore
33
23
  function RequiredResolve(T) {
34
- return (IsIntersect(T) ? Intersect(FromIntersect(T.allOf)) :
35
- IsUnion(T) ? Union(FromUnion(T.anyOf)) :
24
+ return (IsIntersect(T) ? Intersect(FromRest(T.allOf)) :
25
+ IsUnion(T) ? Union(FromRest(T.anyOf)) :
36
26
  IsObject(T) ? Object(FromProperties(T.properties)) :
37
27
  Object({}));
38
28
  }
@@ -2,9 +2,9 @@ import type { TSchema } from '../schema/index.mjs';
2
2
  import type { TIntersect } from '../intersect/index.mjs';
3
3
  import type { TUnion } from '../union/index.mjs';
4
4
  import type { TTuple } from '../tuple/index.mjs';
5
- export type TRestResolve<T extends TSchema> = T extends TIntersect<infer S> ? [...S] : T extends TUnion<infer S> ? [...S] : T extends TTuple<infer S> ? [...S] : [
5
+ type TRestResolve<T extends TSchema> = T extends TIntersect<infer S> ? [...S] : T extends TUnion<infer S> ? [...S] : T extends TTuple<infer S> ? [...S] : [
6
6
  ];
7
- export declare function RestResolve<T extends TSchema>(T: T): TRestResolve<T>;
8
7
  export type TRest<T extends TSchema> = TRestResolve<T>;
9
8
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
10
9
  export declare function Rest<T extends TSchema>(T: T): TRest<T>;
10
+ export {};
@@ -2,10 +2,9 @@ import { CloneRest } from '../clone/type.mjs';
2
2
  // ------------------------------------------------------------------
3
3
  // TypeGuard
4
4
  // ------------------------------------------------------------------
5
- // prettier-ignore
6
5
  import { IsIntersect, IsUnion, IsTuple } from '../guard/type.mjs';
7
6
  // prettier-ignore
8
- export function RestResolve(T) {
7
+ function RestResolve(T) {
9
8
  return (IsIntersect(T) ? [...T.allOf] :
10
9
  IsUnion(T) ? [...T.anyOf] :
11
10
  IsTuple(T) ? [...(T.items ?? [])] :
@@ -0,0 +1 @@
1
+ export * from './set.mjs';
@@ -0,0 +1 @@
1
+ export * from './set.mjs';
@@ -0,0 +1,24 @@
1
+ export type TSetIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TSetIncludes<R, S> : false);
2
+ /** Returns true if element S is in the set of T */
3
+ export declare function SetIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TSetIncludes<T, S>;
4
+ export type SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? SetIsSubset<R, S> : false : true);
5
+ /** Returns true if T is a subset of S */
6
+ export declare function SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): SetIsSubset<T, S>;
7
+ export type TSetDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<Acc, L> extends false ? TSetDistinct<R, [...Acc, L]> : TSetDistinct<R, [...Acc]> : Acc;
8
+ /** Returns a distinct set of elements */
9
+ export declare function SetDistinct<T extends PropertyKey[]>(T: [...T]): TSetDistinct<T>;
10
+ export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [L, ...Acc]> : TSetIntersect<R, S, [...Acc]> : Acc);
11
+ /** Returns the Intersect of the given sets */
12
+ export declare function SetIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetIntersect<T, S>;
13
+ export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetUnion<R, S, [...Acc, L]> : Acc);
14
+ /** Returns the Union of the given sets */
15
+ export declare function SetUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetUnion<T, S>;
16
+ export type TSetComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetComplement<R, S, [...Acc]> : TSetComplement<R, S, [...Acc, L]> : Acc);
17
+ /** Returns the Complement by omitting elements in T that are in S */
18
+ export declare function SetComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetComplement<T, S>;
19
+ export type TSetIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetIntersectMany<R, TSetIntersect<Acc, L>> : Acc);
20
+ /** Returns the Intersect of multiple sets */
21
+ export declare function SetIntersectMany<T extends PropertyKey[][]>(T: [...T]): TSetIntersectMany<T>;
22
+ export type TSetUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetUnionMany<R, TSetUnion<Acc, L>> : Acc);
23
+ /** Returns the Union of multiple sets */
24
+ export declare function SetUnionMany<T extends PropertyKey[][]>(T: [...T]): TSetUnionMany<T>;
@@ -0,0 +1,35 @@
1
+ /** Returns true if element S is in the set of T */
2
+ // prettier-ignore
3
+ export function SetIncludes(T, S) {
4
+ return T.includes(S);
5
+ }
6
+ /** Returns true if T is a subset of S */
7
+ export function SetIsSubset(T, S) {
8
+ return T.every((L) => SetIncludes(S, L));
9
+ }
10
+ /** Returns a distinct set of elements */
11
+ export function SetDistinct(T) {
12
+ return [...new Set(T)];
13
+ }
14
+ /** Returns the Intersect of the given sets */
15
+ export function SetIntersect(T, S) {
16
+ return T.filter((L) => S.includes(L));
17
+ }
18
+ /** Returns the Union of the given sets */
19
+ export function SetUnion(T, S) {
20
+ return [...T, ...S];
21
+ }
22
+ /** Returns the Complement by omitting elements in T that are in S */
23
+ // prettier-ignore
24
+ export function SetComplement(T, S) {
25
+ return T.filter(L => !S.includes(L));
26
+ }
27
+ /** Returns the Intersect of multiple sets */
28
+ // prettier-ignore
29
+ export function SetIntersectMany(T) {
30
+ return (T.length === 1 ? T[0] : T.reduce((Acc, L) => [...SetIntersect(Acc, L)], []));
31
+ }
32
+ /** Returns the Union of multiple sets */
33
+ export function SetUnionMany(T) {
34
+ return T.reduce((Acc, L) => [...Acc, ...L], []);
35
+ }
@@ -1,3 +1,3 @@
1
1
  import type { TSchema } from '../schema/index.mjs';
2
- /** `[Json]` Omits compositing symbols from this schema */
2
+ /** `[Json]` Omits compositing symbols from this schema. */
3
3
  export declare function Strict<T extends TSchema>(schema: T): T;
@@ -1,4 +1,4 @@
1
- /** `[Json]` Omits compositing symbols from this schema */
1
+ /** `[Json]` Omits compositing symbols from this schema. */
2
2
  export function Strict(schema) {
3
3
  return JSON.parse(JSON.stringify(schema));
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import type { Assert, Trim } from '../helpers/index.mjs';
2
- import type { TTemplateLiteralKind, TTemplateLiteral } from './index.mjs';
2
+ import type { TTemplateLiteral, TTemplateLiteralKind } from './index.mjs';
3
3
  import { type TLiteral } from '../literal/index.mjs';
4
4
  import { type TBoolean } from '../boolean/index.mjs';
5
5
  import { type TBigInt } from '../bigint/index.mjs';
@@ -9,7 +9,7 @@ import type { TString } from '../string/index.mjs';
9
9
  import type { TBoolean } from '../boolean/index.mjs';
10
10
  import type { TNever } from '../never/index.mjs';
11
11
  import type { Static } from '../static/index.mjs';
12
- import { TTemplateLiteralSyntax } from './syntax.mjs';
12
+ import { type TTemplateLiteralSyntax } from './syntax.mjs';
13
13
  import { EmptyString } from '../helpers/index.mjs';
14
14
  import { Kind } from '../symbols/index.mjs';
15
15
  type TemplateLiteralStaticKind<T, Acc extends string> = T extends TUnion<infer U> ? {
@@ -1,5 +1,5 @@
1
- import { CloneType } from '../clone/type.mjs';
2
1
  import { TransformKind } from '../symbols/index.mjs';
2
+ import { CloneType } from '../clone/type.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // TypeGuard
5
5
  // ------------------------------------------------------------------