@fncts/typelevel 0.0.5 → 0.0.8

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.
package/Object.d.ts CHANGED
@@ -25,7 +25,7 @@ declare type MetaPath<O, SP extends List<Index> = [], P extends List<Index> = []
25
25
  [__Cont]: _MetaPath<O, SP, P>;
26
26
  [__Path]: [];
27
27
  };
28
- declare type NextPath<OP> = At<UnionOf<At<OP, __Cont>>, __Path> extends infer X ? undefined extends X ? never : X : never;
28
+ declare type NextPath<OP> = At<UnionOf<At<OP, __Cont>>, __Path> extends infer X ? (undefined extends X ? never : X) : never;
29
29
  declare type ExecPath<A, SP extends List<Index>> = NextPath<Path<MetaPath<A, SP>, PrependAll<SP, __Cont>>>;
30
30
  declare type HintPath<A, SP extends List<Index>, Exec extends List<Index>> = [Exec] extends [never] ? ExecPath<A, Pop<SP>> : Exec | SP;
31
31
  export declare type AutoPath<A, P extends List<Index>> = HintPath<A, P, ExecPath<A, P>>;
@@ -85,11 +85,9 @@ declare type MergeDeepList<L extends List, L1 extends List, Ignore, Fill> = numb
85
85
  declare type MergeDeepObject<O, O1, Ignore, Fill, OOKeys extends Key = _OptionalKeys<O>> = {
86
86
  [K in keyof (Anyify<O> & O1)]: MergeDeepChoice<At<O, K>, At<O1, K>, Ignore, Fill, OOKeys, K>;
87
87
  };
88
- declare type MergeDeepChoice<OK, O1K, Ignore, Fill, OOKeys extends Key, K extends Key> = [OK] extends [
89
- never
90
- ] ? MergeProp<OK, O1K, Fill, OOKeys, K> : [O1K] extends [never] ? MergeProp<OK, O1K, Fill, OOKeys, K> : OK extends Ignore ? MergeProp<OK, O1K, Fill, OOKeys, K> : O1K extends Ignore ? MergeProp<OK, O1K, Fill, OOKeys, K> : OK extends List ? O1K extends List ? MergeDeepList<OK, O1K, Ignore, Fill> : MergeProp<OK, O1K, Fill, OOKeys, K> : OK extends object ? O1K extends object ? MergeDeepObject<OK, O1K, Ignore, Fill> : MergeProp<OK, O1K, Fill, OOKeys, K> : MergeProp<OK, O1K, Fill, OOKeys, K>;
88
+ declare type MergeDeepChoice<OK, O1K, Ignore, Fill, OOKeys extends Key, K extends Key> = [OK] extends [never] ? MergeProp<OK, O1K, Fill, OOKeys, K> : [O1K] extends [never] ? MergeProp<OK, O1K, Fill, OOKeys, K> : OK extends Ignore ? MergeProp<OK, O1K, Fill, OOKeys, K> : O1K extends Ignore ? MergeProp<OK, O1K, Fill, OOKeys, K> : OK extends List ? O1K extends List ? MergeDeepList<OK, O1K, Ignore, Fill> : MergeProp<OK, O1K, Fill, OOKeys, K> : OK extends object ? O1K extends object ? MergeDeepObject<OK, O1K, Ignore, Fill> : MergeProp<OK, O1K, Fill, OOKeys, K> : MergeProp<OK, O1K, Fill, OOKeys, K>;
91
89
  export declare type MergeDeep<O, O1, Ignore, Fill> = O extends unknown ? O1 extends unknown ? MergeDeepChoice<O, O1, Ignore, Fill, "x", "y"> : never : never;
92
- declare type PatchProp<OK, O1K, Fill, OKeys extends Key, K extends Key> = K extends OKeys ? OK extends Fill ? O1K : OK : O1K;
90
+ declare type PatchProp<OK, O1K, Fill, OKeys extends Key, K extends Key> = K extends OKeys ? (OK extends Fill ? O1K : OK) : O1K;
93
91
  /**
94
92
  * @hidden
95
93
  */
package/_src/Any.ts CHANGED
@@ -5,10 +5,7 @@ import type { Has } from "./Union.js";
5
5
 
6
6
  export type Cast<A, B> = A extends B ? A : B;
7
7
 
8
- export type Try<A1 , A2 , Catch = never> =
9
- A1 extends A2
10
- ? A1
11
- : Catch;
8
+ export type Try<A1, A2, Catch = never> = A1 extends A2 ? A1 : Catch;
12
9
 
13
10
  export type Extends<A, B> = [A] extends [never] ? False : A extends B ? True : False;
14
11
 
