typia 5.5.0-dev.20240303-2 → 5.5.0-dev.20240304
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/functional/Namespace/functional.d.ts +4 -0
- package/lib/functional/Namespace/functional.js +9 -0
- package/lib/functional/Namespace/functional.js.map +1 -0
- package/lib/functional/Namespace/index.d.ts +1 -0
- package/lib/functional/Namespace/index.js +2 -1
- package/lib/functional/Namespace/index.js.map +1 -1
- package/lib/functional.d.ts +6 -162
- package/lib/functional.js +248 -48
- package/lib/functional.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +2 -2
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.js +3 -3
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +2 -2
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +2 -2
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.d.ts +2 -0
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js +55 -11
- package/lib/programmers/functional/FunctionalAssertFunctionProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.d.ts +1 -5
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js +38 -21
- package/lib/programmers/functional/FunctionalAssertParametersProgrammer.js.map +1 -1
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.d.ts +1 -5
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js +17 -18
- package/lib/programmers/functional/FunctionalAssertReturnProgrammer.js.map +1 -1
- package/lib/programmers/helpers/FunctionImporeter.d.ts +1 -19
- package/lib/programmers/helpers/FunctionImporeter.js +13 -91
- package/lib/programmers/helpers/FunctionImporeter.js.map +1 -1
- package/lib/programmers/helpers/FunctionImporter.d.ts +19 -0
- package/lib/programmers/helpers/FunctionImporter.js +96 -0
- package/lib/programmers/helpers/FunctionImporter.js.map +1 -0
- package/lib/programmers/helpers/StringifyJoinder.d.ts +1 -1
- package/lib/programmers/helpers/disable_function_importer_declare.d.ts +1 -1
- package/lib/programmers/http/HttpFormDataProgrammer.js +2 -2
- package/lib/programmers/http/HttpFormDataProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js +2 -2
- package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpParameterProgrammer.js +2 -2
- package/lib/programmers/http/HttpParameterProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpQueryProgrammer.js +2 -2
- package/lib/programmers/http/HttpQueryProgrammer.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_key.d.ts +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +2 -2
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +2 -2
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +2 -2
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +2 -2
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +2 -2
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +2 -2
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/transformers/features/functional/FunctionalGenericTransformer.d.ts +1 -1
- package/lib/transformers/features/functional/FunctionalGenericTransformer.js +11 -32
- package/lib/transformers/features/functional/FunctionalGenericTransformer.js.map +1 -1
- package/package.json +2 -1
- package/src/functional/Namespace/functional.ts +5 -0
- package/src/functional/Namespace/index.ts +1 -0
- package/src/functional.ts +258 -243
- package/src/programmers/AssertProgrammer.ts +1 -1
- package/src/programmers/CheckerProgrammer.ts +1 -1
- package/src/programmers/FeatureProgrammer.ts +1 -1
- package/src/programmers/IsProgrammer.ts +1 -1
- package/src/programmers/RandomProgrammer.ts +1 -1
- package/src/programmers/ValidateProgrammer.ts +1 -1
- package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +103 -18
- package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +22 -45
- package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +44 -40
- package/src/programmers/helpers/FunctionImporeter.ts +1 -87
- package/src/programmers/helpers/FunctionImporter.ts +87 -0
- package/src/programmers/helpers/StringifyJoinder.ts +1 -1
- package/src/programmers/helpers/disable_function_importer_declare.ts +1 -1
- package/src/programmers/http/HttpFormDataProgrammer.ts +1 -1
- package/src/programmers/http/HttpHeadersProgrammer.ts +1 -1
- package/src/programmers/http/HttpParameterProgrammer.ts +1 -1
- package/src/programmers/http/HttpQueryProgrammer.ts +1 -1
- package/src/programmers/internal/check_dynamic_key.ts +1 -1
- package/src/programmers/internal/check_dynamic_properties.ts +1 -1
- package/src/programmers/internal/check_object.ts +1 -1
- package/src/programmers/internal/feature_object_entries.ts +1 -1
- package/src/programmers/json/JsonStringifyProgrammer.ts +1 -1
- package/src/programmers/misc/MiscCloneProgrammer.ts +1 -1
- package/src/programmers/misc/MiscPruneProgrammer.ts +1 -1
- package/src/programmers/notations/NotationGeneralProgrammer.ts +1 -1
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -1
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +1 -1
- package/src/transformers/features/functional/FunctionalGenericTransformer.ts +12 -17
package/src/functional.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Namespace from "./functional/Namespace";
|
|
2
|
-
import { IValidation } from "./IValidation";
|
|
3
2
|
|
|
3
|
+
// import { IValidation } from "./IValidation";
|
|
4
4
|
import { TypeGuardError } from "./TypeGuardError";
|
|
5
5
|
|
|
6
6
|
/* ===========================================================
|
|
@@ -42,7 +42,7 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
42
42
|
*
|
|
43
43
|
* @author Jeongho Nam - https://github.com/samchon
|
|
44
44
|
*/
|
|
45
|
-
function assertFunction<T extends (...args:
|
|
45
|
+
function assertFunction<T extends (...args: any[]) => any>(
|
|
46
46
|
func: T,
|
|
47
47
|
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
48
48
|
): T;
|
|
@@ -55,10 +55,12 @@ function assertFunction(): never {
|
|
|
55
55
|
}
|
|
56
56
|
const assertFunctionPure = /** @__PURE__ */ Object.assign<
|
|
57
57
|
typeof assertFunction,
|
|
58
|
+
{},
|
|
58
59
|
{}
|
|
59
60
|
>(
|
|
60
61
|
assertFunction,
|
|
61
62
|
/** @__PURE__ */ Namespace.assert("functional.assertFunction"),
|
|
63
|
+
/** @__PURE__ */ Namespace.functional.functionalAssert(),
|
|
62
64
|
);
|
|
63
65
|
export { assertFunctionPure as assertFunction };
|
|
64
66
|
|
|
@@ -90,7 +92,7 @@ export { assertFunctionPure as assertFunction };
|
|
|
90
92
|
*
|
|
91
93
|
* @author Jeongho Nam - https://github.com/samchon
|
|
92
94
|
*/
|
|
93
|
-
function assertParameters<T extends (...args:
|
|
95
|
+
function assertParameters<T extends (...args: any[]) => any>(
|
|
94
96
|
func: T,
|
|
95
97
|
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
96
98
|
): T;
|
|
@@ -103,10 +105,12 @@ function assertParameters(): never {
|
|
|
103
105
|
}
|
|
104
106
|
const assertParametersPure = /** @__PURE__ */ Object.assign<
|
|
105
107
|
typeof assertParameters,
|
|
108
|
+
{},
|
|
106
109
|
{}
|
|
107
110
|
>(
|
|
108
|
-
|
|
109
|
-
/** @__PURE__ */ Namespace.assert("functional.
|
|
111
|
+
assertFunction,
|
|
112
|
+
/** @__PURE__ */ Namespace.assert("functional.assertFunction"),
|
|
113
|
+
/** @__PURE__ */ Namespace.functional.functionalAssert(),
|
|
110
114
|
);
|
|
111
115
|
export { assertParametersPure as assertParameters };
|
|
112
116
|
|
|
@@ -138,7 +142,7 @@ export { assertParametersPure as assertParameters };
|
|
|
138
142
|
*
|
|
139
143
|
* @author Jeongho Nam - https://github.com/samchon
|
|
140
144
|
*/
|
|
141
|
-
function assertReturn<T extends (...args:
|
|
145
|
+
function assertReturn<T extends (...args: any[]) => any>(
|
|
142
146
|
func: T,
|
|
143
147
|
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
144
148
|
): T;
|
|
@@ -151,8 +155,13 @@ function assertReturn(): never {
|
|
|
151
155
|
}
|
|
152
156
|
const assertReturnPure = /** @__PURE__ */ Object.assign<
|
|
153
157
|
typeof assertReturn,
|
|
158
|
+
{},
|
|
154
159
|
{}
|
|
155
|
-
>(
|
|
160
|
+
>(
|
|
161
|
+
assertReturn,
|
|
162
|
+
/** @__PURE__ */ Namespace.assert("functional.assertReturn"),
|
|
163
|
+
/** @__PURE__ */ Namespace.functional.functionalAssert(),
|
|
164
|
+
);
|
|
156
165
|
export { assertReturnPure as assertReturn };
|
|
157
166
|
|
|
158
167
|
/**
|
|
@@ -188,7 +197,7 @@ export { assertReturnPure as assertReturn };
|
|
|
188
197
|
*
|
|
189
198
|
* @author Jeongho Nam - https://github.com/samchon
|
|
190
199
|
*/
|
|
191
|
-
function assertEqualsFunction<T extends (...args:
|
|
200
|
+
function assertEqualsFunction<T extends (...args: any[]) => any>(
|
|
192
201
|
func: T,
|
|
193
202
|
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
194
203
|
): T;
|
|
@@ -201,10 +210,12 @@ function assertEqualsFunction(): never {
|
|
|
201
210
|
}
|
|
202
211
|
const assertEqualsFunctionPure = /** @__PURE__ */ Object.assign<
|
|
203
212
|
typeof assertEqualsFunction,
|
|
213
|
+
{},
|
|
204
214
|
{}
|
|
205
215
|
>(
|
|
206
216
|
assertEqualsFunction,
|
|
207
217
|
/** @__PURE__ */ Namespace.assert("functional.assertEqualsFunction"),
|
|
218
|
+
/** @__PURE__ */ Namespace.functional.functionalAssert(),
|
|
208
219
|
);
|
|
209
220
|
export { assertEqualsFunctionPure as assertEqualsFunction };
|
|
210
221
|
|
|
@@ -237,7 +248,7 @@ export { assertEqualsFunctionPure as assertEqualsFunction };
|
|
|
237
248
|
*
|
|
238
249
|
* @author Jeongho Nam - https://github.com/samchon
|
|
239
250
|
*/
|
|
240
|
-
function assertEqualsParameters<T extends (...args:
|
|
251
|
+
function assertEqualsParameters<T extends (...args: any[]) => any>(
|
|
241
252
|
func: T,
|
|
242
253
|
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
243
254
|
): T;
|
|
@@ -250,10 +261,12 @@ function assertEqualsParameters(): never {
|
|
|
250
261
|
}
|
|
251
262
|
const assertEqualsParametersPure = /** @__PURE__ */ Object.assign<
|
|
252
263
|
typeof assertEqualsParameters,
|
|
264
|
+
{},
|
|
253
265
|
{}
|
|
254
266
|
>(
|
|
255
267
|
assertEqualsParameters,
|
|
256
268
|
/** @__PURE__ */ Namespace.assert("functional.assertEqualsParameters"),
|
|
269
|
+
/** @__PURE__ */ Namespace.functional.functionalAssert(),
|
|
257
270
|
);
|
|
258
271
|
export { assertEqualsParametersPure as assertEqualsParameters };
|
|
259
272
|
|
|
@@ -285,7 +298,7 @@ export { assertEqualsParametersPure as assertEqualsParameters };
|
|
|
285
298
|
*
|
|
286
299
|
* @author Jeongho Nam - https://github.com/samchon
|
|
287
300
|
*/
|
|
288
|
-
function assertEqualsReturn<T extends (...args:
|
|
301
|
+
function assertEqualsReturn<T extends (...args: any[]) => any>(
|
|
289
302
|
func: T,
|
|
290
303
|
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
291
304
|
): T;
|
|
@@ -298,255 +311,257 @@ function assertEqualsReturn(): never {
|
|
|
298
311
|
}
|
|
299
312
|
const assertEqualsReturnPure = /** @__PURE__ */ Object.assign<
|
|
300
313
|
typeof assertEqualsReturn,
|
|
314
|
+
{},
|
|
301
315
|
{}
|
|
302
316
|
>(
|
|
303
317
|
assertEqualsReturn,
|
|
304
318
|
/** @__PURE__ */ Namespace.assert("functional.assertEqualsReturn"),
|
|
319
|
+
/** @__PURE__ */ Namespace.functional.functionalAssert(),
|
|
305
320
|
);
|
|
306
321
|
export { assertEqualsReturnPure as assertEqualsReturn };
|
|
307
322
|
|
|
308
|
-
/* -----------------------------------------------------------
|
|
309
|
-
|
|
310
|
-
----------------------------------------------------------- */
|
|
311
|
-
/**
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
function validateFunction<T extends (...args:
|
|
343
|
-
|
|
344
|
-
): T extends (...args: infer Arguments) => infer Output
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
323
|
+
// /* -----------------------------------------------------------
|
|
324
|
+
// VALIDATIONS
|
|
325
|
+
// ----------------------------------------------------------- */
|
|
326
|
+
// /**
|
|
327
|
+
// * Validates a function.
|
|
328
|
+
// *
|
|
329
|
+
// * Validates a function, by wrapping the function and checking its parameters and
|
|
330
|
+
// * return value through {@link validate} function. If some parameter or return value
|
|
331
|
+
// * does not match the expected type, it returns {@link IValidation.IError} typed
|
|
332
|
+
// * object. Otherwise there's no type error, it returns {@link IValidation.ISuccess}
|
|
333
|
+
// * typed object instead.
|
|
334
|
+
// *
|
|
335
|
+
// * For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
336
|
+
// * individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
337
|
+
// * some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
338
|
+
// * the path would start from `$input.return`.
|
|
339
|
+
// *
|
|
340
|
+
// * - `$input.parameters[0].~`
|
|
341
|
+
// * - `$input.return.~`
|
|
342
|
+
// *
|
|
343
|
+
// * By the way, if what you want is not finding every type errors, but just finding
|
|
344
|
+
// * the 1st type error, then use {@link assertFunction} instead. Otherwise, what you
|
|
345
|
+
// * want is just validating parameters or return value only, you can use
|
|
346
|
+
// * {@link validateParameters} or {@link validateReturn} instead.
|
|
347
|
+
// *
|
|
348
|
+
// * On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
349
|
+
// * {@link validateEqualsFunction} or {@link assertEqualsFunction} instead.
|
|
350
|
+
// *
|
|
351
|
+
// * @template T Target function type
|
|
352
|
+
// * @param func Target function to validate
|
|
353
|
+
// * @returns The wrapper function with type validations
|
|
354
|
+
// *
|
|
355
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
356
|
+
// */
|
|
357
|
+
// function validateFunction<T extends (...args: any[]) => any>(
|
|
358
|
+
// func: T,
|
|
359
|
+
// ): T extends (...args: infer Arguments) => infer Output
|
|
360
|
+
// ? Output extends Promise<infer R>
|
|
361
|
+
// ? (...args: Arguments) => Promise<IValidation<R>>
|
|
362
|
+
// : (...args: Arguments) => IValidation<Output>
|
|
363
|
+
// : never;
|
|
349
364
|
|
|
350
|
-
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
function validateFunction(): never {
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
const validateFunctionPure = /** @__PURE__ */ Object.assign<
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
>(validateFunction, /** @__PURE__ */ Namespace.validate());
|
|
360
|
-
export { validateFunctionPure as validateFunction };
|
|
365
|
+
// /**
|
|
366
|
+
// * @internal
|
|
367
|
+
// */
|
|
368
|
+
// function validateFunction(): never {
|
|
369
|
+
// halt("validateFunction");
|
|
370
|
+
// }
|
|
371
|
+
// const validateFunctionPure = /** @__PURE__ */ Object.assign<
|
|
372
|
+
// typeof validateFunction,
|
|
373
|
+
// {}
|
|
374
|
+
// >(validateFunction, /** @__PURE__ */ Namespace.validate());
|
|
375
|
+
// export { validateFunctionPure as validateFunction };
|
|
361
376
|
|
|
362
|
-
/**
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
function validateReturn<T extends (...args:
|
|
389
|
-
|
|
390
|
-
): T extends (...args: infer Arguments) => infer Output
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
377
|
+
// /**
|
|
378
|
+
// * Validates parameters.
|
|
379
|
+
// *
|
|
380
|
+
// * Validates a function, by wrapping the function and checking its parameters through
|
|
381
|
+
// * {@link validate} function. If some parameter does not match the expected type, it
|
|
382
|
+
// * returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
383
|
+
// * it returns {@link IValidation.ISuccess} typed object instead.
|
|
384
|
+
// *
|
|
385
|
+
// * For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
386
|
+
// * individual {@link validate} function. If the {@link IValidation.IError} occurs from
|
|
387
|
+
// * some parameter, the path would start from `$input.parameters[number]`.
|
|
388
|
+
// *
|
|
389
|
+
// * By the way, if what you want is not finding every type errors, but just finding
|
|
390
|
+
// * the 1st type error, then use {@link assertParameters} instead. Otherwise, what you
|
|
391
|
+
// * want is not only validating parameters, but also validating return value, you can
|
|
392
|
+
// * use {@link validateFunction} instead.
|
|
393
|
+
// *
|
|
394
|
+
// * On the other hand, if you don't want to allow any superfluous properties, utilize
|
|
395
|
+
// * {@link validateEqualsParameters} or {@link assertEqualsParameters} instead.
|
|
396
|
+
// *
|
|
397
|
+
// * @template T Target function type
|
|
398
|
+
// * @param func Target function to validate
|
|
399
|
+
// * @returns The wrapper function with type validations
|
|
400
|
+
// *
|
|
401
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
402
|
+
// */
|
|
403
|
+
// function validateReturn<T extends (...args: any[]) => any>(
|
|
404
|
+
// func: T,
|
|
405
|
+
// ): T extends (...args: infer Arguments) => infer Output
|
|
406
|
+
// ? Output extends Promise<infer R>
|
|
407
|
+
// ? (...args: Arguments) => Promise<IValidation<R>>
|
|
408
|
+
// : (...args: Arguments) => IValidation<Output>
|
|
409
|
+
// : never;
|
|
395
410
|
|
|
396
|
-
/**
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
function validateReturn(): never {
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
const validateReturnPure = /** @__PURE__ */ Object.assign<
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
>(validateReturn, /** @__PURE__ */ Namespace.validate());
|
|
406
|
-
export { validateReturnPure as validateReturn };
|
|
411
|
+
// /**
|
|
412
|
+
// * @internal
|
|
413
|
+
// */
|
|
414
|
+
// function validateReturn(): never {
|
|
415
|
+
// halt("validateReturn");
|
|
416
|
+
// }
|
|
417
|
+
// const validateReturnPure = /** @__PURE__ */ Object.assign<
|
|
418
|
+
// typeof validateReturn,
|
|
419
|
+
// {}
|
|
420
|
+
// >(validateReturn, /** @__PURE__ */ Namespace.validate());
|
|
421
|
+
// export { validateReturnPure as validateReturn };
|
|
407
422
|
|
|
408
|
-
/**
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
function validateEqualsFunction<T extends (...args:
|
|
440
|
-
|
|
441
|
-
): T extends (...args: infer Arguments) => infer Output
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
423
|
+
// /**
|
|
424
|
+
// * Validates a function with strict equality.
|
|
425
|
+
// *
|
|
426
|
+
// * Validates a function with strict equality, by wrapping the function and checking
|
|
427
|
+
// * its parameters and return value through {@link validateEquals} function. If some
|
|
428
|
+
// * parameter or return value does not match the expected type, it returns
|
|
429
|
+
// * {@link IValidation.IError} typed object. Otherwise there's no type error, it
|
|
430
|
+
// * returns {@link IValidation.ISuccess} typed object instead.
|
|
431
|
+
// *
|
|
432
|
+
// * For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
433
|
+
// * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
434
|
+
// * from some parameter, the path would start from `$input.parameters[number]`. Otherwise
|
|
435
|
+
// * the path would start from `$input.return`.
|
|
436
|
+
// *
|
|
437
|
+
// * - `$input.parameters[0].~`
|
|
438
|
+
// * - `$input.return.~`
|
|
439
|
+
// *
|
|
440
|
+
// * By the way, if what you want is not finding every type errors, but just finding
|
|
441
|
+
// * the 1st type error, then use {@link assertEqualsFunction} instead. Otherwise, what
|
|
442
|
+
// * you want is just validating parameters or return value only, you can use
|
|
443
|
+
// * {@link validateEqualsParameters} or {@link validateEqualsReturn} instead.
|
|
444
|
+
// *
|
|
445
|
+
// * On the other hand, if you want to allow any superfluous properties, utilize
|
|
446
|
+
// * {@link validateFunction} or {@link assertFunction} instead.
|
|
447
|
+
// *
|
|
448
|
+
// * @template T Target function type
|
|
449
|
+
// * @param func Target function to validate
|
|
450
|
+
// * @returns The wrapper function with type validations
|
|
451
|
+
// *
|
|
452
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
453
|
+
// */
|
|
454
|
+
// function validateEqualsFunction<T extends (...args: any[]) => any>(
|
|
455
|
+
// func: T,
|
|
456
|
+
// ): T extends (...args: infer Arguments) => infer Output
|
|
457
|
+
// ? Output extends Promise<infer R>
|
|
458
|
+
// ? (...args: Arguments) => Promise<IValidation<R>>
|
|
459
|
+
// : (...args: Arguments) => IValidation<Output>
|
|
460
|
+
// : never;
|
|
446
461
|
|
|
447
|
-
/**
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
function validateEqualsFunction(): never {
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
const validateEqualsFunctionPure = /** @__PURE__ */ Object.assign<
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
>(validateEqualsFunction, /** @__PURE__ */ Namespace.validate());
|
|
457
|
-
export { validateEqualsFunctionPure as validateEqualsFunction };
|
|
462
|
+
// /**
|
|
463
|
+
// * @internal
|
|
464
|
+
// */
|
|
465
|
+
// function validateEqualsFunction(): never {
|
|
466
|
+
// halt("validateEqualsFunction");
|
|
467
|
+
// }
|
|
468
|
+
// const validateEqualsFunctionPure = /** @__PURE__ */ Object.assign<
|
|
469
|
+
// typeof validateEqualsFunction,
|
|
470
|
+
// {}
|
|
471
|
+
// >(validateEqualsFunction, /** @__PURE__ */ Namespace.validate());
|
|
472
|
+
// export { validateEqualsFunctionPure as validateEqualsFunction };
|
|
458
473
|
|
|
459
|
-
/**
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
function validateEqualsParameters<T extends (...args:
|
|
486
|
-
|
|
487
|
-
): T extends (...args: infer Arguments) => infer Output
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
474
|
+
// /**
|
|
475
|
+
// * Validates parameters with strict equality.
|
|
476
|
+
// *
|
|
477
|
+
// * Validates a function, by wrapping the function and checking its parameters through
|
|
478
|
+
// * {@link validateEquals} function. If some parameter does not match the expected type,
|
|
479
|
+
// * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
480
|
+
// * it returns {@link IValidation.ISuccess} typed object instead.
|
|
481
|
+
// *
|
|
482
|
+
// * For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
483
|
+
// * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
484
|
+
// * from some parameter, the path would start from `$input.parameters[number]`.
|
|
485
|
+
// *
|
|
486
|
+
// * By the way, if what you want is not finding every type errors, but just finding
|
|
487
|
+
// * the 1st type error, then use {@link assertEqualsParameters} instead. Otherwise,
|
|
488
|
+
// * what you want is not only validating parameters, but also validating return value,
|
|
489
|
+
// * you can use {@link validateEqualsFunction} instead.
|
|
490
|
+
// *
|
|
491
|
+
// * On the other hand, if you want to allow any superfluous properties, utilize
|
|
492
|
+
// * {@link validateParameters} or {@link assertParameters} instead.
|
|
493
|
+
// *
|
|
494
|
+
// * @template T Target function type
|
|
495
|
+
// * @param func Target function to validate
|
|
496
|
+
// * @returns The wrapper function with type validations
|
|
497
|
+
// *
|
|
498
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
499
|
+
// */
|
|
500
|
+
// function validateEqualsParameters<T extends (...args: any[]) => any>(
|
|
501
|
+
// func: T,
|
|
502
|
+
// ): T extends (...args: infer Arguments) => infer Output
|
|
503
|
+
// ? Output extends Promise<infer R>
|
|
504
|
+
// ? (...args: Arguments) => Promise<IValidation<R>>
|
|
505
|
+
// : (...args: Arguments) => IValidation<Output>
|
|
506
|
+
// : never;
|
|
492
507
|
|
|
493
|
-
/**
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
function validateEqualsParameters(): never {
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
const validateEqualsParametersPure = /** @__PURE__ */ Object.assign<
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
>(validateEqualsParameters, /** @__PURE__ */ Namespace.validate());
|
|
503
|
-
export { validateEqualsParametersPure as validateEqualsParameters };
|
|
508
|
+
// /**
|
|
509
|
+
// * @internal
|
|
510
|
+
// */
|
|
511
|
+
// function validateEqualsParameters(): never {
|
|
512
|
+
// halt("validateEqualsParameters");
|
|
513
|
+
// }
|
|
514
|
+
// const validateEqualsParametersPure = /** @__PURE__ */ Object.assign<
|
|
515
|
+
// typeof validateEqualsParameters,
|
|
516
|
+
// {}
|
|
517
|
+
// >(validateEqualsParameters, /** @__PURE__ */ Namespace.validate());
|
|
518
|
+
// export { validateEqualsParametersPure as validateEqualsParameters };
|
|
504
519
|
|
|
505
|
-
/**
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
function validateEqualsReturn<T extends (...args:
|
|
532
|
-
|
|
533
|
-
): T extends (...args: infer Arguments) => infer Output
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
520
|
+
// /**
|
|
521
|
+
// * Validates return value with strict equality.
|
|
522
|
+
// *
|
|
523
|
+
// * Validates a function, by wrapping the function and checking its return value through
|
|
524
|
+
// * {@link validateEquals} function. If the return value does not match the expected type,
|
|
525
|
+
// * it returns {@link IValidation.IError} typed object. Otherwise there's no type error,
|
|
526
|
+
// * it returns {@link IValidation.ISuccess} typed object instead.
|
|
527
|
+
// *
|
|
528
|
+
// * For reference, {@link IValidation.IError.path} would be a little bit different with
|
|
529
|
+
// * individual {@link validateEquals} function. If the {@link IValidation.IError} occurs
|
|
530
|
+
// * from the return value, the path would start from `$input.return`.
|
|
531
|
+
// *
|
|
532
|
+
// * By the way, if what you want is not finding every type errors, but just finding
|
|
533
|
+
// * the 1st type error, then use {@link assertEqualsReturn} instead. Otherwise, what you
|
|
534
|
+
// * want is not only validating return value, but also validating parameters, you can use
|
|
535
|
+
// * {@link validateEqualsFunction} instead.
|
|
536
|
+
// *
|
|
537
|
+
// * On the other hand, if you want to allow any superfluous properties, utilize
|
|
538
|
+
// * {@link validateReturn} or {@link assertReturn} instead.
|
|
539
|
+
// *
|
|
540
|
+
// * @template T Target function type
|
|
541
|
+
// * @param func Target function to validate
|
|
542
|
+
// * @returns The wrapper function with type validations
|
|
543
|
+
// *
|
|
544
|
+
// * @author Jeongho Nam - https://github.com/samchon
|
|
545
|
+
// */
|
|
546
|
+
// function validateEqualsReturn<T extends (...args: any[]) => any>(
|
|
547
|
+
// func: T,
|
|
548
|
+
// ): T extends (...args: infer Arguments) => infer Output
|
|
549
|
+
// ? Output extends Promise<infer R>
|
|
550
|
+
// ? (...args: Arguments) => Promise<IValidation<R>>
|
|
551
|
+
// : (...args: Arguments) => IValidation<Output>
|
|
552
|
+
// : never;
|
|
538
553
|
|
|
539
|
-
/**
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
function validateEqualsReturn(): never {
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
const validateEqualsReturnPure = /** @__PURE__ */ Object.assign<
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
>(validateEqualsReturn, /** @__PURE__ */ Namespace.validate());
|
|
549
|
-
export { validateEqualsReturnPure as validateEqualsReturn };
|
|
554
|
+
// /**
|
|
555
|
+
// * @internal
|
|
556
|
+
// */
|
|
557
|
+
// function validateEqualsReturn(): never {
|
|
558
|
+
// halt("validateEqualsReturn");
|
|
559
|
+
// }
|
|
560
|
+
// const validateEqualsReturnPure = /** @__PURE__ */ Object.assign<
|
|
561
|
+
// typeof validateEqualsReturn,
|
|
562
|
+
// {}
|
|
563
|
+
// >(validateEqualsReturn, /** @__PURE__ */ Namespace.validate());
|
|
564
|
+
// export { validateEqualsReturnPure as validateEqualsReturn };
|
|
550
565
|
|
|
551
566
|
/* -----------------------------------------------------------
|
|
552
567
|
HALTER
|
|
@@ -8,7 +8,7 @@ import { IProject } from "../transformers/IProject";
|
|
|
8
8
|
|
|
9
9
|
import { CheckerProgrammer } from "./CheckerProgrammer";
|
|
10
10
|
import { IsProgrammer } from "./IsProgrammer";
|
|
11
|
-
import { FunctionImporter } from "./helpers/
|
|
11
|
+
import { FunctionImporter } from "./helpers/FunctionImporter";
|
|
12
12
|
import { OptionPredicator } from "./helpers/OptionPredicator";
|
|
13
13
|
import { check_object } from "./internal/check_object";
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ import { TransformerError } from "../transformers/TransformerError";
|
|
|
19
19
|
|
|
20
20
|
import { FeatureProgrammer } from "./FeatureProgrammer";
|
|
21
21
|
import { AtomicPredicator } from "./helpers/AtomicPredicator";
|
|
22
|
-
import { FunctionImporter } from "./helpers/
|
|
22
|
+
import { FunctionImporter } from "./helpers/FunctionImporter";
|
|
23
23
|
import { ICheckEntry } from "./helpers/ICheckEntry";
|
|
24
24
|
import { IExpressionEntry } from "./helpers/IExpressionEntry";
|
|
25
25
|
import { OptionPredicator } from "./helpers/OptionPredicator";
|
|
@@ -13,7 +13,7 @@ import { MetadataObject } from "../schemas/metadata/MetadataObject";
|
|
|
13
13
|
import { IProject } from "../transformers/IProject";
|
|
14
14
|
|
|
15
15
|
import { CheckerProgrammer } from "./CheckerProgrammer";
|
|
16
|
-
import { FunctionImporter } from "./helpers/
|
|
16
|
+
import { FunctionImporter } from "./helpers/FunctionImporter";
|
|
17
17
|
import { IExpressionEntry } from "./helpers/IExpressionEntry";
|
|
18
18
|
import { UnionExplorer } from "./helpers/UnionExplorer";
|
|
19
19
|
import { feature_object_entries } from "./internal/feature_object_entries";
|