@nestia/fetcher 2.6.2 → 2.6.3
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/package.json +1 -1
- package/src/EncryptedFetcher.ts +174 -174
- package/src/IConnection.ts +247 -247
- package/src/IFetchEvent.ts +31 -31
- package/src/IFetchRoute.ts +62 -62
- package/src/IPropagation.ts +102 -102
- package/src/NestiaSimulator.ts +82 -82
- package/src/PlainFetcher.ts +105 -105
- package/src/Primitive.ts +136 -136
- package/src/Resolved.ts +119 -119
- package/src/index.ts +9 -9
- package/src/internal/FetcherBase.ts +269 -269
package/src/Resolved.ts
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolved type erased every methods.
|
|
3
|
-
*
|
|
4
|
-
* `Resolved` is a type of TMP (Type Meta Programming) type which converts
|
|
5
|
-
* its argument as a resolved type that erased every method properties.
|
|
6
|
-
*
|
|
7
|
-
* If the target argument is a built-in class which returns its origin primitive type
|
|
8
|
-
* through the `valueOf()` method like the `String` or `Number`, its return type would
|
|
9
|
-
* be the `string` or `number`. Otherwise, the built-in class does not have the
|
|
10
|
-
* `valueOf()` method, the return type would be same with the target argument.
|
|
11
|
-
*
|
|
12
|
-
* Otherwise, the target argument is a type of custom class, all of its custom methods
|
|
13
|
-
* would be erased and its prototype would be changed to the primitive `object`.
|
|
14
|
-
* Therefore, return type of the TMP type finally be the resolved object.
|
|
15
|
-
*
|
|
16
|
-
* Before | After
|
|
17
|
-
* ------------------------|----------------------------------------
|
|
18
|
-
* `Boolean` | `boolean`
|
|
19
|
-
* `Number` | `number`
|
|
20
|
-
* `BigInt` | `bigint`
|
|
21
|
-
* `String` | `string`
|
|
22
|
-
* `Class` | `interface`
|
|
23
|
-
* Native Class or Others | No change
|
|
24
|
-
*
|
|
25
|
-
* @template T Target argument type.
|
|
26
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
27
|
-
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
28
|
-
*/
|
|
29
|
-
export type Resolved<T> =
|
|
30
|
-
Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
|
|
31
|
-
|
|
32
|
-
type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
|
|
33
|
-
|
|
34
|
-
type ResolvedMain<T> = T extends [never]
|
|
35
|
-
? never // (special trick for jsonable | null) type
|
|
36
|
-
: ValueOf<T> extends boolean | number | bigint | string
|
|
37
|
-
? ValueOf<T>
|
|
38
|
-
: T extends Function
|
|
39
|
-
? never
|
|
40
|
-
: T extends object
|
|
41
|
-
? ResolvedObject<T>
|
|
42
|
-
: ValueOf<T>;
|
|
43
|
-
|
|
44
|
-
type ResolvedObject<T extends object> =
|
|
45
|
-
T extends Array<infer U>
|
|
46
|
-
? IsTuple<T> extends true
|
|
47
|
-
? ResolvedTuple<T>
|
|
48
|
-
: ResolvedMain<U>[]
|
|
49
|
-
: T extends Set<infer U>
|
|
50
|
-
? Set<ResolvedMain<U>>
|
|
51
|
-
: T extends Map<infer K, infer V>
|
|
52
|
-
? Map<ResolvedMain<K>, ResolvedMain<V>>
|
|
53
|
-
: T extends WeakSet<any> | WeakMap<any, any>
|
|
54
|
-
? never
|
|
55
|
-
: T extends
|
|
56
|
-
| Date
|
|
57
|
-
| Uint8Array
|
|
58
|
-
| Uint8ClampedArray
|
|
59
|
-
| Uint16Array
|
|
60
|
-
| Uint32Array
|
|
61
|
-
| BigUint64Array
|
|
62
|
-
| Int8Array
|
|
63
|
-
| Int16Array
|
|
64
|
-
| Int32Array
|
|
65
|
-
| BigInt64Array
|
|
66
|
-
| Float32Array
|
|
67
|
-
| Float64Array
|
|
68
|
-
| ArrayBuffer
|
|
69
|
-
| SharedArrayBuffer
|
|
70
|
-
| DataView
|
|
71
|
-
| Blob
|
|
72
|
-
| File
|
|
73
|
-
? T
|
|
74
|
-
: {
|
|
75
|
-
[P in keyof T]: ResolvedMain<T[P]>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
type ResolvedTuple<T extends readonly any[]> = T extends []
|
|
79
|
-
? []
|
|
80
|
-
: T extends [infer F]
|
|
81
|
-
? [ResolvedMain<F>]
|
|
82
|
-
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
83
|
-
? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
|
|
84
|
-
: T extends [(infer F)?]
|
|
85
|
-
? [ResolvedMain<F>?]
|
|
86
|
-
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
87
|
-
? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
|
|
88
|
-
: [];
|
|
89
|
-
|
|
90
|
-
type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
|
|
91
|
-
never,
|
|
92
|
-
]
|
|
93
|
-
? false
|
|
94
|
-
: T extends readonly any[]
|
|
95
|
-
? number extends T["length"]
|
|
96
|
-
? false
|
|
97
|
-
: true
|
|
98
|
-
: false;
|
|
99
|
-
|
|
100
|
-
type ValueOf<Instance> =
|
|
101
|
-
IsValueOf<Instance, Boolean> extends true
|
|
102
|
-
? boolean
|
|
103
|
-
: IsValueOf<Instance, Number> extends true
|
|
104
|
-
? number
|
|
105
|
-
: IsValueOf<Instance, String> extends true
|
|
106
|
-
? string
|
|
107
|
-
: Instance;
|
|
108
|
-
|
|
109
|
-
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
110
|
-
? Object extends IValueOf<infer Primitive>
|
|
111
|
-
? Instance extends Primitive
|
|
112
|
-
? false
|
|
113
|
-
: true // not Primitive, but Object
|
|
114
|
-
: false // cannot be
|
|
115
|
-
: false;
|
|
116
|
-
|
|
117
|
-
interface IValueOf<T> {
|
|
118
|
-
valueOf(): T;
|
|
119
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Resolved type erased every methods.
|
|
3
|
+
*
|
|
4
|
+
* `Resolved` is a type of TMP (Type Meta Programming) type which converts
|
|
5
|
+
* its argument as a resolved type that erased every method properties.
|
|
6
|
+
*
|
|
7
|
+
* If the target argument is a built-in class which returns its origin primitive type
|
|
8
|
+
* through the `valueOf()` method like the `String` or `Number`, its return type would
|
|
9
|
+
* be the `string` or `number`. Otherwise, the built-in class does not have the
|
|
10
|
+
* `valueOf()` method, the return type would be same with the target argument.
|
|
11
|
+
*
|
|
12
|
+
* Otherwise, the target argument is a type of custom class, all of its custom methods
|
|
13
|
+
* would be erased and its prototype would be changed to the primitive `object`.
|
|
14
|
+
* Therefore, return type of the TMP type finally be the resolved object.
|
|
15
|
+
*
|
|
16
|
+
* Before | After
|
|
17
|
+
* ------------------------|----------------------------------------
|
|
18
|
+
* `Boolean` | `boolean`
|
|
19
|
+
* `Number` | `number`
|
|
20
|
+
* `BigInt` | `bigint`
|
|
21
|
+
* `String` | `string`
|
|
22
|
+
* `Class` | `interface`
|
|
23
|
+
* Native Class or Others | No change
|
|
24
|
+
*
|
|
25
|
+
* @template T Target argument type.
|
|
26
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
27
|
+
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
28
|
+
*/
|
|
29
|
+
export type Resolved<T> =
|
|
30
|
+
Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
|
|
31
|
+
|
|
32
|
+
type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
|
|
33
|
+
|
|
34
|
+
type ResolvedMain<T> = T extends [never]
|
|
35
|
+
? never // (special trick for jsonable | null) type
|
|
36
|
+
: ValueOf<T> extends boolean | number | bigint | string
|
|
37
|
+
? ValueOf<T>
|
|
38
|
+
: T extends Function
|
|
39
|
+
? never
|
|
40
|
+
: T extends object
|
|
41
|
+
? ResolvedObject<T>
|
|
42
|
+
: ValueOf<T>;
|
|
43
|
+
|
|
44
|
+
type ResolvedObject<T extends object> =
|
|
45
|
+
T extends Array<infer U>
|
|
46
|
+
? IsTuple<T> extends true
|
|
47
|
+
? ResolvedTuple<T>
|
|
48
|
+
: ResolvedMain<U>[]
|
|
49
|
+
: T extends Set<infer U>
|
|
50
|
+
? Set<ResolvedMain<U>>
|
|
51
|
+
: T extends Map<infer K, infer V>
|
|
52
|
+
? Map<ResolvedMain<K>, ResolvedMain<V>>
|
|
53
|
+
: T extends WeakSet<any> | WeakMap<any, any>
|
|
54
|
+
? never
|
|
55
|
+
: T extends
|
|
56
|
+
| Date
|
|
57
|
+
| Uint8Array
|
|
58
|
+
| Uint8ClampedArray
|
|
59
|
+
| Uint16Array
|
|
60
|
+
| Uint32Array
|
|
61
|
+
| BigUint64Array
|
|
62
|
+
| Int8Array
|
|
63
|
+
| Int16Array
|
|
64
|
+
| Int32Array
|
|
65
|
+
| BigInt64Array
|
|
66
|
+
| Float32Array
|
|
67
|
+
| Float64Array
|
|
68
|
+
| ArrayBuffer
|
|
69
|
+
| SharedArrayBuffer
|
|
70
|
+
| DataView
|
|
71
|
+
| Blob
|
|
72
|
+
| File
|
|
73
|
+
? T
|
|
74
|
+
: {
|
|
75
|
+
[P in keyof T]: ResolvedMain<T[P]>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type ResolvedTuple<T extends readonly any[]> = T extends []
|
|
79
|
+
? []
|
|
80
|
+
: T extends [infer F]
|
|
81
|
+
? [ResolvedMain<F>]
|
|
82
|
+
: T extends [infer F, ...infer Rest extends readonly any[]]
|
|
83
|
+
? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
|
|
84
|
+
: T extends [(infer F)?]
|
|
85
|
+
? [ResolvedMain<F>?]
|
|
86
|
+
: T extends [(infer F)?, ...infer Rest extends readonly any[]]
|
|
87
|
+
? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
|
|
88
|
+
: [];
|
|
89
|
+
|
|
90
|
+
type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
|
|
91
|
+
never,
|
|
92
|
+
]
|
|
93
|
+
? false
|
|
94
|
+
: T extends readonly any[]
|
|
95
|
+
? number extends T["length"]
|
|
96
|
+
? false
|
|
97
|
+
: true
|
|
98
|
+
: false;
|
|
99
|
+
|
|
100
|
+
type ValueOf<Instance> =
|
|
101
|
+
IsValueOf<Instance, Boolean> extends true
|
|
102
|
+
? boolean
|
|
103
|
+
: IsValueOf<Instance, Number> extends true
|
|
104
|
+
? number
|
|
105
|
+
: IsValueOf<Instance, String> extends true
|
|
106
|
+
? string
|
|
107
|
+
: Instance;
|
|
108
|
+
|
|
109
|
+
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
110
|
+
? Object extends IValueOf<infer Primitive>
|
|
111
|
+
? Instance extends Primitive
|
|
112
|
+
? false
|
|
113
|
+
: true // not Primitive, but Object
|
|
114
|
+
: false // cannot be
|
|
115
|
+
: false;
|
|
116
|
+
|
|
117
|
+
interface IValueOf<T> {
|
|
118
|
+
valueOf(): T;
|
|
119
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./HttpError";
|
|
2
|
-
export * from "./IConnection";
|
|
3
|
-
export * from "./IEncryptionPassword";
|
|
4
|
-
export * from "./IFetchEvent";
|
|
5
|
-
export * from "./IFetchRoute";
|
|
6
|
-
export * from "./IPropagation";
|
|
7
|
-
export * from "./IRandomGenerator";
|
|
8
|
-
export * from "./Primitive";
|
|
9
|
-
export * from "./Resolved";
|
|
1
|
+
export * from "./HttpError";
|
|
2
|
+
export * from "./IConnection";
|
|
3
|
+
export * from "./IEncryptionPassword";
|
|
4
|
+
export * from "./IFetchEvent";
|
|
5
|
+
export * from "./IFetchRoute";
|
|
6
|
+
export * from "./IPropagation";
|
|
7
|
+
export * from "./IRandomGenerator";
|
|
8
|
+
export * from "./Primitive";
|
|
9
|
+
export * from "./Resolved";
|