typia 3.8.3 → 3.8.4

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.
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.$dictionary = void 0;
4
+ var blackhole = {};
4
5
  exports.$dictionary = (function () {
5
6
  var _a;
6
7
  var glob = typeof global === "object" &&
7
8
  typeof global.process === "object" &&
8
9
  typeof global.process.versions === "object" &&
9
10
  typeof global.process.versions.node !== "undefined"
10
- ? global
11
- : window;
11
+ ? (global !== null && global !== void 0 ? global : blackhole)
12
+ : (self !== null && self !== void 0 ? self : blackhole);
12
13
  return ((_a = glob.__typia_custom_validator) !== null && _a !== void 0 ? _a : (glob.__typia_custom_validator = new Map()));
13
14
  })();
14
15
  //# sourceMappingURL=$dictionary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"$dictionary.js","sourceRoot":"","sources":["../../src/functional/$dictionary.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG,CAAC;;IACxB,IAAM,IAAI,GASN,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAClC,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,WAAW;QAC/C,CAAC,CAAE,MAAc;QACjB,CAAC,CAAE,MAAc,CAAC;IAC1B,OAAO,OAAC,IAAI,CAAC,wBAAwB,oCAA7B,IAAI,CAAC,wBAAwB,GAAK,IAAI,GAAG,EAAE,EAAC,CAAC;AACzD,CAAC,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"$dictionary.js","sourceRoot":"","sources":["../../src/functional/$dictionary.ts"],"names":[],"mappings":";;;AAKA,IAAM,SAAS,GAAQ,EAAE,CAAC;AAEb,QAAA,WAAW,GAAG,CAAC;;IACxB,IAAM,IAAI,GASN,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;QAClC,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,WAAW;QAC/C,CAAC,CAAE,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAS;QAChC,CAAC,CAAE,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,SAAS,CAAS,CAAC;IACvC,OAAO,OAAC,IAAI,CAAC,wBAAwB,oCAA7B,IAAI,CAAC,wBAAwB,GAAK,IAAI,GAAG,EAAE,EAAC,CAAC;AACzD,CAAC,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "3.8.3",
