@nestia/fetcher 9.0.0-dev.20251107-3 → 9.0.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.
- package/README.md +93 -93
- package/package.json +1 -1
- package/src/AesPkcs5.ts +49 -49
- package/src/EncryptedFetcher.ts +176 -176
- package/src/FormDataInput.ts +80 -80
- package/src/HttpError.ts +1 -1
- package/src/IConnection.ts +241 -241
- package/src/IEncryptionPassword.ts +44 -44
- package/src/IFetchEvent.ts +31 -31
- package/src/IFetchRoute.ts +60 -60
- package/src/IPropagation.ts +99 -99
- package/src/MigrateFetcher.ts +118 -118
- package/src/NestiaSimulator.ts +82 -82
- package/src/PlainFetcher.ts +105 -105
- package/src/index.ts +7 -7
- package/src/internal/FetcherBase.ts +235 -235
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { IConnection } from "./IConnection";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Encryption password.
|
|
5
|
-
*
|
|
6
|
-
* `IEncryptionPassword` is a type of interface who represents encryption
|
|
7
|
-
* password used by the {@link Fetcher} with AES-128/256 algorithm. If your
|
|
8
|
-
* encryption password is not fixed but changes according to the input content,
|
|
9
|
-
* you can utilize the {@link IEncryptionPassword.Closure} function type.
|
|
10
|
-
*
|
|
11
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
-
*/
|
|
13
|
-
export interface IEncryptionPassword {
|
|
14
|
-
/** Secret key. */
|
|
15
|
-
key: string;
|
|
16
|
-
|
|
17
|
-
/** Initialization Vector. */
|
|
18
|
-
iv: string;
|
|
19
|
-
}
|
|
20
|
-
export namespace IEncryptionPassword {
|
|
21
|
-
/**
|
|
22
|
-
* Type of a closure function returning the {@link IEncryptionPassword} object.
|
|
23
|
-
*
|
|
24
|
-
* `IEncryptionPassword.Closure` is a type of closure function who are
|
|
25
|
-
* returning the {@link IEncryptionPassword} object. It would be used when your
|
|
26
|
-
* encryption password be changed according to the input content.
|
|
27
|
-
*/
|
|
28
|
-
export interface Closure {
|
|
29
|
-
/**
|
|
30
|
-
* Encryption password getter.
|
|
31
|
-
*
|
|
32
|
-
* @param props Properties for predication
|
|
33
|
-
* @returns Encryption password
|
|
34
|
-
*/
|
|
35
|
-
(props: IProps): IEncryptionPassword;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Properties for the closure. */
|
|
39
|
-
export interface IProps {
|
|
40
|
-
headers: Record<string, IConnection.HeaderValue | undefined>;
|
|
41
|
-
body: string;
|
|
42
|
-
direction: "encode" | "decode";
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
import { IConnection } from "./IConnection";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Encryption password.
|
|
5
|
+
*
|
|
6
|
+
* `IEncryptionPassword` is a type of interface who represents encryption
|
|
7
|
+
* password used by the {@link Fetcher} with AES-128/256 algorithm. If your
|
|
8
|
+
* encryption password is not fixed but changes according to the input content,
|
|
9
|
+
* you can utilize the {@link IEncryptionPassword.Closure} function type.
|
|
10
|
+
*
|
|
11
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
+
*/
|
|
13
|
+
export interface IEncryptionPassword {
|
|
14
|
+
/** Secret key. */
|
|
15
|
+
key: string;
|
|
16
|
+
|
|
17
|
+
/** Initialization Vector. */
|
|
18
|
+
iv: string;
|
|
19
|
+
}
|
|
20
|
+
export namespace IEncryptionPassword {
|
|
21
|
+
/**
|
|
22
|
+
* Type of a closure function returning the {@link IEncryptionPassword} object.
|
|
23
|
+
*
|
|
24
|
+
* `IEncryptionPassword.Closure` is a type of closure function who are
|
|
25
|
+
* returning the {@link IEncryptionPassword} object. It would be used when your
|
|
26
|
+
* encryption password be changed according to the input content.
|
|
27
|
+
*/
|
|
28
|
+
export interface Closure {
|
|
29
|
+
/**
|
|
30
|
+
* Encryption password getter.
|
|
31
|
+
*
|
|
32
|
+
* @param props Properties for predication
|
|
33
|
+
* @returns Encryption password
|
|
34
|
+
*/
|
|
35
|
+
(props: IProps): IEncryptionPassword;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Properties for the closure. */
|
|
39
|
+
export interface IProps {
|
|
40
|
+
headers: Record<string, IConnection.HeaderValue | undefined>;
|
|
41
|
+
body: string;
|
|
42
|
+
direction: "encode" | "decode";
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/IFetchEvent.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
// import { IConnection } from "./IConnection";
|
|
2
|
-
import { IFetchRoute } from "./IFetchRoute";
|
|
3
|
-
|
|
4
|
-
export interface IFetchEvent {
|
|
5
|
-
route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">;
|
|
6
|
-
path: string;
|
|
7
|
-
status: number | null;
|
|
8
|
-
input: any;
|
|
9
|
-
output: any;
|
|
10
|
-
started_at: Date;
|
|
11
|
-
respond_at: Date | null;
|
|
12
|
-
completed_at: Date;
|
|
13
|
-
}
|
|
14
|
-
// export namespace IFetchEvent {
|
|
15
|
-
// export interface IFunction {
|
|
16
|
-
// (connection: IConnection, ...args: any[]): Promise<any>;
|
|
17
|
-
// METADATA: {
|
|
18
|
-
// method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
19
|
-
// path: string;
|
|
20
|
-
// request: null | {
|
|
21
|
-
// type: string;
|
|
22
|
-
// encrypted: boolean;
|
|
23
|
-
// };
|
|
24
|
-
// response: null | {
|
|
25
|
-
// type: string;
|
|
26
|
-
// encrypted: boolean;
|
|
27
|
-
// };
|
|
28
|
-
// };
|
|
29
|
-
// status: null | number;
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
1
|
+
// import { IConnection } from "./IConnection";
|
|
2
|
+
import { IFetchRoute } from "./IFetchRoute";
|
|
3
|
+
|
|
4
|
+
export interface IFetchEvent {
|
|
5
|
+
route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">;
|
|
6
|
+
path: string;
|
|
7
|
+
status: number | null;
|
|
8
|
+
input: any;
|
|
9
|
+
output: any;
|
|
10
|
+
started_at: Date;
|
|
11
|
+
respond_at: Date | null;
|
|
12
|
+
completed_at: Date;
|
|
13
|
+
}
|
|
14
|
+
// export namespace IFetchEvent {
|
|
15
|
+
// export interface IFunction {
|
|
16
|
+
// (connection: IConnection, ...args: any[]): Promise<any>;
|
|
17
|
+
// METADATA: {
|
|
18
|
+
// method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
19
|
+
// path: string;
|
|
20
|
+
// request: null | {
|
|
21
|
+
// type: string;
|
|
22
|
+
// encrypted: boolean;
|
|
23
|
+
// };
|
|
24
|
+
// response: null | {
|
|
25
|
+
// type: string;
|
|
26
|
+
// encrypted: boolean;
|
|
27
|
+
// };
|
|
28
|
+
// };
|
|
29
|
+
// status: null | number;
|
|
30
|
+
// }
|
|
31
|
+
// }
|
package/src/IFetchRoute.ts
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Properties of remote API route.
|
|
3
|
-
*
|
|
4
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
5
|
-
*/
|
|
6
|
-
export interface IFetchRoute<
|
|
7
|
-
Method extends "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
|
|
8
|
-
> {
|
|
9
|
-
/** Method of the HTTP request. */
|
|
10
|
-
method: Method;
|
|
11
|
-
|
|
12
|
-
/** Path of the HTTP request. */
|
|
13
|
-
path: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Path template.
|
|
17
|
-
*
|
|
18
|
-
* Filled since 3.2.2 version.
|
|
19
|
-
*/
|
|
20
|
-
template?: string;
|
|
21
|
-
|
|
22
|
-
/** Request body data info. */
|
|
23
|
-
request: Method extends "DELETE" | "POST" | "PUT" | "PATCH"
|
|
24
|
-
? IFetchRoute.IBody | null
|
|
25
|
-
: null;
|
|
26
|
-
|
|
27
|
-
/** Response body data info. */
|
|
28
|
-
response: Method extends "HEAD" ? null : IFetchRoute.IBody;
|
|
29
|
-
|
|
30
|
-
/** When special status code being used. */
|
|
31
|
-
status: number | null;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Parser of the query string.
|
|
35
|
-
*
|
|
36
|
-
* If content type of response body is `application/x-www-form-urlencoded`,
|
|
37
|
-
* then this `parseQuery` function would be called.
|
|
38
|
-
*
|
|
39
|
-
* If you've forgotten to configuring this `parseQuery` property about the
|
|
40
|
-
* `application/x-www-form-urlencoded` typed response body data, then only the
|
|
41
|
-
* `URLSearchParams` typed instance would be returned instead.
|
|
42
|
-
*/
|
|
43
|
-
parseQuery?(input: URLSearchParams): any;
|
|
44
|
-
}
|
|
45
|
-
export namespace IFetchRoute {
|
|
46
|
-
/**
|
|
47
|
-
* Metadata of body.
|
|
48
|
-
*
|
|
49
|
-
* Describes how content-type being used in body, and whether encrypted or
|
|
50
|
-
* not.
|
|
51
|
-
*/
|
|
52
|
-
export interface IBody {
|
|
53
|
-
type:
|
|
54
|
-
| "application/json"
|
|
55
|
-
| "application/x-www-form-urlencoded"
|
|
56
|
-
| "multipart/form-data"
|
|
57
|
-
| "text/plain";
|
|
58
|
-
encrypted?: boolean;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Properties of remote API route.
|
|
3
|
+
*
|
|
4
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
5
|
+
*/
|
|
6
|
+
export interface IFetchRoute<
|
|
7
|
+
Method extends "HEAD" | "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
|
|
8
|
+
> {
|
|
9
|
+
/** Method of the HTTP request. */
|
|
10
|
+
method: Method;
|
|
11
|
+
|
|
12
|
+
/** Path of the HTTP request. */
|
|
13
|
+
path: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Path template.
|
|
17
|
+
*
|
|
18
|
+
* Filled since 3.2.2 version.
|
|
19
|
+
*/
|
|
20
|
+
template?: string;
|
|
21
|
+
|
|
22
|
+
/** Request body data info. */
|
|
23
|
+
request: Method extends "DELETE" | "POST" | "PUT" | "PATCH"
|
|
24
|
+
? IFetchRoute.IBody | null
|
|
25
|
+
: null;
|
|
26
|
+
|
|
27
|
+
/** Response body data info. */
|
|
28
|
+
response: Method extends "HEAD" ? null : IFetchRoute.IBody;
|
|
29
|
+
|
|
30
|
+
/** When special status code being used. */
|
|
31
|
+
status: number | null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Parser of the query string.
|
|
35
|
+
*
|
|
36
|
+
* If content type of response body is `application/x-www-form-urlencoded`,
|
|
37
|
+
* then this `parseQuery` function would be called.
|
|
38
|
+
*
|
|
39
|
+
* If you've forgotten to configuring this `parseQuery` property about the
|
|
40
|
+
* `application/x-www-form-urlencoded` typed response body data, then only the
|
|
41
|
+
* `URLSearchParams` typed instance would be returned instead.
|
|
42
|
+
*/
|
|
43
|
+
parseQuery?(input: URLSearchParams): any;
|
|
44
|
+
}
|
|
45
|
+
export namespace IFetchRoute {
|
|
46
|
+
/**
|
|
47
|
+
* Metadata of body.
|
|
48
|
+
*
|
|
49
|
+
* Describes how content-type being used in body, and whether encrypted or
|
|
50
|
+
* not.
|
|
51
|
+
*/
|
|
52
|
+
export interface IBody {
|
|
53
|
+
type:
|
|
54
|
+
| "application/json"
|
|
55
|
+
| "application/x-www-form-urlencoded"
|
|
56
|
+
| "multipart/form-data"
|
|
57
|
+
| "text/plain";
|
|
58
|
+
encrypted?: boolean;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/IPropagation.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Propagation type.
|
|
3
|
-
*
|
|
4
|
-
* `IPropagation` is a type gathering all possible status codes and their body
|
|
5
|
-
* data types as a discriminated union type. You can specify the status code and
|
|
6
|
-
* its body data type just by using conditional statement like below.
|
|
7
|
-
*
|
|
8
|
-
* ```typescript
|
|
9
|
-
* type Output = IPropagation<{
|
|
10
|
-
* 200: ISeller.IAuthorized;
|
|
11
|
-
* 400: TypeGuardError.IProps;
|
|
12
|
-
* >};
|
|
13
|
-
*
|
|
14
|
-
* const output: Output = await sdk.sellers.authenticate.join(input);
|
|
15
|
-
* if (output.success) {
|
|
16
|
-
* // automatically casted to "ISeller.IAuthorized" type
|
|
17
|
-
* const authorized: ISeller.IAuthorized = output.data;
|
|
18
|
-
* } else if (output.status === 400) {
|
|
19
|
-
* // automatically casted to "TypeGuardError.IProps" type
|
|
20
|
-
* const error: TypeGuardError.IProps = output.data;
|
|
21
|
-
* } else {
|
|
22
|
-
* // unknown type when out of pre-defined status codes
|
|
23
|
-
* const result: unknown = output.data;
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* For reference, this `IPropagation` type is utilized by SDK library generated
|
|
28
|
-
* by `@nestia/sdk`, when you've configured {@link INestiaConfig.propagate} to be
|
|
29
|
-
* `true`. In that case, SDK functions generated by `@nestia/sdk` no more
|
|
30
|
-
* returns response DTO typed data directly, but returns this `IPropagation`
|
|
31
|
-
* typed object instead.
|
|
32
|
-
*
|
|
33
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
-
* @template StatusMap Map of status code and its body data type.
|
|
35
|
-
* @template Success Default success status code.
|
|
36
|
-
*/
|
|
37
|
-
export type IPropagation<
|
|
38
|
-
StatusMap extends {
|
|
39
|
-
[P in IPropagation.Status]?: any;
|
|
40
|
-
},
|
|
41
|
-
Success extends number = 200 | 201,
|
|
42
|
-
> =
|
|
43
|
-
| {
|
|
44
|
-
[P in keyof StatusMap]: IPropagation.IBranch<
|
|
45
|
-
P extends Success ? true : false,
|
|
46
|
-
P,
|
|
47
|
-
StatusMap[P]
|
|
48
|
-
>;
|
|
49
|
-
}[keyof StatusMap]
|
|
50
|
-
| IPropagation.IBranch<false, unknown, unknown>;
|
|
51
|
-
export namespace IPropagation {
|
|
52
|
-
/**
|
|
53
|
-
* Type of configurable status codes.
|
|
54
|
-
*
|
|
55
|
-
* The special characters like `2XX`, `3XX`, `4XX`, `5XX` are meaning the
|
|
56
|
-
* range of status codes. If `5XX` is specified, it means the status code is
|
|
57
|
-
* in the range of `500` to `599`.
|
|
58
|
-
*/
|
|
59
|
-
export type Status = number | "2XX" | "3XX" | "4XX" | "5XX";
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Branch type of propagation.
|
|
63
|
-
*
|
|
64
|
-
* `IPropagation.IBranch` is a branch type composing `IPropagation` type,
|
|
65
|
-
* which is gathering all possible status codes and their body data types as a
|
|
66
|
-
* union type.
|
|
67
|
-
*/
|
|
68
|
-
export interface IBranch<Success extends boolean, StatusValue, BodyData> {
|
|
69
|
-
success: Success;
|
|
70
|
-
status: StatusValue extends "2XX" | "3XX" | "4XX" | "5XX"
|
|
71
|
-
? StatusRange<StatusValue>
|
|
72
|
-
: StatusValue extends number
|
|
73
|
-
? StatusValue
|
|
74
|
-
: never;
|
|
75
|
-
data: BodyData;
|
|
76
|
-
headers: Record<string, string | string[]>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Range of status codes by the first digit. */
|
|
80
|
-
export type StatusRange<T extends "2XX" | "3XX" | "4XX" | "5XX"> = T extends 0
|
|
81
|
-
? IntRange<200, 299>
|
|
82
|
-
: T extends 3
|
|
83
|
-
? IntRange<300, 399>
|
|
84
|
-
: T extends 4
|
|
85
|
-
? IntRange<400, 499>
|
|
86
|
-
: IntRange<500, 599>;
|
|
87
|
-
|
|
88
|
-
type IntRange<F extends number, T extends number> = Exclude<
|
|
89
|
-
Enumerate<T>,
|
|
90
|
-
Enumerate<F>
|
|
91
|
-
>;
|
|
92
|
-
|
|
93
|
-
type Enumerate<
|
|
94
|
-
N extends number,
|
|
95
|
-
Acc extends number[] = [],
|
|
96
|
-
> = Acc["length"] extends N
|
|
97
|
-
? Acc[number]
|
|
98
|
-
: Enumerate<N, [...Acc, Acc["length"]]>;
|
|
99
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Propagation type.
|
|
3
|
+
*
|
|
4
|
+
* `IPropagation` is a type gathering all possible status codes and their body
|
|
5
|
+
* data types as a discriminated union type. You can specify the status code and
|
|
6
|
+
* its body data type just by using conditional statement like below.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* type Output = IPropagation<{
|
|
10
|
+
* 200: ISeller.IAuthorized;
|
|
11
|
+
* 400: TypeGuardError.IProps;
|
|
12
|
+
* >};
|
|
13
|
+
*
|
|
14
|
+
* const output: Output = await sdk.sellers.authenticate.join(input);
|
|
15
|
+
* if (output.success) {
|
|
16
|
+
* // automatically casted to "ISeller.IAuthorized" type
|
|
17
|
+
* const authorized: ISeller.IAuthorized = output.data;
|
|
18
|
+
* } else if (output.status === 400) {
|
|
19
|
+
* // automatically casted to "TypeGuardError.IProps" type
|
|
20
|
+
* const error: TypeGuardError.IProps = output.data;
|
|
21
|
+
* } else {
|
|
22
|
+
* // unknown type when out of pre-defined status codes
|
|
23
|
+
* const result: unknown = output.data;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* For reference, this `IPropagation` type is utilized by SDK library generated
|
|
28
|
+
* by `@nestia/sdk`, when you've configured {@link INestiaConfig.propagate} to be
|
|
29
|
+
* `true`. In that case, SDK functions generated by `@nestia/sdk` no more
|
|
30
|
+
* returns response DTO typed data directly, but returns this `IPropagation`
|
|
31
|
+
* typed object instead.
|
|
32
|
+
*
|
|
33
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
34
|
+
* @template StatusMap Map of status code and its body data type.
|
|
35
|
+
* @template Success Default success status code.
|
|
36
|
+
*/
|
|
37
|
+
export type IPropagation<
|
|
38
|
+
StatusMap extends {
|
|
39
|
+
[P in IPropagation.Status]?: any;
|
|
40
|
+
},
|
|
41
|
+
Success extends number = 200 | 201,
|
|
42
|
+
> =
|
|
43
|
+
| {
|
|
44
|
+
[P in keyof StatusMap]: IPropagation.IBranch<
|
|
45
|
+
P extends Success ? true : false,
|
|
46
|
+
P,
|
|
47
|
+
StatusMap[P]
|
|
48
|
+
>;
|
|
49
|
+
}[keyof StatusMap]
|
|
50
|
+
| IPropagation.IBranch<false, unknown, unknown>;
|
|
51
|
+
export namespace IPropagation {
|
|
52
|
+
/**
|
|
53
|
+
* Type of configurable status codes.
|
|
54
|
+
*
|
|
55
|
+
* The special characters like `2XX`, `3XX`, `4XX`, `5XX` are meaning the
|
|
56
|
+
* range of status codes. If `5XX` is specified, it means the status code is
|
|
57
|
+
* in the range of `500` to `599`.
|
|
58
|
+
*/
|
|
59
|
+
export type Status = number | "2XX" | "3XX" | "4XX" | "5XX";
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Branch type of propagation.
|
|
63
|
+
*
|
|
64
|
+
* `IPropagation.IBranch` is a branch type composing `IPropagation` type,
|
|
65
|
+
* which is gathering all possible status codes and their body data types as a
|
|
66
|
+
* union type.
|
|
67
|
+
*/
|
|
68
|
+
export interface IBranch<Success extends boolean, StatusValue, BodyData> {
|
|
69
|
+
success: Success;
|
|
70
|
+
status: StatusValue extends "2XX" | "3XX" | "4XX" | "5XX"
|
|
71
|
+
? StatusRange<StatusValue>
|
|
72
|
+
: StatusValue extends number
|
|
73
|
+
? StatusValue
|
|
74
|
+
: never;
|
|
75
|
+
data: BodyData;
|
|
76
|
+
headers: Record<string, string | string[]>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Range of status codes by the first digit. */
|
|
80
|
+
export type StatusRange<T extends "2XX" | "3XX" | "4XX" | "5XX"> = T extends 0
|
|
81
|
+
? IntRange<200, 299>
|
|
82
|
+
: T extends 3
|
|
83
|
+
? IntRange<300, 399>
|
|
84
|
+
: T extends 4
|
|
85
|
+
? IntRange<400, 499>
|
|
86
|
+
: IntRange<500, 599>;
|
|
87
|
+
|
|
88
|
+
type IntRange<F extends number, T extends number> = Exclude<
|
|
89
|
+
Enumerate<T>,
|
|
90
|
+
Enumerate<F>
|
|
91
|
+
>;
|
|
92
|
+
|
|
93
|
+
type Enumerate<
|
|
94
|
+
N extends number,
|
|
95
|
+
Acc extends number[] = [],
|
|
96
|
+
> = Acc["length"] extends N
|
|
97
|
+
? Acc[number]
|
|
98
|
+
: Enumerate<N, [...Acc, Acc["length"]]>;
|
|
99
|
+
}
|