package/_src/Boolean.ts CHANGED
@@ -18,27 +18,27 @@ export type Or<B1 extends Boolean, B2 extends Boolean> = {
18
18
 
19
19
  export type And<B1 extends Boolean, B2 extends Boolean> = {
20
20
  [False]: {
21
- [False]: False,
22
- [True]: False
23
- },
21
+ [False]: False;
22
+ [True]: False;
23
+ };
24
24
  [True]: {
25
- [False]: False,
26
- [True]: True
27
- }
25
+ [False]: False;
26
+ [True]: True;
27
+ };
28
28
  }[B1][B2];
29
29
 
30
30
  export type Xor<B1 extends Boolean, B2 extends Boolean> = {
31
31
  [False]: {
32
- [False]: False,
33
- [True]: True
34
- },
32
+ [False]: False;
33
+ [True]: True;
34
+ };
35
35
  [True]: {
36
- [False]: True,
37
- [True]: False
38
- }
36
+ [False]: True;
37
+ [True]: False;
38
+ };
39
39
  }[B1][B2];
40
40
 
41
41
  export type Not<B extends Boolean> = {
42
- [False]: True,
43
- [True]: False
44
- }[B];
42
+ [False]: True;
43
+ [True]: False;
44
+ }[B];
package/_src/BuiltIn.ts CHANGED
@@ -1,7 +1 @@
1
- export type BuiltIn =
2
- | Function
3
- | Error
4
- | Date
5
- | { readonly [Symbol.toStringTag]: string }
6
- | RegExp
7
- | Generator;
1
+ export type BuiltIn = Function | Error | Date | { readonly [Symbol.toStringTag]: string } | RegExp | Generator;
package/_src/Check.ts CHANGED
@@ -46,16 +46,16 @@ export declare namespace Check {
46
46
  /**
47
47
  * @tsplus type fncts.Check.IsEqual
48
48
  */
49
- type IsEqual<A, B> = (<T>() => T extends EqualsWrapped<A> ? 1 : 2) extends <
50
- T,
51
- >() => T extends EqualsWrapped<B> ? 1 : 2
49
+ type IsEqual<A, B> = (<T>() => T extends EqualsWrapped<A> ? 1 : 2) extends <T>() => T extends EqualsWrapped<B> ? 1 : 2
52
50
  ? unknown
53
51
  : never;
54
52
 
55
53
  /**
56
54
  * @tsplus type fncts.Check.IsLiteral
57
55
  */
58
- type IsLiteral<A extends string | number | boolean> = Not<Extends<string, A> | Extends<number, A> | Extends<boolean, A>>;
56
+ type IsLiteral<A extends string | number | boolean> = Not<
57
+ Extends<string, A> | Extends<number, A> | Extends<boolean, A>
58
+ >;
59
59
 
60
60
  /**
61
61
  * @tsplus type fncts.Check.IsStruct
@@ -65,10 +65,7 @@ export declare namespace Check {
65
65
  /**
66
66
  * @tsplus type fncts.Check.HaveSameLength
67
67
  */
68
- type HaveSameLength<A extends { length: number }, B extends { length: number }> = IsEqual<
69
- A["length"],
70
- B["length"]
71
- >;
68
+ type HaveSameLength<A extends { length: number }, B extends { length: number }> = IsEqual<A["length"], B["length"]>;
72
69
 
73
70
  /**
74
71
  * @tsplus type fncts.Check.IsTagged
package/_src/List.ts CHANGED
@@ -12,17 +12,9 @@ export type Length<L extends List> = L["length"];
12
12
 
13
13
  export type Head<L extends List> = L[0];
14
14
 
15
- export type Tail<L extends List> = L extends readonly []
16
- ? L
17
- : L extends readonly [any?, ...infer Tail]
18
- ? Tail
19
- : L;
15
+ export type Tail<L extends List> = L extends readonly [] ? L : L extends readonly [any?, ...infer Tail] ? Tail : L;
20
16
 
21
- export type Init<L extends List> = L extends readonly []
22
- ? L
23
- : L extends readonly [...infer Init, any?]
24
- ? Init
25
- : L;
17
+ export type Init<L extends List> = L extends readonly [] ? L : L extends readonly [...infer Init, any?] ? Init : L;
26
18
 
27
19
  export type Last<L extends List> = L[Length<Tail<L>>];
28
20
 
@@ -32,9 +24,7 @@ export type PrependAll<L extends List, A, O extends List = []> = Length<L> exten
32
24
  ? O
33
25
  : PrependAll<Tail<L>, A, [...O, A, Head<L>]>;
34
26
 
35
- export type Pop<L extends List> = L extends
36
- | readonly [...infer LBody, any]
37
- | readonly [...infer LBody, any?]
27
+ export type Pop<L extends List> = L extends readonly [...infer LBody, any] | readonly [...infer LBody, any?]
38
28
  ? LBody
39
29
  : L;
40
30
 
package/_src/Number.ts CHANGED
@@ -36,10 +36,7 @@ export type _AddPositive<N1 extends Iteration, N2 extends Iteration> = Pos<N2> e
36
36
  ? IterationOf<number>
37
37
  : _AddPositive<Next<N1>, Prev<N2>>;
38
38
 
39
- export type AddPositive<N1 extends Iteration, N2 extends Iteration> = _AddPositive<
40
- N1,
41
- N2
42
- > extends infer X
39
+ export type AddPositive<N1 extends Iteration, N2 extends Iteration> = _AddPositive<N1, N2> extends infer X
43
40
  ? Cast<X, Iteration>
44
41
  : never;
45
42
 
@@ -49,10 +46,7 @@ export type _AddNegative<N1 extends Iteration, N2 extends Iteration> = Pos<N2> e
49
46
  ? IterationOf<number>
50
47
  : _AddNegative<Prev<N1>, Next<N2>>;
51
48
 
52
- export type AddNegative<N1 extends Iteration, N2 extends Iteration> = _AddNegative<
53
- N1,
54
- N2
55
- > extends infer X
49
+ export type AddNegative<N1 extends Iteration, N2 extends Iteration> = _AddNegative<N1, N2> extends infer X
56
50
  ? Cast<X, Iteration>
57
51
  : never;
58
52
 
@@ -98,10 +92,7 @@ export type Lower<X extends number, Y extends number> = X extends unknown
98
92
  : never
99
93
  : never;
100
94
 
101
- export type _GreaterEq<N1 extends Iteration, N2 extends Iteration> = Or<
102
- Equals<N1, N2>,
103
- _Greater<N1, N2>
104
- >;
95
+ export type _GreaterEq<N1 extends Iteration, N2 extends Iteration> = Or<Equals<N1, N2>, _Greater<N1, N2>>;
105
96
 
106
97
  export type GreaterEq<X extends number, Y extends number> = X extends unknown
107
98
  ? Y extends unknown
@@ -109,10 +100,7 @@ export type GreaterEq<X extends number, Y extends number> = X extends unknown
109
100
  : never
110
101
  : never;
111
102
 
112
- export type _LowerEq<N1 extends Iteration, N2 extends Iteration> = Or<
113
- Equals<N1, N2>,
114
- _Lower<N1, N2>
115
- >;
103
+ export type _LowerEq<N1 extends Iteration, N2 extends Iteration> = Or<Equals<N1, N2>, _Lower<N1, N2>>;
116
104
 
117
105
  export type LowerEq<X extends number, Y extends number> = X extends unknown
118
106
  ? Y extends unknown
@@ -134,4 +122,4 @@ export type Comp<X extends number, C extends Comparison, Y extends number> = X e
134
122
  ? Y extends unknown
135
123
  ? _Comp<IterationOf<X>, C, IterationOf<Y>>
136
124
  : never
137
- : never;
125
+ : never;
package/_src/Object.ts CHANGED
@@ -45,11 +45,7 @@ type MetaPath<O, SP extends List<Index> = [], P extends List<Index> = []> = {
45
45
  [__Path]: [];
46
46
  };
47
47
 
48
- type NextPath<OP> = At<UnionOf<At<OP, __Cont>>, __Path> extends infer X
49
- ? undefined extends X
50
- ? never
51
- : X
52
- : never;
48
+ type NextPath<OP> = At<UnionOf<At<OP, __Cont>>, __Path> extends infer X ? (undefined extends X ? never : X) : never;
53
49
 
54
50
  type ExecPath<A, SP extends List<Index>> = NextPath<Path<MetaPath<A, SP>, PrependAll<SP, __Cont>>>;
55
51
 
@@ -140,9 +136,7 @@ export type _ExcludeMatch<O, O1, M extends Match> = {
140
136
  }[Is<O[K], At<O1, K>, M>];
141
137
  }[keyof O];
142
138
 
143
- export type ExcludeMatch<O, O1, M extends Match> = O extends unknown
144
- ? _ExcludeMatch<O, O1, M>
145
- : never;
139
+ export type ExcludeMatch<O, O1, M extends Match> = O extends unknown ? _ExcludeMatch<O, O1, M> : never;
146
140
 
147
141
  export type ExcludeKeys<O, O1, M extends Match = "default"> = {
148
142
  default: U.Exclude<Keys<O>, Keys<O1>>;
@@ -223,9 +217,7 @@ type MergeDeepObject<O, O1, Ignore, Fill, OOKeys extends Key = _OptionalKeys<O>>
223
217
  [K in keyof (Anyify<O> & O1)]: MergeDeepChoice<At<O, K>, At<O1, K>, Ignore, Fill, OOKeys, K>;
224
218
  };
225
219
 
226
- type MergeDeepChoice<OK, O1K, Ignore, Fill, OOKeys extends Key, K extends Key> = [OK] extends [
227
- never,
228
- ]
220
+ type MergeDeepChoice<OK, O1K, Ignore, Fill, OOKeys extends Key, K extends Key> = [OK] extends [never]
229
221
  ? MergeProp<OK, O1K, Fill, OOKeys, K>
230
222
  : [O1K] extends [never]
231
223
  ? MergeProp<OK, O1K, Fill, OOKeys, K>
@@ -255,11 +247,7 @@ export type MergeDeep<O, O1, Ignore, Fill> = O extends unknown
255
247
  * -------------------------------------------------------------------------------------------------
256
248
  */
257
249
 
258
- type PatchProp<OK, O1K, Fill, OKeys extends Key, K extends Key> = K extends OKeys
259
- ? OK extends Fill
260
- ? O1K
261
- : OK
262
- : O1K;
250
+ type PatchProp<OK, O1K, Fill, OKeys extends Key, K extends Key> = K extends OKeys ? (OK extends Fill ? O1K : OK) : O1K;
263
251
 
264
252
  /**
265
253
  * @hidden
@@ -324,9 +312,6 @@ export type PatchDeep<O, O1, Ignore, Fill> = O extends unknown
324
312
  : never
325
313
  : never;
326
314
 
327
- export type Diff<O, O1, M extends Match = "default"> = PatchFlat<
328
- Exclude<O, O1, M>,
329
- Exclude<O1, O, M>
330
- >;
315
+ export type Diff<O, O1, M extends Match = "default"> = PatchFlat<Exclude<O, O1, M>, Exclude<O1, O, M>>;
331
316
 
332
317
  export type EnforceNonEmpty<O> = keyof O extends never ? never : O;
package/_src/String.ts CHANGED
@@ -13,16 +13,10 @@ export type Join<T extends List<Literal>, D extends string = ""> = _Join<T, D> e
13
13
  ? Cast<X, string>
14
14
  : never;
15
15
 
16
- type __Split<
17
- S extends string,
18
- D extends string,
19
- T extends string[] = [],
20
- > = S extends `${infer BS}${D}${infer AS}` ? __Split<AS, D, [...T, BS]> : [...T, S];
16
+ type __Split<S extends string, D extends string, T extends string[] = []> = S extends `${infer BS}${D}${infer AS}`
17
+ ? __Split<AS, D, [...T, BS]>
18
+ : [...T, S];
21
19
 
22
- type _Split<S extends string, D extends string = ""> = D extends ""
23
- ? Pop<__Split<S, D>>
24
- : __Split<S, D>;
20
+ type _Split<S extends string, D extends string = ""> = D extends "" ? Pop<__Split<S, D>> : __Split<S, D>;
25
21
 
26
- export type Split<S extends string, D extends string = ""> = _Split<S, D> extends infer X
27
- ? Cast<X, string[]>
28
- : never;
22
+ export type Split<S extends string, D extends string = ""> = _Split<S, D> extends infer X ? Cast<X, string[]> : never;
package/_src/Union.ts CHANGED
@@ -1,16 +1,10 @@
1
1
  import type { Cast, Equals, Extends, Is, Match } from "./Any.js";
2
- import type { False,True } from "./Boolean.js";
2
+ import type { False, True } from "./Boolean.js";
3
3
  import type { List, Prepend } from "./List.js";
4
4
 
5
- export type IntersectionOf<U> = (U extends unknown ? (k: U) => void : never) extends (
6
- k: infer I,
7
- ) => void
8
- ? I
9
- : never;
5
+ export type IntersectionOf<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
10
6
 
11
- export type Last<U> = IntersectionOf<U extends unknown ? (x: U) => void : never> extends (
12
- x: infer P,
13
- ) => void
7
+ export type Last<U> = IntersectionOf<U extends unknown ? (x: U) => void : never> extends (x: infer P) => void
14
8
  ? P
15
9
  : never;
16
10
 
@@ -44,4 +38,4 @@ export type Intersect<A, B> = A extends unknown
44
38
 
45
39
  export type Exclude<A, B> = A extends B ? never : A;
46
40
 
47
- export type Pop<U> = Exclude<U, Last<U>>;
41
+ export type Pop<U> = Exclude<U, Last<U>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fncts/typelevel",
3
- "version": "0.0.5",
3
+ "version": "0.0.8",
4
4
  "exports": {
5
5
  "./*": {
6
6
  "import": "./_mjs/*.mjs",