typia 7.0.0-dev.20240923 → 7.0.0-dev.20240924
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/lib/programmers/FeatureProgrammer.d.ts +2 -2
- package/lib/programmers/FeatureProgrammer.js +2 -2
- package/lib/programmers/json/JsonStringifyProgrammer.js +3 -3
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +456 -405
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js +3 -3
- package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +336 -300
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/package.json +1 -1
- package/src/programmers/FeatureProgrammer.ts +3 -3
- package/src/programmers/json/JsonStringifyProgrammer.ts +4 -3
- package/src/programmers/misc/MiscCloneProgrammer.ts +737 -600
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -4
- package/src/programmers/misc/MiscPruneProgrammer.ts +508 -412
|
@@ -47,7 +47,7 @@ var wrap_metadata_rest_tuple_1 = require("../internal/wrap_metadata_rest_tuple")
|
|
|
47
47
|
var MiscCloneProgrammer;
|
|
48
48
|
(function (MiscCloneProgrammer) {
|
|
49
49
|
MiscCloneProgrammer.decompose = function (props) {
|
|
50
|
-
var config = configure(props
|
|
50
|
+
var config = configure(props);
|
|
51
51
|
if (props.validated === false)
|
|
52
52
|
config.addition = function (collection) {
|
|
53
53
|
return IsProgrammer_1.IsProgrammer.write_function_statements(props.context)(props.importer)(collection);
|
|
@@ -68,445 +68,500 @@ var MiscCloneProgrammer;
|
|
|
68
68
|
result: result,
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
|
-
var write_array_functions = function (
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
71
|
+
var write_array_functions = function (props) {
|
|
72
|
+
return props.collection
|
|
73
|
+
.arrays()
|
|
74
|
+
.filter(function (a) { return a.recursive; })
|
|
75
|
+
.map(function (type, i) {
|
|
76
|
+
return StatementFactory_1.StatementFactory.constant("".concat(props.config.prefix, "a").concat(i), typescript_1.default.factory.createArrowFunction(undefined, undefined, FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")), TypeFactory_1.TypeFactory.keyword("any"), undefined, decode_array_inline({
|
|
77
|
+
config: props.config,
|
|
78
|
+
importer: props.importer,
|
|
79
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
80
|
+
array: MetadataArray_1.MetadataArray.create({
|
|
81
|
+
type: type,
|
|
82
|
+
tags: [],
|
|
83
|
+
}),
|
|
84
|
+
explore: {
|
|
85
|
+
tracable: props.config.trace,
|
|
86
|
+
source: "function",
|
|
87
|
+
from: "array",
|
|
88
|
+
postfix: "",
|
|
89
|
+
},
|
|
90
|
+
})));
|
|
91
|
+
});
|
|
90
92
|
};
|
|
91
|
-
var write_tuple_functions = function (
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
93
|
+
var write_tuple_functions = function (props) {
|
|
94
|
+
return props.collection
|
|
95
|
+
.tuples()
|
|
96
|
+
.filter(function (t) { return t.recursive; })
|
|
97
|
+
.map(function (tuple, i) {
|
|
98
|
+
return StatementFactory_1.StatementFactory.constant("".concat(props.config.prefix, "t").concat(i), typescript_1.default.factory.createArrowFunction(undefined, undefined, FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")), TypeFactory_1.TypeFactory.keyword("any"), undefined, decode_tuple_inline({
|
|
99
|
+
config: props.config,
|
|
100
|
+
context: props.context,
|
|
101
|
+
importer: props.importer,
|
|
102
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
103
|
+
tuple: tuple,
|
|
104
|
+
explore: {
|
|
105
|
+
tracable: props.config.trace,
|
|
106
|
+
source: "function",
|
|
107
|
+
from: "array",
|
|
108
|
+
postfix: "",
|
|
109
|
+
},
|
|
110
|
+
})));
|
|
111
|
+
});
|
|
109
112
|
};
|
|
110
113
|
/* -----------------------------------------------------------
|
|
111
114
|
DECODERS
|
|
112
115
|
----------------------------------------------------------- */
|
|
113
|
-
var decode = function (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(native)(input); },
|
|
199
|
-
value: function () {
|
|
200
|
-
return native === "Boolean" || native === "Number" || native === "String"
|
|
201
|
-
? typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(input)("valueOf"), undefined, undefined)
|
|
202
|
-
: decode_native(native)(input);
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
try {
|
|
207
|
-
for (var _f = __values(meta.natives), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
208
|
-
var native = _g.value;
|
|
209
|
-
_loop_2(native);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
213
|
-
finally {
|
|
214
|
-
try {
|
|
215
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
216
|
-
}
|
|
217
|
-
finally { if (e_2) throw e_2.error; }
|
|
218
|
-
}
|
|
219
|
-
// OBJECTS
|
|
220
|
-
if (meta.objects.length)
|
|
221
|
-
unions.push({
|
|
222
|
-
type: "object",
|
|
223
|
-
is: function () {
|
|
224
|
-
return ExpressionFactory_1.ExpressionFactory.isObject({
|
|
225
|
-
checkNull: true,
|
|
226
|
-
checkArray: false,
|
|
227
|
-
})(input);
|
|
228
|
-
},
|
|
229
|
-
value: function () {
|
|
230
|
-
return explore_objects(config)(importer)(input, meta, __assign(__assign({}, explore), { from: "object" }));
|
|
231
|
-
},
|
|
116
|
+
var decode = function (props) {
|
|
117
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
118
|
+
// ANY TYPE
|
|
119
|
+
if (props.metadata.any ||
|
|
120
|
+
props.metadata.arrays.some(function (a) { return a.type.value.any; }) ||
|
|
121
|
+
props.metadata.tuples.some(function (t) { return !!t.type.elements.length && t.type.elements.every(function (e) { return e.any; }); }))
|
|
122
|
+
return typescript_1.default.factory.createCallExpression(props.importer.use("any"), undefined, [props.input]);
|
|
123
|
+
var unions = [];
|
|
124
|
+
//----
|
|
125
|
+
// LIST UP UNION TYPES
|
|
126
|
+
//----
|
|
127
|
+
// FUNCTIONAL
|
|
128
|
+
if (props.metadata.functions.length)
|
|
129
|
+
unions.push({
|
|
130
|
+
type: "functional",
|
|
131
|
+
is: function () {
|
|
132
|
+
return typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createStringLiteral("function"), typescript_1.default.factory.createTypeOfExpression(props.input));
|
|
133
|
+
},
|
|
134
|
+
value: function () { return typescript_1.default.factory.createIdentifier("undefined"); },
|
|
135
|
+
});
|
|
136
|
+
var _loop_1 = function (tuple) {
|
|
137
|
+
unions.push({
|
|
138
|
+
type: "tuple",
|
|
139
|
+
is: function () {
|
|
140
|
+
return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer)(props.input, (function () {
|
|
141
|
+
var partial = Metadata_1.Metadata.initialize();
|
|
142
|
+
partial.tuples.push(tuple);
|
|
143
|
+
return partial;
|
|
144
|
+
})(), props.explore);
|
|
145
|
+
},
|
|
146
|
+
value: function () {
|
|
147
|
+
return decode_tuple(__assign(__assign({}, props), { tuple: tuple }));
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
// TUPLES
|
|
153
|
+
for (var _d = __values(props.metadata.tuples), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
154
|
+
var tuple = _e.value;
|
|
155
|
+
_loop_1(tuple);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
159
|
+
finally {
|
|
160
|
+
try {
|
|
161
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
162
|
+
}
|
|
163
|
+
finally { if (e_1) throw e_1.error; }
|
|
164
|
+
}
|
|
165
|
+
// ARRAYS
|
|
166
|
+
if (props.metadata.arrays.length)
|
|
167
|
+
unions.push({
|
|
168
|
+
type: "array",
|
|
169
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isArray(props.input); },
|
|
170
|
+
value: function () {
|
|
171
|
+
return explore_arrays(__assign(__assign({}, props), { arrays: props.metadata.arrays, explore: __assign(__assign({}, props.explore), { from: "array" }) }));
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
// NATIVE TYPES
|
|
175
|
+
if (props.metadata.sets.length)
|
|
176
|
+
unions.push({
|
|
177
|
+
type: "set",
|
|
178
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Set")(props.input); },
|
|
179
|
+
value: function () {
|
|
180
|
+
return explore_sets(__assign(__assign({}, props), { sets: props.metadata.sets, explore: __assign(__assign({}, props.explore), { from: "array" }) }));
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
if (props.metadata.maps.length)
|
|
184
|
+
unions.push({
|
|
185
|
+
type: "map",
|
|
186
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf("Map")(props.input); },
|
|
187
|
+
value: function () {
|
|
188
|
+
return explore_maps(__assign(__assign({}, props), { maps: props.metadata.maps, explore: __assign(__assign({}, props.explore), { from: "array" }) }));
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
var _loop_2 = function (native) {
|
|
192
|
+
unions.push({
|
|
193
|
+
type: "native",
|
|
194
|
+
is: function () { return ExpressionFactory_1.ExpressionFactory.isInstanceOf(native)(props.input); },
|
|
195
|
+
value: function () {
|
|
196
|
+
return native === "Boolean" || native === "Number" || native === "String"
|
|
197
|
+
? typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("valueOf"), undefined, undefined)
|
|
198
|
+
: decode_native({
|
|
199
|
+
type: native,
|
|
200
|
+
input: props.input,
|
|
232
201
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return input;
|
|
236
|
-
else if (unions.length === 1 && meta.size() === 1) {
|
|
237
|
-
var value = (meta.nullable || meta.isRequired() === false) && is_instance(meta)
|
|
238
|
-
? typescript_1.default.factory.createConditionalExpression(input, undefined, unions[0].value(), undefined, input)
|
|
239
|
-
: unions[0].value();
|
|
240
|
-
return typescript_1.default.factory.createAsExpression(value, TypeFactory_1.TypeFactory.keyword("any"));
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
var last = input;
|
|
244
|
-
try {
|
|
245
|
-
for (var _h = __values(unions.reverse()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
246
|
-
var u = _j.value;
|
|
247
|
-
last = typescript_1.default.factory.createConditionalExpression(u.is(), undefined, u.value(), undefined, last);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
251
|
-
finally {
|
|
252
|
-
try {
|
|
253
|
-
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
254
|
-
}
|
|
255
|
-
finally { if (e_3) throw e_3.error; }
|
|
256
|
-
}
|
|
257
|
-
return typescript_1.default.factory.createAsExpression(last, TypeFactory_1.TypeFactory.keyword("any"));
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
};
|
|
202
|
+
},
|
|
203
|
+
});
|
|
261
204
|
};
|
|
205
|
+
try {
|
|
206
|
+
for (var _f = __values(props.metadata.natives), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
207
|
+
var native = _g.value;
|
|
208
|
+
_loop_2(native);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
212
|
+
finally {
|
|
213
|
+
try {
|
|
214
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
215
|
+
}
|
|
216
|
+
finally { if (e_2) throw e_2.error; }
|
|
217
|
+
}
|
|
218
|
+
// OBJECTS
|
|
219
|
+
if (props.metadata.objects.length)
|
|
220
|
+
unions.push({
|
|
221
|
+
type: "object",
|
|
222
|
+
is: function () {
|
|
223
|
+
return ExpressionFactory_1.ExpressionFactory.isObject({
|
|
224
|
+
checkNull: true,
|
|
225
|
+
checkArray: false,
|
|
226
|
+
})(props.input);
|
|
227
|
+
},
|
|
228
|
+
value: function () {
|
|
229
|
+
return explore_objects(__assign(__assign({}, props), { explore: __assign(__assign({}, props.explore), { from: "object" }) }));
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
// COMPOSITION
|
|
233
|
+
if (unions.length === 0)
|
|
234
|
+
return props.input;
|
|
235
|
+
else if (unions.length === 1 && props.metadata.size() === 1) {
|
|
236
|
+
var value = (props.metadata.nullable || props.metadata.isRequired() === false) &&
|
|
237
|
+
is_instance(props.metadata)
|
|
238
|
+
? typescript_1.default.factory.createConditionalExpression(props.input, undefined, unions[0].value(), undefined, props.input)
|
|
239
|
+
: unions[0].value();
|
|
240
|
+
return typescript_1.default.factory.createAsExpression(value, TypeFactory_1.TypeFactory.keyword("any"));
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
var last = props.input;
|
|
244
|
+
try {
|
|
245
|
+
for (var _h = __values(unions.reverse()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
246
|
+
var u = _j.value;
|
|
247
|
+
last = typescript_1.default.factory.createConditionalExpression(u.is(), undefined, u.value(), undefined, last);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
251
|
+
finally {
|
|
252
|
+
try {
|
|
253
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
254
|
+
}
|
|
255
|
+
finally { if (e_3) throw e_3.error; }
|
|
256
|
+
}
|
|
257
|
+
return typescript_1.default.factory.createAsExpression(last, TypeFactory_1.TypeFactory.keyword("any"));
|
|
258
|
+
}
|
|
262
259
|
};
|
|
263
|
-
var decode_object = function (
|
|
260
|
+
var decode_object = function (props) {
|
|
264
261
|
return FeatureProgrammer_1.FeatureProgrammer.decode_object({
|
|
265
262
|
trace: false,
|
|
266
263
|
path: false,
|
|
267
264
|
prefix: PREFIX,
|
|
268
|
-
})(importer);
|
|
265
|
+
})(props.importer)(props.input, props.object, props.explore);
|
|
269
266
|
};
|
|
270
|
-
var decode_array = function (
|
|
271
|
-
return
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
? typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(config.prefix, "a").concat(array.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(__assign(__assign({}, explore), { source: "function", from: "array" }))(input))
|
|
275
|
-
: decode_array_inline(config)(importer)(input, array, explore);
|
|
276
|
-
};
|
|
277
|
-
};
|
|
267
|
+
var decode_array = function (props) {
|
|
268
|
+
return props.array.type.recursive
|
|
269
|
+
? typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(props.config.prefix, "a").concat(props.array.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(__assign(__assign({}, props.explore), { source: "function", from: "array" }))(props.input))
|
|
270
|
+
: decode_array_inline(props);
|
|
278
271
|
};
|
|
279
|
-
var decode_array_inline = function (
|
|
280
|
-
return
|
|
281
|
-
return function (input, array, explore) {
|
|
282
|
-
return FeatureProgrammer_1.FeatureProgrammer.decode_array(config)(importer)(CloneJoiner_1.CloneJoiner.array)(input, array, explore);
|
|
283
|
-
};
|
|
284
|
-
};
|
|
272
|
+
var decode_array_inline = function (props) {
|
|
273
|
+
return FeatureProgrammer_1.FeatureProgrammer.decode_array(props.config)(props.importer)(CloneJoiner_1.CloneJoiner.array)(props.input, props.array, props.explore);
|
|
285
274
|
};
|
|
286
|
-
var decode_tuple = function (
|
|
287
|
-
return
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return tuple.type.recursive
|
|
291
|
-
? typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(config.prefix, "t").concat(tuple.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(__assign(__assign({}, explore), { source: "function" }))(input))
|
|
292
|
-
: decode_tuple_inline(project)(config)(importer)(input, tuple.type, explore);
|
|
293
|
-
};
|
|
294
|
-
};
|
|
295
|
-
};
|
|
275
|
+
var decode_tuple = function (props) {
|
|
276
|
+
return props.tuple.type.recursive
|
|
277
|
+
? typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(props.config.prefix, "t").concat(props.tuple.type.index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(__assign(__assign({}, props.explore), { source: "function" }))(props.input))
|
|
278
|
+
: decode_tuple_inline(__assign(__assign({}, props), { tuple: props.tuple.type }));
|
|
296
279
|
};
|
|
297
|
-
var decode_tuple_inline = function (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
280
|
+
var decode_tuple_inline = function (props) {
|
|
281
|
+
var elements = props.tuple.elements
|
|
282
|
+
.filter(function (m) { return m.rest === null; })
|
|
283
|
+
.map(function (elem, index) {
|
|
284
|
+
return decode({
|
|
285
|
+
context: props.context,
|
|
286
|
+
config: props.config,
|
|
287
|
+
importer: props.importer,
|
|
288
|
+
input: typescript_1.default.factory.createElementAccessExpression(props.input, index),
|
|
289
|
+
metadata: elem,
|
|
290
|
+
explore: __assign(__assign({}, props.explore), { from: "array", postfix: props.explore.postfix.length
|
|
291
|
+
? "".concat((0, postfix_of_tuple_1.postfix_of_tuple)(props.explore.postfix), "[").concat(index, "]\"")
|
|
292
|
+
: "\"[".concat(index, "]\"") }),
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
var rest = (function () {
|
|
296
|
+
if (props.tuple.elements.length === 0)
|
|
297
|
+
return null;
|
|
298
|
+
var last = props.tuple.elements.at(-1);
|
|
299
|
+
var rest = last.rest;
|
|
300
|
+
if (rest === null)
|
|
301
|
+
return null;
|
|
302
|
+
return decode({
|
|
303
|
+
context: props.context,
|
|
304
|
+
config: props.config,
|
|
305
|
+
importer: props.importer,
|
|
306
|
+
input: typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(props.input)("slice"), undefined, [ExpressionFactory_1.ExpressionFactory.number(props.tuple.elements.length - 1)]),
|
|
307
|
+
metadata: (0, wrap_metadata_rest_tuple_1.wrap_metadata_rest_tuple)(props.tuple.elements.at(-1).rest),
|
|
308
|
+
explore: __assign(__assign({}, props.explore), { start: props.tuple.elements.length - 1 }),
|
|
309
|
+
});
|
|
310
|
+
})();
|
|
311
|
+
return CloneJoiner_1.CloneJoiner.tuple({
|
|
312
|
+
elements: elements,
|
|
313
|
+
rest: rest,
|
|
314
|
+
});
|
|
324
315
|
};
|
|
325
316
|
/* -----------------------------------------------------------
|
|
326
317
|
NATIVE CLASSES
|
|
327
318
|
----------------------------------------------------------- */
|
|
328
|
-
var decode_native = function (
|
|
329
|
-
return type === "Date" ||
|
|
330
|
-
type === "Uint8Array" ||
|
|
331
|
-
type === "Uint8ClampedArray" ||
|
|
332
|
-
type === "Uint16Array" ||
|
|
333
|
-
type === "Uint32Array" ||
|
|
334
|
-
type === "BigUint64Array" ||
|
|
335
|
-
type === "Int8Array" ||
|
|
336
|
-
type === "Int16Array" ||
|
|
337
|
-
type === "Int32Array" ||
|
|
338
|
-
type === "BigInt64Array" ||
|
|
339
|
-
type === "Float32Array" ||
|
|
340
|
-
type === "Float64Array" ||
|
|
341
|
-
type === "RegExp"
|
|
342
|
-
? decode_native_copyable(
|
|
343
|
-
: type === "ArrayBuffer" || type === "SharedArrayBuffer"
|
|
344
|
-
? decode_native_buffer(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
};
|
|
352
|
-
var
|
|
319
|
+
var decode_native = function (props) {
|
|
320
|
+
return props.type === "Date" ||
|
|
321
|
+
props.type === "Uint8Array" ||
|
|
322
|
+
props.type === "Uint8ClampedArray" ||
|
|
323
|
+
props.type === "Uint16Array" ||
|
|
324
|
+
props.type === "Uint32Array" ||
|
|
325
|
+
props.type === "BigUint64Array" ||
|
|
326
|
+
props.type === "Int8Array" ||
|
|
327
|
+
props.type === "Int16Array" ||
|
|
328
|
+
props.type === "Int32Array" ||
|
|
329
|
+
props.type === "BigInt64Array" ||
|
|
330
|
+
props.type === "Float32Array" ||
|
|
331
|
+
props.type === "Float64Array" ||
|
|
332
|
+
props.type === "RegExp"
|
|
333
|
+
? decode_native_copyable(props)
|
|
334
|
+
: props.type === "ArrayBuffer" || props.type === "SharedArrayBuffer"
|
|
335
|
+
? decode_native_buffer({
|
|
336
|
+
type: props.type,
|
|
337
|
+
input: props.input,
|
|
338
|
+
})
|
|
339
|
+
: props.type === "DataView"
|
|
340
|
+
? decode_native_data_view(props.input)
|
|
341
|
+
: typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.type), undefined, []);
|
|
342
|
+
};
|
|
343
|
+
var decode_native_copyable = function (props) {
|
|
344
|
+
return typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier(props.type), undefined, [props.input]);
|
|
345
|
+
};
|
|
346
|
+
var decode_native_buffer = function (props) {
|
|
353
347
|
return ExpressionFactory_1.ExpressionFactory.selfCall(typescript_1.default.factory.createBlock([
|
|
354
|
-
StatementFactory_1.StatementFactory.constant("buffer", typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier(type), undefined, [IdentifierFactory_1.IdentifierFactory.access(input)("byteLength")])),
|
|
348
|
+
StatementFactory_1.StatementFactory.constant("buffer", typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier(props.type), undefined, [IdentifierFactory_1.IdentifierFactory.access(props.input)("byteLength")])),
|
|
355
349
|
typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(IdentifierFactory_1.IdentifierFactory.access(typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Uint8Array"), undefined, [typescript_1.default.factory.createIdentifier("buffer")]))("set"), undefined, [
|
|
356
|
-
typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Uint8Array"), undefined, [input]),
|
|
350
|
+
typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Uint8Array"), undefined, [props.input]),
|
|
357
351
|
])),
|
|
358
352
|
typescript_1.default.factory.createReturnStatement(typescript_1.default.factory.createIdentifier("buffer")),
|
|
359
353
|
], true));
|
|
360
|
-
};
|
|
354
|
+
};
|
|
361
355
|
var decode_native_data_view = function (input) {
|
|
362
356
|
return typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("DataView"), undefined, [IdentifierFactory_1.IdentifierFactory.access(input)("buffer")]);
|
|
363
357
|
};
|
|
364
358
|
/* -----------------------------------------------------------
|
|
365
359
|
EXPLORERS FOR UNION TYPES
|
|
366
360
|
----------------------------------------------------------- */
|
|
367
|
-
var explore_sets = function (
|
|
368
|
-
return
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
361
|
+
var explore_sets = function (props) {
|
|
362
|
+
return typescript_1.default.factory.createCallExpression(UnionExplorer_1.UnionExplorer.set({
|
|
363
|
+
checker: IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer),
|
|
364
|
+
decoder: function (input, array, explore) {
|
|
365
|
+
return typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Set"), [TypeFactory_1.TypeFactory.keyword("any")], [
|
|
366
|
+
decode_array({
|
|
367
|
+
config: props.config,
|
|
368
|
+
importer: props.importer,
|
|
369
|
+
input: input,
|
|
370
|
+
array: array,
|
|
371
|
+
explore: explore,
|
|
372
|
+
}),
|
|
373
|
+
]);
|
|
374
|
+
},
|
|
375
|
+
empty: typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Set"), [TypeFactory_1.TypeFactory.keyword("any")], []),
|
|
376
|
+
success: typescript_1.default.factory.createTrue(),
|
|
377
|
+
failure: function (input, expected) {
|
|
378
|
+
return create_throw_error({
|
|
379
|
+
importer: props.importer,
|
|
380
|
+
expected: expected,
|
|
381
|
+
input: input,
|
|
382
|
+
});
|
|
383
|
+
},
|
|
384
|
+
})([])(props.input, props.sets, props.explore), undefined, undefined);
|
|
385
385
|
};
|
|
386
|
-
var explore_maps = function (
|
|
387
|
-
return
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
386
|
+
var explore_maps = function (props) {
|
|
387
|
+
return typescript_1.default.factory.createCallExpression(UnionExplorer_1.UnionExplorer.map({
|
|
388
|
+
checker: function (top, entry, explore) {
|
|
389
|
+
var func = IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer);
|
|
390
|
+
return typescript_1.default.factory.createLogicalAnd(func(typescript_1.default.factory.createElementAccessExpression(top, 0), entry[0], __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[0]") })), func(typescript_1.default.factory.createElementAccessExpression(top, 1), entry[1], __assign(__assign({}, explore), { postfix: "".concat(explore.postfix, "[1]") })));
|
|
391
|
+
},
|
|
392
|
+
decoder: function (input, array, explore) {
|
|
393
|
+
return typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Map"), [TypeFactory_1.TypeFactory.keyword("any"), TypeFactory_1.TypeFactory.keyword("any")], [
|
|
394
|
+
decode_array({
|
|
395
|
+
config: props.config,
|
|
396
|
+
importer: props.importer,
|
|
397
|
+
input: input,
|
|
398
|
+
array: array,
|
|
399
|
+
explore: explore,
|
|
400
|
+
}),
|
|
401
|
+
]);
|
|
402
|
+
},
|
|
403
|
+
empty: typescript_1.default.factory.createNewExpression(typescript_1.default.factory.createIdentifier("Map"), [TypeFactory_1.TypeFactory.keyword("any"), TypeFactory_1.TypeFactory.keyword("any")], []),
|
|
404
|
+
success: typescript_1.default.factory.createTrue(),
|
|
405
|
+
failure: function (input, expected) {
|
|
406
|
+
return create_throw_error({
|
|
407
|
+
importer: props.importer,
|
|
408
|
+
expected: expected,
|
|
409
|
+
input: input,
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
})([])(props.input, props.maps, props.explore), undefined, undefined);
|
|
407
413
|
};
|
|
408
|
-
var explore_objects = function (
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
? decode_object(importer)(input, meta.objects[0], explore)
|
|
413
|
-
: typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.useLocal("".concat(PREFIX, "u").concat(meta.union_index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input));
|
|
414
|
-
};
|
|
415
|
-
};
|
|
414
|
+
var explore_objects = function (props) {
|
|
415
|
+
return props.metadata.objects.length === 1
|
|
416
|
+
? decode_object(__assign(__assign({}, props), { object: props.metadata.objects[0] }))
|
|
417
|
+
: typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.useLocal("".concat(PREFIX, "u").concat(props.metadata.union_index))), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(props.explore)(props.input));
|
|
416
418
|
};
|
|
417
|
-
var explore_arrays = function (
|
|
418
|
-
return function (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
419
|
+
var explore_arrays = function (props) {
|
|
420
|
+
return explore_array_like_union_types(__assign(__assign({}, props), { elements: props.arrays, factory: function (next) {
|
|
421
|
+
return UnionExplorer_1.UnionExplorer.array({
|
|
422
|
+
checker: IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer),
|
|
423
|
+
decoder: function (input, array, explore) {
|
|
424
|
+
return decode_array({
|
|
425
|
+
config: props.config,
|
|
426
|
+
importer: props.importer,
|
|
427
|
+
input: input,
|
|
428
|
+
array: array,
|
|
429
|
+
explore: explore,
|
|
430
|
+
});
|
|
431
|
+
},
|
|
432
|
+
empty: typescript_1.default.factory.createIdentifier("[]"),
|
|
433
|
+
success: typescript_1.default.factory.createTrue(),
|
|
434
|
+
failure: function (input, expected) {
|
|
435
|
+
return create_throw_error({
|
|
436
|
+
importer: props.importer,
|
|
437
|
+
expected: expected,
|
|
438
|
+
input: input,
|
|
439
|
+
});
|
|
440
|
+
},
|
|
441
|
+
})(next.parameters)(next.input, next.elements, next.explore);
|
|
442
|
+
} }));
|
|
433
443
|
};
|
|
434
|
-
var explore_array_like_union_types = function (
|
|
435
|
-
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
};
|
|
443
|
-
};
|
|
444
|
-
};
|
|
445
|
-
if (elements.every(function (e) { return e.type.recursive === false; }))
|
|
446
|
-
typescript_1.default.factory.createCallExpression(arrow([])(explore)(input), undefined, []);
|
|
447
|
-
explore = __assign(__assign({}, explore), { source: "function", from: "array" });
|
|
448
|
-
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(importer.emplaceUnion(config.prefix, elements.map(function (e) { return e.type.name; }).join(" | "), function () {
|
|
449
|
-
return arrow(FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")))(__assign(__assign({}, explore), { postfix: "" }))(typescript_1.default.factory.createIdentifier("input"));
|
|
450
|
-
})), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(config)(explore)(input));
|
|
451
|
-
};
|
|
452
|
-
};
|
|
444
|
+
var explore_array_like_union_types = function (props) {
|
|
445
|
+
var arrow = function (next) {
|
|
446
|
+
return props.factory({
|
|
447
|
+
elements: props.elements,
|
|
448
|
+
parameters: next.parameters,
|
|
449
|
+
input: next.input,
|
|
450
|
+
explore: next.explore,
|
|
451
|
+
});
|
|
453
452
|
};
|
|
453
|
+
if (props.elements.every(function (e) { return e.type.recursive === false; }))
|
|
454
|
+
typescript_1.default.factory.createCallExpression(arrow({
|
|
455
|
+
parameters: [],
|
|
456
|
+
explore: props.explore,
|
|
457
|
+
input: props.input,
|
|
458
|
+
}), undefined, []);
|
|
459
|
+
var explore = __assign(__assign({}, props.explore), { source: "function", from: "array" });
|
|
460
|
+
return typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier(props.importer.emplaceUnion(props.config.prefix, props.elements.map(function (e) { return e.type.name; }).join(" | "), function () {
|
|
461
|
+
return arrow({
|
|
462
|
+
parameters: FeatureProgrammer_1.FeatureProgrammer.parameterDeclarations(props.config)(TypeFactory_1.TypeFactory.keyword("any"))(typescript_1.default.factory.createIdentifier("input")),
|
|
463
|
+
explore: __assign(__assign({}, explore), { postfix: "" }),
|
|
464
|
+
input: typescript_1.default.factory.createIdentifier("input"),
|
|
465
|
+
});
|
|
466
|
+
})), undefined, FeatureProgrammer_1.FeatureProgrammer.argumentsArray(props.config)(explore)(props.input));
|
|
454
467
|
};
|
|
455
468
|
/* -----------------------------------------------------------
|
|
456
469
|
CONFIGURATIONS
|
|
457
470
|
----------------------------------------------------------- */
|
|
458
471
|
var PREFIX = "$c";
|
|
459
|
-
var configure = function (
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
return typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(project.checker)(type));
|
|
465
|
-
},
|
|
466
|
-
output: function (type, name) {
|
|
467
|
-
return typescript_1.default.factory.createImportTypeNode(typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral("typia")), undefined, typescript_1.default.factory.createIdentifier("Resolved"), [
|
|
468
|
-
typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(project.checker)(type)),
|
|
469
|
-
], false);
|
|
470
|
-
},
|
|
472
|
+
var configure = function (props) {
|
|
473
|
+
var config = {
|
|
474
|
+
types: {
|
|
475
|
+
input: function (type, name) {
|
|
476
|
+
return typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(props.context.checker)(type));
|
|
471
477
|
},
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
decoder: function () { return decode(project)(config)(importer); },
|
|
477
|
-
objector: {
|
|
478
|
-
checker: function () { return IsProgrammer_1.IsProgrammer.decode(project)(importer); },
|
|
479
|
-
decoder: function () { return decode_object(importer); },
|
|
480
|
-
joiner: CloneJoiner_1.CloneJoiner.object,
|
|
481
|
-
unionizer: (0, decode_union_object_1.decode_union_object)(IsProgrammer_1.IsProgrammer.decode_object(project)(importer))(decode_object(importer))(function (exp) { return exp; })(function (input, expected) {
|
|
482
|
-
return create_throw_error(importer)(expected)(input);
|
|
483
|
-
}),
|
|
484
|
-
failure: function (input, expected) {
|
|
485
|
-
return create_throw_error(importer)(expected)(input);
|
|
486
|
-
},
|
|
478
|
+
output: function (type, name) {
|
|
479
|
+
return typescript_1.default.factory.createImportTypeNode(typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral("typia")), undefined, typescript_1.default.factory.createIdentifier("Resolved"), [
|
|
480
|
+
typescript_1.default.factory.createTypeReferenceNode(name !== null && name !== void 0 ? name : TypeFactory_1.TypeFactory.getFullName(props.context.checker)(type)),
|
|
481
|
+
], false);
|
|
487
482
|
},
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
483
|
+
},
|
|
484
|
+
prefix: PREFIX,
|
|
485
|
+
trace: false,
|
|
486
|
+
path: false,
|
|
487
|
+
initializer: initializer,
|
|
488
|
+
decoder: function () { return function (input, metadata, explore) {
|
|
489
|
+
return decode({
|
|
490
|
+
context: props.context,
|
|
491
|
+
importer: props.importer,
|
|
492
|
+
config: config,
|
|
493
|
+
input: input,
|
|
494
|
+
metadata: metadata,
|
|
495
|
+
explore: explore,
|
|
496
|
+
});
|
|
497
|
+
}; },
|
|
498
|
+
objector: {
|
|
499
|
+
checker: function () { return IsProgrammer_1.IsProgrammer.decode(props.context)(props.importer); },
|
|
500
|
+
decoder: function () { return function (input, object, explore) {
|
|
501
|
+
return decode_object({
|
|
502
|
+
importer: props.importer,
|
|
503
|
+
input: input,
|
|
504
|
+
object: object,
|
|
505
|
+
explore: explore,
|
|
506
|
+
});
|
|
507
|
+
}; },
|
|
508
|
+
joiner: CloneJoiner_1.CloneJoiner.object,
|
|
509
|
+
unionizer: (0, decode_union_object_1.decode_union_object)(IsProgrammer_1.IsProgrammer.decode_object(props.context)(props.importer))(function (input, object, explore) {
|
|
510
|
+
return decode_object({
|
|
511
|
+
importer: props.importer,
|
|
512
|
+
input: input,
|
|
513
|
+
object: object,
|
|
514
|
+
explore: explore,
|
|
515
|
+
});
|
|
516
|
+
})(function (exp) { return exp; })(function (input, expected) {
|
|
517
|
+
return create_throw_error({
|
|
518
|
+
importer: props.importer,
|
|
519
|
+
expected: expected,
|
|
520
|
+
input: input,
|
|
521
|
+
});
|
|
522
|
+
}),
|
|
523
|
+
failure: function (input, expected) {
|
|
524
|
+
return create_throw_error({
|
|
525
|
+
importer: props.importer,
|
|
526
|
+
expected: expected,
|
|
527
|
+
input: input,
|
|
528
|
+
});
|
|
491
529
|
},
|
|
492
|
-
}
|
|
493
|
-
|
|
530
|
+
},
|
|
531
|
+
generator: {
|
|
532
|
+
arrays: function () { return function (collection) {
|
|
533
|
+
return write_array_functions({
|
|
534
|
+
importer: props.importer,
|
|
535
|
+
config: config,
|
|
536
|
+
collection: collection,
|
|
537
|
+
});
|
|
538
|
+
}; },
|
|
539
|
+
tuples: function () { return function (collection) {
|
|
540
|
+
return write_tuple_functions({
|
|
541
|
+
context: props.context,
|
|
542
|
+
importer: props.importer,
|
|
543
|
+
config: config,
|
|
544
|
+
collection: collection,
|
|
545
|
+
});
|
|
546
|
+
}; },
|
|
547
|
+
},
|
|
494
548
|
};
|
|
549
|
+
return config;
|
|
495
550
|
};
|
|
496
|
-
var initializer = function (
|
|
551
|
+
var initializer = function (context) { return function (importer) { return function (type) {
|
|
497
552
|
var collection = new MetadataCollection_1.MetadataCollection();
|
|
498
553
|
var result = MetadataFactory_1.MetadataFactory.analyze({
|
|
499
|
-
checker:
|
|
500
|
-
transformer:
|
|
554
|
+
checker: context.checker,
|
|
555
|
+
transformer: context.transformer,
|
|
501
556
|
options: {
|
|
502
557
|
escape: false,
|
|
503
558
|
constant: true,
|
|
504
559
|
absorb: true,
|
|
505
|
-
validate: function (
|
|
560
|
+
validate: function (metadata) {
|
|
506
561
|
var output = [];
|
|
507
|
-
if (
|
|
562
|
+
if (metadata.natives.some(function (n) { return n === "WeakSet"; }))
|
|
508
563
|
output.push("unable to clone WeakSet");
|
|
509
|
-
else if (
|
|
564
|
+
else if (metadata.natives.some(function (n) { return n === "WeakMap"; }))
|
|
510
565
|
output.push("unable to clone WeakMap");
|
|
511
566
|
return output;
|
|
512
567
|
},
|
|
@@ -518,26 +573,22 @@ var MiscCloneProgrammer;
|
|
|
518
573
|
throw TransformerError_1.TransformerError.from("typia.misc.".concat(importer.method))(result.errors);
|
|
519
574
|
return [collection, result.data];
|
|
520
575
|
}; }; };
|
|
521
|
-
var create_throw_error = function (
|
|
522
|
-
return
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
], true),
|
|
529
|
-
]));
|
|
530
|
-
};
|
|
531
|
-
};
|
|
576
|
+
var create_throw_error = function (props) {
|
|
577
|
+
return typescript_1.default.factory.createExpressionStatement(typescript_1.default.factory.createCallExpression(props.importer.use("throws"), [], [
|
|
578
|
+
typescript_1.default.factory.createObjectLiteralExpression([
|
|
579
|
+
typescript_1.default.factory.createPropertyAssignment("expected", typescript_1.default.factory.createStringLiteral(props.expected)),
|
|
580
|
+
typescript_1.default.factory.createPropertyAssignment("value", props.input),
|
|
581
|
+
], true),
|
|
582
|
+
]));
|
|
532
583
|
};
|
|
533
|
-
var is_instance = function (
|
|
534
|
-
return !!
|
|
535
|
-
!!
|
|
536
|
-
!!
|
|
537
|
-
!!
|
|
538
|
-
!!
|
|
539
|
-
!!
|
|
540
|
-
(
|
|
584
|
+
var is_instance = function (metadata) {
|
|
585
|
+
return !!metadata.objects.length ||
|
|
586
|
+
!!metadata.arrays.length ||
|
|
587
|
+
!!metadata.tuples.length ||
|
|
588
|
+
!!metadata.sets.length ||
|
|
589
|
+
!!metadata.maps.length ||
|
|
590
|
+
!!metadata.natives.length ||
|
|
591
|
+
(metadata.rest !== null && is_instance(metadata.rest));
|
|
541
592
|
};
|
|
542
593
|
})(MiscCloneProgrammer || (exports.MiscCloneProgrammer = MiscCloneProgrammer = {}));
|
|
543
594
|
//# sourceMappingURL=MiscCloneProgrammer.js.map
|