@nestia/fetcher 2.4.5 → 2.4.6

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/src/Resolved.ts CHANGED
@@ -26,82 +26,83 @@
26
26
  * @author Jeongho Nam - https://github.com/samchon
27
27
  * @author Kyungsu Kang - https://github.com/kakasoo
28
28
  */
29
- export type Resolved<T> = Equal<T, ResolvedMain<T>> extends true
30
- ? T
31
- : ResolvedMain<T>;
29
+ export type Resolved<T> =
30
+ Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
32
31
 
33
32
  type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
34
33
 
35
34
  type ResolvedMain<Instance> = Instance extends [never]
36
35
  ? never // (special trick for jsonable | null) type
37
36
  : ValueOf<Instance> extends boolean | number | bigint | string
38
- ? ValueOf<Instance>
39
- : Instance extends Function
40
- ? never
41
- : Instance extends object
42
- ? ResolvedObject<Instance>
43
- : ValueOf<Instance>;
37
+ ? ValueOf<Instance>
38
+ : Instance extends Function
39
+ ? never
40
+ : Instance extends object
41
+ ? ResolvedObject<Instance>
42
+ : ValueOf<Instance>;
44
43
 
45
- type ResolvedObject<Instance extends object> = Instance extends Array<infer T>
46
- ? IsTuple<Instance> extends true
47
- ? ResolvedTuple<Instance>
48
- : ResolvedMain<T>[]
49
- : Instance extends Set<infer U>
50
- ? Set<ResolvedMain<U>>
51
- : Instance extends Map<infer K, infer V>
52
- ? Map<ResolvedMain<K>, ResolvedMain<V>>
53
- : Instance extends WeakSet<any> | WeakMap<any, any>
54
- ? never
55
- : Instance 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
- ? Instance
72
- : {
73
- [P in keyof Instance]: ResolvedMain<Instance[P]>;
74
- };
44
+ type ResolvedObject<Instance extends object> =
45
+ Instance extends Array<infer T>
46
+ ? IsTuple<Instance> extends true
47
+ ? ResolvedTuple<Instance>
48
+ : ResolvedMain<T>[]
49
+ : Instance extends Set<infer U>
50
+ ? Set<ResolvedMain<U>>
51
+ : Instance extends Map<infer K, infer V>
52
+ ? Map<ResolvedMain<K>, ResolvedMain<V>>
53
+ : Instance extends WeakSet<any> | WeakMap<any, any>
54
+ ? never
55
+ : Instance 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
+ ? Instance
72
+ : {
73
+ [P in keyof Instance]: ResolvedMain<Instance[P]>;
74
+ };
75
75
 
76
76
  type ResolvedTuple<T extends readonly any[]> = T extends []
77
77
  ? []
78
78
  : T extends [infer F]
79
- ? [ResolvedMain<F>]
80
- : T extends [infer F, ...infer Rest extends readonly any[]]
81
- ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
82
- : T extends [(infer F)?]
83
- ? [ResolvedMain<F>?]
84
- : T extends [(infer F)?, ...infer Rest extends readonly any[]]
85
- ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
86
- : [];
79
+ ? [ResolvedMain<F>]
80
+ : T extends [infer F, ...infer Rest extends readonly any[]]
81
+ ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
82
+ : T extends [(infer F)?]
83
+ ? [ResolvedMain<F>?]
84
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
85
+ ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
86
+ : [];
87
87
 
88
- type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true
89
- ? boolean
90
- : IsValueOf<Instance, Number> extends true
91
- ? number
92
- : IsValueOf<Instance, String> extends true
93
- ? string
94
- : Instance;
88
+ type ValueOf<Instance> =
89
+ IsValueOf<Instance, Boolean> extends true
90
+ ? boolean
91
+ : IsValueOf<Instance, Number> extends true
92
+ ? number
93
+ : IsValueOf<Instance, String> extends true
94
+ ? string
95
+ : Instance;
95
96
 
96
97
  type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
97
98
  never,
98
99
  ]
99
100
  ? false
100
101
  : T extends readonly any[]
101
- ? number extends T["length"]
102
- ? false
103
- : true
104
- : false;
102
+ ? number extends T["length"]
103
+ ? false
104
+ : true
105
+ : false;
105
106
 
106
107
  type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
