@fncts/typelevel 0.0.15 → 0.0.17
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/Check.d.ts +1 -1
- package/_cjs/HKT.cjs +0 -1
- package/_cjs/HKT.cjs.map +1 -1
- package/_cjs/index.cjs +2 -2
- package/_mjs/HKT.mjs.map +1 -1
- package/_src/Any.ts +20 -21
- package/_src/Check.ts +4 -5
- package/_src/HKT.ts +30 -30
- package/_src/List.ts +2 -3
- package/_src/Number.ts +9 -17
- package/_src/Object.ts +68 -70
- package/_src/String.ts +6 -7
- package/_src/Union.ts +4 -6
- package/package.json +1 -1
package/Check.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare namespace Check {
|
|
|
39
39
|
/**
|
|
40
40
|
* @tsplus type fncts.Check.IsLiteral
|
|
41
41
|
*/
|
|
42
|
-
type IsLiteral<A extends string | number | boolean> = Not<Extends<string, A> | Extends<number, A> | Extends<boolean, A>>;
|
|
42
|
+
type IsLiteral<A extends string | number | boolean | bigint | null> = Not<Extends<string, A> | Extends<number, A> | Extends<boolean, A> | Extends<bigint, A> | Extends<null, A>>;
|
|
43
43
|
/**
|
|
44
44
|
* @tsplus type fncts.Check.IsStruct
|
|
45
45
|
*/
|
package/_cjs/HKT.cjs
CHANGED
package/_cjs/HKT.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HKT.cjs","names":["HKT","instance","_","unifyFK1"],"sources":["../esm/HKT.js"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-namespace\nexport var HKT;\n(function (HKT) {\n /*\n * Instance util\n */\n /**\n * @tsplus macro identity\n */\n function instance(_) {\n // @ts-expect-error: typelevel utility\n return _;\n }\n HKT.instance = instance;\n})(HKT || (HKT = {}));\n/**\n * @tsplus unify fncts.HKT.FK1\n */\nexport function unifyFK1(_) {\n return _;\n}\n"],"mappings":";;;;;;;AAAA;AACO,IAAIA,GAAG;
|
|
1
|
+
{"version":3,"file":"HKT.cjs","names":["HKT","instance","_","exports","unifyFK1"],"sources":["../esm/HKT.js"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-namespace\nexport var HKT;\n(function (HKT) {\n /*\n * Instance util\n */\n /**\n * @tsplus macro identity\n */\n function instance(_) {\n // @ts-expect-error: typelevel utility\n return _;\n }\n HKT.instance = instance;\n})(HKT || (HKT = {}));\n/**\n * @tsplus unify fncts.HKT.FK1\n */\nexport function unifyFK1(_) {\n return _;\n}\n"],"mappings":";;;;;;;AAAA;AACO,IAAIA,GAAG;AACd,CAAC,UAAUA,GAAG,EAAE;EACZ;AACJ;AACA;EACI;AACJ;AACA;EACI,SAASC,QAAQA,CAACC,CAAC,EAAE;IACjB;IACA,OAAOA,CAAC;EACZ;EACAF,GAAG,CAACC,QAAQ,GAAGA,QAAQ;AAC3B,CAAC,EAAED,GAAG,KAAAG,OAAA,CAAAH,GAAA,GAAKA,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACrB;AACA;AACA;AACO,SAASI,QAAQA,CAACF,CAAC,EAAE;EACxB,OAAOA,CAAC;AACZ"}
|
package/_cjs/index.cjs
CHANGED
|
@@ -24,6 +24,6 @@ var _String = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Stri
|
|
|
24
24
|
exports.String = _String;
|
|
25
25
|
var _Union = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Union.cjs"));
|
|
26
26
|
exports.Union = _Union;
|
|
27
|
-
function _getRequireWildcardCache(
|
|
28
|
-
function _interopRequireWildcard(
|
|
27
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
28
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
29
|
//# sourceMappingURL=index.cjs.map
|
package/_mjs/HKT.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HKT.mjs","names":["HKT","instance","_","unifyFK1"],"sources":["../esm/HKT.js"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-namespace\nexport var HKT;\n(function (HKT) {\n /*\n * Instance util\n */\n /**\n * @tsplus macro identity\n */\n function instance(_) {\n // @ts-expect-error: typelevel utility\n return _;\n }\n HKT.instance = instance;\n})(HKT || (HKT = {}));\n/**\n * @tsplus unify fncts.HKT.FK1\n */\nexport function unifyFK1(_) {\n return _;\n}\n"],"mappings":"AAAA;AACA,OAAO,IAAIA,GAAG;AACd,CAAC,UAAUA,GAAG,EAAE;EACZ;AACJ;AACA;EACI;AACJ;AACA;EACI,SAASC,
|
|
1
|
+
{"version":3,"file":"HKT.mjs","names":["HKT","instance","_","unifyFK1"],"sources":["../esm/HKT.js"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-namespace\nexport var HKT;\n(function (HKT) {\n /*\n * Instance util\n */\n /**\n * @tsplus macro identity\n */\n function instance(_) {\n // @ts-expect-error: typelevel utility\n return _;\n }\n HKT.instance = instance;\n})(HKT || (HKT = {}));\n/**\n * @tsplus unify fncts.HKT.FK1\n */\nexport function unifyFK1(_) {\n return _;\n}\n"],"mappings":"AAAA;AACA,OAAO,IAAIA,GAAG;AACd,CAAC,UAAUA,GAAG,EAAE;EACZ;AACJ;AACA;EACI;AACJ;AACA;EACI,SAASC,QAAQA,CAACC,CAAC,EAAE;IACjB;IACA,OAAOA,CAAC;EACZ;EACAF,GAAG,CAACC,QAAQ,GAAGA,QAAQ;AAC3B,CAAC,EAAED,GAAG,KAAKA,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACrB;AACA;AACA;AACA,OAAO,SAASG,QAAQA,CAACD,CAAC,EAAE;EACxB,OAAOA,CAAC;AACZ"}
|
package/_src/Any.ts
CHANGED
|
@@ -11,9 +11,8 @@ export type Extends<A, B> = [A] extends [never] ? False : A extends B ? True : F
|
|
|
11
11
|
|
|
12
12
|
export type Contains<A, B> = Extends<A, B> extends True ? True : False;
|
|
13
13
|
|
|
14
|
-
export type Equals<A, B> =
|
|
15
|
-
? True
|
|
16
|
-
: False;
|
|
14
|
+
export type Equals<A, B> =
|
|
15
|
+
(<X>() => X extends B ? True : False) extends <X>() => X extends A ? True : False ? True : False;
|
|
17
16
|
|
|
18
17
|
export type If<B extends Boolean, Then, Else = never> = B extends True ? Then : Else;
|
|
19
18
|
|
|
@@ -58,14 +57,14 @@ export type ComputeRaw<A> = A extends Function ? A : { [K in keyof A]: A[K] } &
|
|
|
58
57
|
export type ComputeFlat<A> = A extends BuiltIn
|
|
59
58
|
? A
|
|
60
59
|
: A extends Array<any>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
? A extends Array<Record<Key, any>>
|
|
61
|
+
? Array<{ [K in keyof A[number]]: A[number][K] } & unknown>
|
|
62
|
+
: A
|
|
63
|
+
: A extends ReadonlyArray<any>
|
|
64
|
+
? A extends ReadonlyArray<Record<Key, any>>
|
|
65
|
+
? ReadonlyArray<{ [K in keyof A[number]]: A[number][K] } & unknown>
|
|
66
|
+
: A
|
|
67
|
+
: { [K in keyof A]: A[K] } & unknown;
|
|
69
68
|
|
|
70
69
|
export type ComputeDeep<A, Seen = never> = A extends BuiltIn
|
|
71
70
|
? A
|
|
@@ -75,10 +74,10 @@ export type ComputeDeep<A, Seen = never> = A extends BuiltIn
|
|
|
75
74
|
? Array<{ [K in keyof A[number]]: ComputeDeep<A[number][K], A | Seen> } & unknown>
|
|
76
75
|
: A
|
|
77
76
|
: A extends ReadonlyArray<any>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
? A extends ReadonlyArray<Record<Key, any>>
|
|
78
|
+
? ReadonlyArray<{ [K in keyof A[number]]: ComputeDeep<A[number][K], A | Seen> } & unknown>
|
|
79
|
+
: A
|
|
80
|
+
: { [K in keyof A]: ComputeDeep<A[K], A | Seen> } & unknown;
|
|
82
81
|
[True]: A;
|
|
83
82
|
}[Has<Seen, A>];
|
|
84
83
|
|
|
@@ -88,10 +87,10 @@ export type At<A, K extends Key> = A extends List
|
|
|
88
87
|
? A[never] | undefined
|
|
89
88
|
: undefined
|
|
90
89
|
: K extends keyof A
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
? A[K]
|
|
91
|
+
: undefined
|
|
93
92
|
: unknown extends A
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
? unknown
|
|
94
|
+
: K extends keyof A
|
|
95
|
+
? A[K]
|
|
96
|
+
: undefined;
|
package/_src/Check.ts
CHANGED
|
@@ -46,15 +46,14 @@ export declare namespace Check {
|
|
|
46
46
|
/**
|
|
47
47
|
* @tsplus type fncts.Check.IsEqual
|
|
48
48
|
*/
|
|
49
|
-
type IsEqual<A, B> =
|
|
50
|
-
? unknown
|
|
51
|
-
: never;
|
|
49
|
+
type IsEqual<A, B> =
|
|
50
|
+
(<T>() => T extends EqualsWrapped<A> ? 1 : 2) extends <T>() => T extends EqualsWrapped<B> ? 1 : 2 ? unknown : never;
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
53
|
* @tsplus type fncts.Check.IsLiteral
|
|
55
54
|
*/
|
|
56
|
-
type IsLiteral<A extends string | number | boolean> = Not<
|
|
57
|
-
Extends<string, A> | Extends<number, A> | Extends<boolean, A>
|
|
55
|
+
type IsLiteral<A extends string | number | boolean | bigint | null> = Not<
|
|
56
|
+
Extends<string, A> | Extends<number, A> | Extends<boolean, A> | Extends<bigint, A> | Extends<null, A>
|
|
58
57
|
>;
|
|
59
58
|
|
|
60
59
|
/**
|
package/_src/HKT.ts
CHANGED
|
@@ -227,24 +227,24 @@ export namespace HKT {
|
|
|
227
227
|
? N extends "C"
|
|
228
228
|
? C
|
|
229
229
|
: N extends "K"
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
230
|
+
? K
|
|
231
|
+
: N extends "Q"
|
|
232
|
+
? Q
|
|
233
|
+
: N extends "W"
|
|
234
|
+
? W
|
|
235
|
+
: N extends "X"
|
|
236
|
+
? X
|
|
237
|
+
: N extends "I"
|
|
238
|
+
? I
|
|
239
|
+
: N extends "S"
|
|
240
|
+
? S
|
|
241
|
+
: N extends "R"
|
|
242
|
+
? R
|
|
243
|
+
: N extends "E"
|
|
244
|
+
? E
|
|
245
|
+
: N extends "A"
|
|
246
|
+
? A
|
|
247
|
+
: never
|
|
248
248
|
: never;
|
|
249
249
|
|
|
250
250
|
/*
|
|
@@ -269,14 +269,14 @@ export namespace HKT {
|
|
|
269
269
|
"-": P extends [any]
|
|
270
270
|
? P[0]
|
|
271
271
|
: P extends [any, any]
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
272
|
+
? P[0] & P[1]
|
|
273
|
+
: P extends [any, any, any]
|
|
274
|
+
? P[0] & P[1] & P[2]
|
|
275
|
+
: P extends [any, any, any, any]
|
|
276
|
+
? P[0] & P[1] & P[2] & P[3]
|
|
277
|
+
: P extends [any, any, any, any, any]
|
|
278
|
+
? P[0] & P[1] & P[2] & P[3] & P[4]
|
|
279
|
+
: Union.IntersectionOf<P[number]>;
|
|
280
280
|
"+": P[number];
|
|
281
281
|
_: P[0];
|
|
282
282
|
}
|
|
@@ -291,10 +291,10 @@ export namespace HKT {
|
|
|
291
291
|
export type MixStruct<F extends HKT, N extends ParamName, X, Y> = F["variance"][N] extends "_"
|
|
292
292
|
? X
|
|
293
293
|
: F["variance"][N] extends "+"
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
? Y[keyof Y]
|
|
295
|
+
: F["variance"][N] extends "-"
|
|
296
|
+
? Union.IntersectionOf<{ [k in keyof Y]: OrNever<Y[k]> }[keyof Y]>
|
|
297
|
+
: X;
|
|
298
298
|
|
|
299
299
|
export interface Intros<A, B> {
|
|
300
300
|
"-": B;
|
package/_src/List.ts
CHANGED
|
@@ -20,9 +20,8 @@ export type Last<L extends List> = L[Length<Tail<L>>];
|
|
|
20
20
|
|
|
21
21
|
export type UnionOf<L extends List> = L[number];
|
|
22
22
|
|
|
23
|
-
export type PrependAll<L extends List, A, O extends List = []> =
|
|
24
|
-
? O
|
|
25
|
-
: PrependAll<Tail<L>, A, [...O, A, Head<L>]>;
|
|
23
|
+
export type PrependAll<L extends List, A, O extends List = []> =
|
|
24
|
+
Length<L> extends 0 ? O : PrependAll<Tail<L>, A, [...O, A, Head<L>]>;
|
|
26
25
|
|
|
27
26
|
export type Pop<L extends List> = L extends readonly [...infer LBody, any] | readonly [...infer LBody, any?]
|
|
28
27
|
? LBody
|
package/_src/Number.ts
CHANGED
|
@@ -30,25 +30,17 @@ export type _Negate<N extends Iteration> = IterationMap[N[4]];
|
|
|
30
30
|
|
|
31
31
|
export type Negate<N extends number> = N extends unknown ? _Negate<IterationOf<N>>[0] : never;
|
|
32
32
|
|
|
33
|
-
export type _AddPositive<N1 extends Iteration, N2 extends Iteration> =
|
|
34
|
-
? N1
|
|
35
|
-
: number extends Pos<N2>
|
|
36
|
-
? IterationOf<number>
|
|
37
|
-
: _AddPositive<Next<N1>, Prev<N2>>;
|
|
38
|
-
|
|
39
|
-
export type AddPositive<N1 extends Iteration, N2 extends Iteration> = _AddPositive<N1, N2> extends infer X
|
|
40
|
-
? Cast<X, Iteration>
|
|
41
|
-
: never;
|
|
33
|
+
export type _AddPositive<N1 extends Iteration, N2 extends Iteration> =
|
|
34
|
+
Pos<N2> extends 0 ? N1 : number extends Pos<N2> ? IterationOf<number> : _AddPositive<Next<N1>, Prev<N2>>;
|
|
42
35
|
|
|
43
|
-
export type
|
|
44
|
-
?
|
|
45
|
-
: number extends Pos<N2>
|
|
46
|
-
? IterationOf<number>
|
|
47
|
-
: _AddNegative<Prev<N1>, Next<N2>>;
|
|
36
|
+
export type AddPositive<N1 extends Iteration, N2 extends Iteration> =
|
|
37
|
+
_AddPositive<N1, N2> extends infer X ? Cast<X, Iteration> : never;
|
|
48
38
|
|
|
49
|
-
export type
|
|
50
|
-
?
|
|
51
|
-
|
|
39
|
+
export type _AddNegative<N1 extends Iteration, N2 extends Iteration> =
|
|
40
|
+
Pos<N2> extends 0 ? N1 : number extends Pos<N2> ? IterationOf<number> : _AddNegative<Prev<N1>, Next<N2>>;
|
|
41
|
+
|
|
42
|
+
export type AddNegative<N1 extends Iteration, N2 extends Iteration> =
|
|
43
|
+
_AddNegative<N1, N2> extends infer X ? Cast<X, Iteration> : never;
|
|
52
44
|
|
|
53
45
|
export type _Add<N1 extends Iteration, N2 extends Iteration> = {
|
|
54
46
|
[False]: AddPositive<N1, N2>;
|
package/_src/Object.ts
CHANGED
|
@@ -170,36 +170,31 @@ type Longer<L extends List, L1 extends List> = L extends unknown
|
|
|
170
170
|
type MergeProp<OK, O1K, Fill, OOKeys extends Key, K extends Key> = K extends OOKeys
|
|
171
171
|
? U.Exclude<OK, undefined> | O1K
|
|
172
172
|
: [OK] extends [never]
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
? O1K
|
|
174
|
+
: OK extends Fill
|
|
175
|
+
? O1K
|
|
176
|
+
: OK;
|
|
177
177
|
|
|
178
178
|
type MergeFlatObject<O, O1, Fill, OOKeys extends Key = OptionalKeys<O>> = {
|
|
179
179
|
[K in keyof (Anyify<O> & O1)]: MergeProp<At<O, K>, At<O1, K>, Fill, OOKeys, K>;
|
|
180
180
|
} & {};
|
|
181
181
|
|
|
182
|
-
type MergeFlatList<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
> = number extends Length<L | L1>
|
|
189
|
-
? MergeFlatChoice<L[number], L1[number], Ignore, Fill>[]
|
|
190
|
-
: Longer<L, L1> extends True
|
|
191
|
-
? { [K in keyof L]: MergeProp<L[K], At<L1, K>, Fill, LOK, K> }
|
|
192
|
-
: { [K in keyof L1]: MergeProp<At<L, K>, L1[K], Fill, LOK, K> };
|
|
182
|
+
type MergeFlatList<L extends List, L1 extends List, Ignore, Fill, LOK extends Key = _OptionalKeys<L>> =
|
|
183
|
+
number extends Length<L | L1>
|
|
184
|
+
? MergeFlatChoice<L[number], L1[number], Ignore, Fill>[]
|
|
185
|
+
: Longer<L, L1> extends True
|
|
186
|
+
? { [K in keyof L]: MergeProp<L[K], At<L1, K>, Fill, LOK, K> }
|
|
187
|
+
: { [K in keyof L1]: MergeProp<At<L, K>, L1[K], Fill, LOK, K> };
|
|
193
188
|
|
|
194
189
|
type MergeFlatChoice<O, O1, Ignore, Fill> = O extends Ignore
|
|
195
190
|
? O
|
|
196
191
|
: O1 extends Ignore
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
192
|
+
? O
|
|
193
|
+
: O extends List
|
|
194
|
+
? O1 extends List
|
|
195
|
+
? MergeFlatList<O, O1, Ignore, Fill>
|
|
196
|
+
: MergeFlatObject<O, O1, Fill>
|
|
197
|
+
: MergeFlatObject<O, O1, Fill>;
|
|
203
198
|
|
|
204
199
|
export type MergeFlat<O, O1, Ignore = BuiltIn, Fill = undefined> = O extends unknown
|
|
205
200
|
? O1 extends unknown
|
|
@@ -207,11 +202,12 @@ export type MergeFlat<O, O1, Ignore = BuiltIn, Fill = undefined> = O extends unk
|
|
|
207
202
|
: never
|
|
208
203
|
: never;
|
|
209
204
|
|
|
210
|
-
type MergeDeepList<L extends List, L1 extends List, Ignore, Fill> =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
205
|
+
type MergeDeepList<L extends List, L1 extends List, Ignore, Fill> =
|
|
206
|
+
number extends Length<L | L1>
|
|
207
|
+
? MergeDeepChoice<L[number], L1[number], Ignore, Fill, never, any>[]
|
|
208
|
+
: Longer<L, L1> extends True
|
|
209
|
+
? { [K in keyof L]: MergeDeepChoice<L[K], At<L1, K>, Ignore, Fill, _OptionalKeys<L>, K> }
|
|
210
|
+
: { [K in keyof L1]: MergeDeepChoice<At<L, K>, L1[K], Ignore, Fill, _OptionalKeys<L>, K> };
|
|
215
211
|
|
|
216
212
|
type MergeDeepObject<O, O1, Ignore, Fill, OOKeys extends Key = _OptionalKeys<O>> = {
|
|
217
213
|
[K in keyof (Anyify<O> & O1)]: MergeDeepChoice<At<O, K>, At<O1, K>, Ignore, Fill, OOKeys, K>;
|
|
@@ -220,20 +216,20 @@ type MergeDeepObject<O, O1, Ignore, Fill, OOKeys extends Key = _OptionalKeys<O>>
|
|
|
220
216
|
type MergeDeepChoice<OK, O1K, Ignore, Fill, OOKeys extends Key, K extends Key> = [OK] extends [never]
|
|
221
217
|
? MergeProp<OK, O1K, Fill, OOKeys, K>
|
|
222
218
|
: [O1K] extends [never]
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
219
|
+
? MergeProp<OK, O1K, Fill, OOKeys, K>
|
|
220
|
+
: OK extends Ignore
|
|
221
|
+
? MergeProp<OK, O1K, Fill, OOKeys, K>
|
|
222
|
+
: O1K extends Ignore
|
|
223
|
+
? MergeProp<OK, O1K, Fill, OOKeys, K>
|
|
224
|
+
: OK extends List
|
|
225
|
+
? O1K extends List
|
|
226
|
+
? MergeDeepList<OK, O1K, Ignore, Fill>
|
|
227
|
+
: MergeProp<OK, O1K, Fill, OOKeys, K>
|
|
228
|
+
: OK extends object
|
|
229
|
+
? O1K extends object
|
|
230
|
+
? MergeDeepObject<OK, O1K, Ignore, Fill>
|
|
231
|
+
: MergeProp<OK, O1K, Fill, OOKeys, K>
|
|
232
|
+
: MergeProp<OK, O1K, Fill, OOKeys, K>;
|
|
237
233
|
|
|
238
234
|
export type MergeDeep<O, O1, Ignore, Fill> = O extends unknown
|
|
239
235
|
? O1 extends unknown
|
|
@@ -256,21 +252,22 @@ type PatchFlatObject<O, O1, Fill, OKeys extends Key = keyof O> = {
|
|
|
256
252
|
[K in keyof (O & _Omit<O1, OKeys>)]: PatchProp<At<O, K>, At<O1, K>, Fill, OKeys, K>;
|
|
257
253
|
} & {};
|
|
258
254
|
|
|
259
|
-
type PatchFlatList<L extends List, L1 extends List, Ignore, Fill> =
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
255
|
+
type PatchFlatList<L extends List, L1 extends List, Ignore, Fill> =
|
|
256
|
+
number extends Length<L | L1>
|
|
257
|
+
? PatchFlatChoice<L[number], L1[number], Ignore, Fill>[]
|
|
258
|
+
: Longer<L, L1> extends True
|
|
259
|
+
? { [K in keyof L]: PatchProp<L[K], At<L1, K>, Fill, keyof L, K> }
|
|
260
|
+
: { [K in keyof L1]: PatchProp<At<L, K>, L1[K], Fill, keyof L, K> };
|
|
264
261
|
|
|
265
262
|
export type PatchFlatChoice<O, O1, Ignore, Fill> = O extends Ignore
|
|
266
263
|
? O
|
|
267
264
|
: O1 extends Ignore
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
265
|
+
? O
|
|
266
|
+
: O extends List
|
|
267
|
+
? O1 extends List
|
|
268
|
+
? PatchFlatList<O, O1, Ignore, Fill>
|
|
269
|
+
: PatchFlatObject<O, O1, Fill>
|
|
270
|
+
: PatchFlatObject<O, O1, Fill>;
|
|
274
271
|
|
|
275
272
|
export type PatchFlat<O, O1, Ignore = BuiltIn, Fill = never> = O extends unknown
|
|
276
273
|
? O1 extends unknown
|
|
@@ -278,11 +275,12 @@ export type PatchFlat<O, O1, Ignore = BuiltIn, Fill = never> = O extends unknown
|
|
|
278
275
|
: never
|
|
279
276
|
: never;
|
|
280
277
|
|
|
281
|
-
type PatchDeepList<L extends List, L1 extends List, Ignore, Fill> =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
278
|
+
type PatchDeepList<L extends List, L1 extends List, Ignore, Fill> =
|
|
279
|
+
number extends Length<L | L1>
|
|
280
|
+
? PatchDeepChoice<L[number], L1[number], Ignore, Fill, never, any>[]
|
|
281
|
+
: Longer<L, L1> extends True
|
|
282
|
+
? { [K in keyof L]: PatchDeepChoice<L[K], At<L1, K>, Ignore, Fill, keyof L, K> }
|
|
283
|
+
: { [K in keyof L1]: PatchDeepChoice<At<L, K>, L1[K], Ignore, Fill, keyof L, K> };
|
|
286
284
|
|
|
287
285
|
type PatchDeepObject<O, O1, Ignore, Fill, OKeys extends Key = keyof O> = {
|
|
288
286
|
[K in keyof (O & _Omit<O1, OKeys>)]: PatchDeepChoice<At<O, K>, At<O1, K>, Ignore, Fill, OKeys, K>;
|
|
@@ -291,20 +289,20 @@ type PatchDeepObject<O, O1, Ignore, Fill, OKeys extends Key = keyof O> = {
|
|
|
291
289
|
type PatchDeepChoice<OK, O1K, Ignore, fill, OKeys extends Key, K extends Key> = [OK] extends [never]
|
|
292
290
|
? PatchProp<OK, O1K, fill, OKeys, K>
|
|
293
291
|
: [O1K] extends [never]
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
292
|
+
? PatchProp<OK, O1K, fill, OKeys, K>
|
|
293
|
+
: OK extends Ignore
|
|
294
|
+
? PatchProp<OK, O1K, fill, OKeys, K>
|
|
295
|
+
: O1K extends Ignore
|
|
296
|
+
? PatchProp<OK, O1K, fill, OKeys, K>
|
|
297
|
+
: OK extends List
|
|
298
|
+
? O1K extends List
|
|
299
|
+
? PatchDeepList<OK, O1K, Ignore, fill>
|
|
300
|
+
: PatchProp<OK, O1K, fill, OKeys, K>
|
|
301
|
+
: OK extends object
|
|
302
|
+
? O1K extends object
|
|
303
|
+
? PatchDeepObject<OK, O1K, Ignore, fill>
|
|
304
|
+
: PatchProp<OK, O1K, fill, OKeys, K>
|
|
305
|
+
: PatchProp<OK, O1K, fill, OKeys, K>;
|
|
308
306
|
|
|
309
307
|
export type PatchDeep<O, O1, Ignore, Fill> = O extends unknown
|
|
310
308
|
? O1 extends unknown
|
package/_src/String.ts
CHANGED
|
@@ -4,14 +4,13 @@ import type { List, Pop } from "./List.js";
|
|
|
4
4
|
type _Join<T extends List, D extends string> = T extends []
|
|
5
5
|
? ""
|
|
6
6
|
: T extends [Literal]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
? `${T[0]}`
|
|
8
|
+
: T extends [Literal, ...infer R]
|
|
9
|
+
? `${T[0]}${D}${_Join<R, D>}`
|
|
10
|
+
: string;
|
|
11
11
|
|
|
12
|
-
export type Join<T extends List<Literal>, D extends string = ""> =
|
|
13
|
-
? Cast<X, string>
|
|
14
|
-
: never;
|
|
12
|
+
export type Join<T extends List<Literal>, D extends string = ""> =
|
|
13
|
+
_Join<T, D> extends infer X ? Cast<X, string> : never;
|
|
15
14
|
|
|
16
15
|
type __Split<S extends string, D extends string, T extends string[] = []> = S extends `${infer BS}${D}${infer AS}`
|
|
17
16
|
? __Split<AS, D, [...T, BS]>
|
package/_src/Union.ts
CHANGED
|
@@ -4,13 +4,11 @@ import type { List, Prepend } from "./List.js";
|
|
|
4
4
|
|
|
5
5
|
export type IntersectionOf<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
6
6
|
|
|
7
|
-
export type Last<U> =
|
|
8
|
-
? P
|
|
9
|
-
: never;
|
|
7
|
+
export type Last<U> =
|
|
8
|
+
IntersectionOf<U extends unknown ? (x: U) => void : never> extends (x: infer P) => void ? P : never;
|
|
10
9
|
|
|
11
|
-
type _ListOf<U, LN extends List = [], LastU = Last<U>> =
|
|
12
|
-
? _ListOf<Exclude<U, LastU>, Prepend<LN, LastU>>
|
|
13
|
-
: LN;
|
|
10
|
+
type _ListOf<U, LN extends List = [], LastU = Last<U>> =
|
|
11
|
+
Extends<[U], [never]> extends False ? _ListOf<Exclude<U, LastU>, Prepend<LN, LastU>> : LN;
|
|
14
12
|
|
|
15
13
|
export type ListOf<U> = _ListOf<U> extends infer X ? Cast<X, List> : never;
|
|
16
14
|
|