3
+ "version": "3.8.4",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
package/src/Primitive.ts CHANGED
@@ -1,123 +1,123 @@
1
- /**
2
- * Primitive type.
3
- *
4
- * `Primitive` is a type of TMP (Type Meta Programming) type who converts its argument as a
5
- * primitive type.
6
- *
7
- * If the target argument is a built-in class who returns its origin primitive type through
8
- * the `valueOf()` method like the `String` or `Number`, its return type would be the
9
- * `string` or `number`.
10
- *
11
- * Otherwise, the target argument is a type of custom class, all of its custom method would
12
- * be erased and its prototype would be changed to the primitive `object`. Therefore, return
13
- * type of the TMP type finally be the primitive object.
14
- *
15
- * In addition, if the target argument is a type of custom class and it has a special
16
- * method `toJSON()`, return type of this `Primitive` would be not `Primitive<Instance>`
17
- * but `Primitive<ReturnType<Instance.toJSON>>`.
18
- *
19
- * Before | After
20
- * ------------------------|----------------------------------------
21
- * `Boolean` | `boolean`
22
- * `Number` | `number`
23
- * `String` | `string`
24
- * `Class` | `object`
25
- * `Class` with `toJSON()` | `Primitive<ReturnType<Class.toJSON>>`
26
- * Others | No change
27
- *
28
- * @template Instance Target argument type.
29
- * @author Jenogho Nam - https://github.com/samchon
30
- */
31
- export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
32
- ? T
33
- : PrimitiveMain<T>;
34
-
35
- type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
36
-
37
- type PrimitiveMain<Instance> = ValueOf<Instance> extends object
38
- ? Instance extends object
39
- ? Instance extends NativeClass
40
- ? {}
41
- : Instance extends IJsonable<infer Raw>
42
- ? ValueOf<Raw> extends object
43
- ? Raw extends object
44
- ? PrimitiveObject<Raw> // object would be primitified
45
- : never // cannot be
46
- : ValueOf<Raw> // atomic value
47
- : PrimitiveObject<Instance> // object would be primitified
48
- : never // cannot be
49
- : ValueOf<Instance>;
50
-
51
- type PrimitiveObject<Instance extends object> = Instance extends Array<infer T>
52
- ? IsTuple<Instance> extends true
53
- ? PrimitiveTuple<Instance>
54
- : PrimitiveMain<T>[]
55
- : {
56
- [P in keyof Instance]: Instance[P] extends Function
57
- ? never
58
- : PrimitiveMain<Instance[P]>;
59
- };
60
-
61
- type PrimitiveTuple<T extends readonly any[]> = T extends [infer F]
62
- ? [PrimitiveMain<F>]
63
- : T extends [infer F, ...infer Rest extends readonly any[]]
64
- ? [PrimitiveMain<F>, ...PrimitiveTuple<Rest>]
65
- : T extends [(infer F)?]
66
- ? [PrimitiveMain<F>?]
67
- : T extends [(infer F)?, ...infer Rest extends readonly any[]]
68
- ? [PrimitiveMain<F>?, ...PrimitiveTuple<Rest>]
69
- : [];
70
-
71
- type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true
72
- ? boolean
73
- : IsValueOf<Instance, Number> extends true
74
- ? number
75
- : IsValueOf<Instance, String> extends true
76
- ? string
77
- : Instance;
78
-
79
- type NativeClass =
80
- | Set<any>
81
- | Map<any, any>
82
- | WeakSet<any>
83
- | WeakMap<any, any>
84
- | Uint8Array
85
- | Uint8ClampedArray
86
- | Uint16Array
87
- | Uint32Array
88
- | BigUint64Array
89
- | Int8Array
90
- | Int16Array
91
- | Int32Array
92
- | BigInt64Array
93
- | Float32Array
94
- | Float64Array
95
- | ArrayBuffer
96
- | SharedArrayBuffer
97
- | DataView;
98
-
99
- type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
100
- never,
101
- ]
102
- ? false
103
- : T extends readonly any[]
104
- ? number extends T["length"]
105
- ? false
106
- : true
107
- : false;
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
- }
120
-
121
- interface IJsonable<T> {
122
- toJSON(): T;
123
- }
1
+ /**
2
+ * Primitive type.
3
+ *
4
+ * `Primitive` is a type of TMP (Type Meta Programming) type who converts its argument as a
5
+ * primitive type.
6
+ *
7
+ * If the target argument is a built-in class who returns its origin primitive type through
8
+ * the `valueOf()` method like the `String` or `Number`, its return type would be the
9
+ * `string` or `number`.
10
+ *
11
+ * Otherwise, the target argument is a type of custom class, all of its custom method would
12
+ * be erased and its prototype would be changed to the primitive `object`. Therefore, return
13
+ * type of the TMP type finally be the primitive object.
14
+ *
15
+ * In addition, if the target argument is a type of custom class and it has a special
16
+ * method `toJSON()`, return type of this `Primitive` would be not `Primitive<Instance>`
17
+ * but `Primitive<ReturnType<Instance.toJSON>>`.
18
+ *
19
+ * Before | After
20
+ * ------------------------|----------------------------------------
21
+ * `Boolean` | `boolean`
22
+ * `Number` | `number`
23
+ * `String` | `string`
24
+ * `Class` | `object`
25
+ * `Class` with `toJSON()` | `Primitive<ReturnType<Class.toJSON>>`
26
+ * Others | No change
27
+ *
28
+ * @template Instance Target argument type.
29
+ * @author Jenogho Nam - https://github.com/samchon
30
+ */
31
+ export type Primitive<T> = Equal<T, PrimitiveMain<T>> extends true
32
+ ? T
33
+ : PrimitiveMain<T>;
34
+
35
+ type Equal<X, Y> = X extends Y ? (Y extends X ? true : false) : false;
36
+
37
+ type PrimitiveMain<Instance> = ValueOf<Instance> extends object
38
+ ? Instance extends object
39
+ ? Instance extends NativeClass
40
+ ? {}
41
+ : Instance extends IJsonable<infer Raw>
42
+ ? ValueOf<Raw> extends object
43
+ ? Raw extends object
44
+ ? PrimitiveObject<Raw> // object would be primitified
45
+ : never // cannot be
46
+ : ValueOf<Raw> // atomic value
47
+ : PrimitiveObject<Instance> // object would be primitified
48
+ : never // cannot be
49
+ : ValueOf<Instance>;
50
+
51
+ type PrimitiveObject<Instance extends object> = Instance extends Array<infer T>
52
+ ? IsTuple<Instance> extends true
53
+ ? PrimitiveTuple<Instance>
54
+ : PrimitiveMain<T>[]
55
+ : {
56
+ [P in keyof Instance]: Instance[P] extends Function
57
+ ? never
58
+ : PrimitiveMain<Instance[P]>;
59
+ };
60
+
61
+ type PrimitiveTuple<T extends readonly any[]> = T extends [infer F]
62
+ ? [PrimitiveMain<F>]
63
+ : T extends [infer F, ...infer Rest extends readonly any[]]
64
+ ? [PrimitiveMain<F>, ...PrimitiveTuple<Rest>]
65
+ : T extends [(infer F)?]
66
+ ? [PrimitiveMain<F>?]
67
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
68
+ ? [PrimitiveMain<F>?, ...PrimitiveTuple<Rest>]
69
+ : [];
70
+
71
+ type ValueOf<Instance> = IsValueOf<Instance, Boolean> extends true
72
+ ? boolean
73
+ : IsValueOf<Instance, Number> extends true
74
+ ? number
75
+ : IsValueOf<Instance, String> extends true
76
+ ? string
77
+ : Instance;
78
+
79
+ type NativeClass =
80
+ | Set<any>
81
+ | Map<any, any>
82
+ | WeakSet<any>
83
+ | WeakMap<any, any>
84
+ | Uint8Array
85
+ | Uint8ClampedArray
86
+ | Uint16Array
87
+ | Uint32Array
88
+ | BigUint64Array
89
+ | Int8Array
90
+ | Int16Array
91
+ | Int32Array
92
+ | BigInt64Array
93
+ | Float32Array
94
+ | Float64Array
95
+ | ArrayBuffer
96
+ | SharedArrayBuffer
97
+ | DataView;
98
+
99
+ type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
100
+ never,
101
+ ]
102
+ ? false
103
+ : T extends readonly any[]
104
+ ? number extends T["length"]
105
+ ? false
106
+ : true
107
+ : false;
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
+ }
120
+
121
+ interface IJsonable<T> {
122
+ toJSON(): T;
123
+ }
@@ -1,62 +1,62 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../metadata/Metadata";
4
- import { explore_metadata } from "./internal/metadata/explore_metadata";
5
-
6
- import { MetadataCollection } from "./MetadataCollection";
7
-
8
- export namespace MetadataFactory {
9
- export interface IOptions {
10
- resolve: boolean;
11
- constant: boolean;
12
- validate?: (meta: Metadata) => void;
13
- }
14
-
15
- export const analyze =
16
- (checker: ts.TypeChecker) =>
17
- (options: IOptions) =>
18
- (collection: MetadataCollection) =>
19
- (type: ts.Type | null): Metadata => {
20
- // CONSTRUCT SCHEMA WITH OBJECTS
21
- const metadata: Metadata = explore_metadata(checker)(options)(
22
- collection,
23
- )(type, false);
24
-
25
- // FIND RECURSIVE OBJECTS
26
- for (const object of collection.objects())
27
- object.recursive = object.properties.some((prop) =>
28
- isRecursive(object.name)(prop.value),
29
- );
30
-
31
- // RETURNS
32
- return metadata;
33
- };
34
-
35
- const isRecursive =
36
- (name: string) =>
37
- (meta: Metadata): boolean => {
38
- const similar = (str: string) =>
39
- name === str ||
40
- name.indexOf(`<${str},`) !== -1 ||
41
- name.indexOf(`, ${str}>`) !== -1 ||
42
- name.indexOf(`, ${str},`) !== -1;
43
- return (
44
- meta.objects.some((obj) => similar(obj.name)) ||
45
- meta.arrays.some((arr) => isRecursive(name)(arr)) ||
46
- meta.tuples.some((tuple) =>
47
- tuple.some((m) => isRecursive(name)(m.rest ?? m)),
48
- ) ||
49
- meta.maps.some((map) => isRecursive(name)(map.value))
50
- );
51
- };
52
-
53
- /**
54
- * @deprecated Use `analyze` function instead
55
- */
56
- export const generate = (
57
- checker: ts.TypeChecker,
58
- collection: MetadataCollection,
59
- type: ts.Type,
60
- options: IOptions,
61
- ) => analyze(checker)(options)(collection)(type);
62
- }
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../metadata/Metadata";
4
+ import { explore_metadata } from "./internal/metadata/explore_metadata";
5
+
6
+ import { MetadataCollection } from "./MetadataCollection";
7
+
8
+ export namespace MetadataFactory {
9
+ export interface IOptions {
10
+ resolve: boolean;
11
+ constant: boolean;
12
+ validate?: (meta: Metadata) => void;
13
+ }
14
+
15
+ export const analyze =
16
+ (checker: ts.TypeChecker) =>
17
+ (options: IOptions) =>
18
+ (collection: MetadataCollection) =>
19
+ (type: ts.Type | null): Metadata => {
20
+ // CONSTRUCT SCHEMA WITH OBJECTS
21
+ const metadata: Metadata = explore_metadata(checker)(options)(
22
+ collection,
23
+ )(type, false);
24
+
25
+ // FIND RECURSIVE OBJECTS
26
+ for (const object of collection.objects())
27
+ object.recursive = object.properties.some((prop) =>
28
+ isRecursive(object.name)(prop.value),
29
+ );
30
+
31
+ // RETURNS
32
+ return metadata;
33
+ };
34
+
35
+ const isRecursive =
36
+ (name: string) =>
37
+ (meta: Metadata): boolean => {
38
+ const similar = (str: string) =>
39
+ name === str ||
40
+ name.indexOf(`<${str},`) !== -1 ||
41
+ name.indexOf(`, ${str}>`) !== -1 ||
42
+ name.indexOf(`, ${str},`) !== -1;
43
+ return (
44
+ meta.objects.some((obj) => similar(obj.name)) ||
45
+ meta.arrays.some((arr) => isRecursive(name)(arr)) ||
46
+ meta.tuples.some((tuple) =>
47
+ tuple.some((m) => isRecursive(name)(m.rest ?? m)),
48
+ ) ||
49
+ meta.maps.some((map) => isRecursive(name)(map.value))
50
+ );
51
+ };
52
+
53
+ /**
54
+ * @deprecated Use `analyze` function instead
55
+ */
56
+ export const generate = (
57
+ checker: ts.TypeChecker,
58
+ collection: MetadataCollection,
59
+ type: ts.Type,
60
+ options: IOptions,
61
+ ) => analyze(checker)(options)(collection)(type);
62
+ }