107
108
  ? Object extends IValueOf<infer Primitive>
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from "./IConnection";
2
- export * from "./IEncryptionPassword";
3
- export * from "./IPropagation";
4
- export * from "./IRandomGenerator";
5
- export * from "./HttpError";
6
- export * from "./Primitive";
7
- export * from "./Resolved";
1
+ export * from "./IConnection";
2
+ export * from "./IEncryptionPassword";
3
+ export * from "./IPropagation";
4
+ export * from "./IRandomGenerator";
5
+ export * from "./HttpError";
6
+ export * from "./Primitive";
7
+ export * from "./Resolved";
@@ -104,8 +104,8 @@ export namespace FetcherBase {
104
104
  route.request?.type === "application/x-www-form-urlencoded"
105
105
  ? request_query_body(input)
106
106
  : route.request?.type !== "text/plain"
107
- ? (stringify ?? JSON.stringify)(input)
108
- : input,
107
+ ? (stringify ?? JSON.stringify)(input)
108
+ : input,
109
109
  headers,
110
110
  );
111
111
 
@@ -1,61 +1,61 @@
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
- /**
10
- * Method of the HTTP request.
11
- */
12
- method: Method;
13
-
14
- /**
15
- * Path of the HTTP request.
16
- */
17
- path: string;
18
-
19
- /**
20
- * Request body data info.
21
- */
22
- request: Method extends "DELETE" | "POST" | "PUT" | "PATCH"
23
- ? IFetchRoute.IBody | null
24
- : null;
25
-
26
- /**
27
- * Response body data info.
28
- */
29
- response: Method extends "HEAD" ? null : IFetchRoute.IBody;
30
-
31
- /**
32
- * When special status code being used.
33
- */
34
- status: number | null;
35
-
36
- /**
37
- * Parser of the query string.
38
- *
39
- * If content type of response body is `application/x-www-form-urlencoded`,
40
- * then this `parseQuery` function would be called.
41
- *
42
- * If you've forgotten to configuring this `parseQuery` property about the
43
- * `application/x-www-form-urlencoded` typed response body data, then
44
- * only the `URLSearchParams` typed instance would be returned instead.
45
- */
46
- parseQuery?(input: URLSearchParams): any;
47
- }
48
- export namespace IFetchRoute {
49
- /**
50
- * Metadata of body.
51
- *
52
- * Describes how content-type being used in body, and whether encrypted or not.
53
- */
54
- export interface IBody {
55
- type:
56
- | "application/json"
57
- | "application/x-www-form-urlencoded"
58
- | "text/plain";
59
- encrypted?: boolean;
60
- }
61
- }
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
+ /**
10
+ * Method of the HTTP request.
11
+ */
12
+ method: Method;
13
+
14
+ /**
15
+ * Path of the HTTP request.
16
+ */
17
+ path: string;
18
+
19
+ /**
20
+ * Request body data info.
21
+ */
22
+ request: Method extends "DELETE" | "POST" | "PUT" | "PATCH"
23
+ ? IFetchRoute.IBody | null
24
+ : null;
25
+
26
+ /**
27
+ * Response body data info.
28
+ */
29
+ response: Method extends "HEAD" ? null : IFetchRoute.IBody;
30
+
31
+ /**
32
+ * When special status code being used.
33
+ */
34
+ status: number | null;
35
+
36
+ /**
37
+ * Parser of the query string.
38
+ *
39
+ * If content type of response body is `application/x-www-form-urlencoded`,
40
+ * then this `parseQuery` function would be called.
41
+ *
42
+ * If you've forgotten to configuring this `parseQuery` property about the
43
+ * `application/x-www-form-urlencoded` typed response body data, then
44
+ * only the `URLSearchParams` typed instance would be returned instead.
45
+ */
46
+ parseQuery?(input: URLSearchParams): any;
47
+ }
48
+ export namespace IFetchRoute {
49
+ /**
50
+ * Metadata of body.
51
+ *
52
+ * Describes how content-type being used in body, and whether encrypted or not.
53
+ */
54
+ export interface IBody {
55
+ type:
56
+ | "application/json"
57
+ | "application/x-www-form-urlencoded"
58
+ | "text/plain";
59
+ encrypted?: boolean;
60
+ }
61
+ }
@@ -1,20 +1,20 @@
1
- /**
2
- * @internal
3
- */
4
- export class Singleton<T> {
5
- private value_: T | object;
6
-
7
- public constructor(private readonly closure_: () => T) {
8
- this.value_ = NOT_MOUNTED_YET;
9
- }
10
-
11
- public get(): T {
12
- if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_();
13
- return this.value_ as T;
14
- }
15
- }
16
-
17
- /**
18
- * @internal
19
- */
20
- const NOT_MOUNTED_YET = {};
1
+ /**
2
+ * @internal
3
+ */
4
+ export class Singleton<T> {
5
+ private value_: T | object;
6
+
7
+ public constructor(private readonly closure_: () => T) {
8
+ this.value_ = NOT_MOUNTED_YET;
9
+ }
10
+
11
+ public get(): T {
12
+ if (this.value_ === NOT_MOUNTED_YET) this.value_ = this.closure_();
13
+ return this.value_ as T;
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @internal
19
+ */
20
+ const NOT_MOUNTED_YET = {};