typia 3.5.0-dev.20230212 → 3.5.0-dev.20230214
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/README.md +15 -1
- package/lib/IRandomGenerator.d.ts +15 -0
- package/lib/IRandomGenerator.js +3 -0
- package/lib/IRandomGenerator.js.map +1 -0
- package/lib/factories/ExpressionFactory.d.ts +1 -0
- package/lib/factories/ExpressionFactory.js +4 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/MetadataFactory.js +15 -5
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +11 -101
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/functional/$any.d.ts +1 -0
- package/lib/functional/$any.js +8 -0
- package/lib/functional/$any.js.map +1 -0
- package/lib/{programmers/internal/check_length.d.ts → functional/Namespace.d.ts} +0 -0
- package/lib/functional/Namespace.js +80 -0
- package/lib/functional/Namespace.js.map +1 -0
- package/lib/metadata/IMetadataTag.d.ts +3 -10
- package/lib/module.d.ts +255 -0
- package/lib/module.js +77 -234
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertCloneProgrammer.d.ts +5 -0
- package/lib/programmers/AssertCloneProgrammer.js +37 -0
- package/lib/programmers/AssertCloneProgrammer.js.map +1 -0
- package/lib/programmers/CloneProgrammer.d.ts +5 -0
- package/lib/programmers/CloneProgrammer.js +285 -0
- package/lib/programmers/CloneProgrammer.js.map +1 -0
- package/lib/programmers/IsCloneProgrammer.d.ts +5 -0
- package/lib/programmers/IsCloneProgrammer.js +37 -0
- package/lib/programmers/IsCloneProgrammer.js.map +1 -0
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.js +5 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.d.ts +5 -0
- package/lib/programmers/RandomProgrammer.js +338 -0
- package/lib/programmers/RandomProgrammer.js.map +1 -0
- package/lib/programmers/StringifyProgrammer.js +1 -1
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateCloneProgrammer.d.ts +5 -0
- package/lib/programmers/ValidateCloneProgrammer.js +37 -0
- package/lib/programmers/ValidateCloneProgrammer.js.map +1 -0
- package/lib/programmers/ValidateStringifyProgrammer.js +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -1
- package/lib/programmers/helpers/CloneJoiner.d.ts +8 -0
- package/lib/programmers/helpers/CloneJoiner.js +80 -0
- package/lib/programmers/helpers/CloneJoiner.js.map +1 -0
- package/lib/programmers/helpers/RandomJoiner.d.ts +10 -0
- package/lib/programmers/helpers/RandomJoiner.js +93 -0
- package/lib/programmers/helpers/RandomJoiner.js.map +1 -0
- package/lib/programmers/helpers/RandomRanger.d.ts +25 -0
- package/lib/programmers/helpers/RandomRanger.js +138 -0
- package/lib/programmers/helpers/RandomRanger.js.map +1 -0
- package/lib/programmers/helpers/StringifyJoinder.js +2 -2
- package/lib/programmers/helpers/StringifyJoinder.js.map +1 -1
- package/lib/programmers/internal/application_array.js +0 -10
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_number.js +4 -12
- package/lib/programmers/internal/application_number.js.map +1 -1
- package/lib/programmers/internal/application_string.js +0 -8
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array_length.js +3 -4
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_bigint.js +0 -12
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_number.js +7 -25
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string_tags.js +2 -3
- package/lib/programmers/internal/check_string_tags.js.map +1 -1
- package/lib/schemas/IJsonSchema.d.ts +36 -2
- package/lib/transformers/CallExpressionTransformer.js +21 -1
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CloneTransformer.js +34 -0
- package/lib/transformers/features/miscellaneous/CloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +29 -0
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/RandomTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +35 -0
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/AssertParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/AssertParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/IsParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/IsParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/ValidateParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/ValidateParseTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js.map +1 -1
- package/lib/transformers/features/validators/CreateAssertTransformer.js +2 -1
- package/lib/transformers/features/validators/CreateAssertTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateIsTransformer.js +2 -1
- package/lib/transformers/features/validators/CreateIsTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateValidateTransformer.js +2 -1
- package/lib/transformers/features/validators/CreateValidateTransformer.js.map +1 -1
- package/lib/utils/RandomGenerator.d.ts +1 -0
- package/lib/utils/RandomGenerator.js +85 -0
- package/lib/utils/RandomGenerator.js.map +1 -0
- package/package.json +8 -3
- package/src/IRandomGenerator.ts +16 -0
- package/src/factories/ExpressionFactory.ts +11 -0
- package/src/factories/MetadataFactory.ts +18 -14
- package/src/factories/MetadataTagFactory.ts +11 -97
- package/src/functional/$any.ts +3 -0
- package/src/functional/Namespace.ts +121 -0
- package/src/metadata/IMetadataTag.ts +2 -11
- package/src/module.ts +390 -350
- package/src/programmers/AssertCloneProgrammer.ts +60 -0
- package/src/programmers/CloneProgrammer.ts +351 -0
- package/src/programmers/IsCloneProgrammer.ts +66 -0
- package/src/programmers/IsProgrammer.ts +8 -5
- package/src/programmers/RandomProgrammer.ts +367 -0
- package/src/programmers/StringifyProgrammer.ts +2 -4
- package/src/programmers/ValidateCloneProgrammer.ts +77 -0
- package/src/programmers/ValidateStringifyProgrammer.ts +1 -4
- package/src/programmers/helpers/CloneJoiner.ts +124 -0
- package/src/programmers/helpers/RandomJoiner.ts +140 -0
- package/src/programmers/helpers/RandomRanger.ts +215 -0
- package/src/programmers/helpers/StringifyJoinder.ts +4 -4
- package/src/programmers/internal/application_array.ts +0 -10
- package/src/programmers/internal/application_number.ts +7 -13
- package/src/programmers/internal/application_string.ts +0 -8
- package/src/programmers/internal/check_array_length.ts +8 -9
- package/src/programmers/internal/check_bigint.ts +0 -21
- package/src/programmers/internal/check_number.ts +0 -30
- package/src/programmers/internal/check_string_tags.ts +7 -7
- package/src/schemas/IJsonSchema.ts +36 -1
- package/src/transformers/CallExpressionTransformer.ts +24 -1
- package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +38 -0
- package/src/transformers/features/miscellaneous/CloneTransformer.ts +46 -0
- package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +31 -0
- package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +39 -0
- package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +38 -0
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +45 -0
- package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +38 -0
- package/src/transformers/features/parsers/AssertParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/IsParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +1 -1
- package/src/transformers/features/validators/CreateAssertTransformer.ts +1 -1
- package/src/transformers/features/validators/CreateIsTransformer.ts +1 -1
- package/src/transformers/features/validators/CreateValidateTransformer.ts +1 -1
- package/src/utils/RandomGenerator.ts +90 -0
- package/lib/programmers/internal/check_length.js +0 -28
- package/lib/programmers/internal/check_length.js.map +0 -1
- package/src/programmers/internal/check_length.ts +0 -46
package/src/module.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $guard } from "./functional/$guard";
|
|
3
|
-
import { $is_between } from "./functional/$is_between";
|
|
4
|
-
import { $is_email } from "./functional/$is_email";
|
|
5
|
-
import { $is_ipv4 } from "./functional/$is_ipv4";
|
|
6
|
-
import { $is_ipv6 } from "./functional/$is_ipv6";
|
|
7
|
-
import { $is_url } from "./functional/$is_url";
|
|
8
|
-
import { $is_uuid } from "./functional/$is_uuid";
|
|
9
|
-
import { $join } from "./functional/$join";
|
|
10
|
-
import { $number } from "./functional/$number";
|
|
11
|
-
import { $report } from "./functional/$report";
|
|
12
|
-
import { $rest } from "./functional/$rest";
|
|
13
|
-
import { $string } from "./functional/$string";
|
|
14
|
-
import { $tail } from "./functional/$tail";
|
|
1
|
+
import { Namespace } from "./functional/Namespace";
|
|
15
2
|
|
|
16
3
|
import { IMetadataApplication } from "./metadata/IMetadataApplication";
|
|
17
4
|
import { IJsonApplication } from "./schemas/IJsonApplication";
|
|
18
5
|
|
|
19
6
|
import { IValidation } from "./IValidation";
|
|
7
|
+
import { Primitive } from "./Primitive";
|
|
20
8
|
import { TypeGuardError } from "./TypeGuardError";
|
|
21
9
|
|
|
22
10
|
export * from "./schemas/IJsonApplication";
|
|
@@ -87,22 +75,7 @@ export function assert<T>(input: unknown): T;
|
|
|
87
75
|
export function assert(): never {
|
|
88
76
|
halt("assert");
|
|
89
77
|
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
94
|
-
export namespace assert {
|
|
95
|
-
export const is_uuid = $is_uuid;
|
|
96
|
-
export const is_email = $is_email;
|
|
97
|
-
export const is_url = $is_url;
|
|
98
|
-
export const is_ipv4 = $is_ipv4;
|
|
99
|
-
export const is_ipv6 = $is_ipv6;
|
|
100
|
-
export const is_between = $is_between;
|
|
101
|
-
|
|
102
|
-
export const join = $join;
|
|
103
|
-
export const every = $every;
|
|
104
|
-
export const guard = $guard("typia.assert");
|
|
105
|
-
}
|
|
78
|
+
Object.assign(assert, Namespace.assert("assert"));
|
|
106
79
|
|
|
107
80
|
/**
|
|
108
81
|
* Asserts a value type.
|
|
@@ -140,26 +113,7 @@ export function assertType<T>(input: unknown): T;
|
|
|
140
113
|
export function assertType(): never {
|
|
141
114
|
halt("assertType");
|
|
142
115
|
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
export namespace assertType {
|
|
148
|
-
// FOR LEGACY FUNCTIONS
|
|
149
|
-
export function predicate(
|
|
150
|
-
matched: boolean,
|
|
151
|
-
exceptionable: boolean,
|
|
152
|
-
closure: () => Omit<TypeGuardError.IProps, "method">,
|
|
153
|
-
): boolean {
|
|
154
|
-
if (matched === false && exceptionable === true)
|
|
155
|
-
throw new TypeGuardError({
|
|
156
|
-
method: "typia.assertType",
|
|
157
|
-
...closure(),
|
|
158
|
-
});
|
|
159
|
-
return matched;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
Object.assign(assertType, assert);
|
|
116
|
+
Object.assign(assertType, Namespace.assert("assertType"));
|
|
163
117
|
|
|
164
118
|
/**
|
|
165
119
|
* Tests a value type.
|
|
@@ -215,18 +169,7 @@ export function is<T>(input: unknown): input is T;
|
|
|
215
169
|
export function is(): never {
|
|
216
170
|
halt("is");
|
|
217
171
|
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
export namespace is {
|
|
223
|
-
export const is_uuid = $is_uuid;
|
|
224
|
-
export const is_email = $is_email;
|
|
225
|
-
export const is_url = $is_url;
|
|
226
|
-
export const is_ipv4 = $is_ipv4;
|
|
227
|
-
export const is_ipv6 = $is_ipv6;
|
|
228
|
-
export const is_between = $is_between;
|
|
229
|
-
}
|
|
172
|
+
Object.assign(is, Namespace.assert("is"));
|
|
230
173
|
|
|
231
174
|
/**
|
|
232
175
|
* Validates a value type.
|
|
@@ -284,51 +227,7 @@ export function validate<T>(input: unknown): IValidation<T>;
|
|
|
284
227
|
export function validate(): never {
|
|
285
228
|
halt("validate");
|
|
286
229
|
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @internal
|
|
290
|
-
*/
|
|
291
|
-
export namespace validate {
|
|
292
|
-
export const is_uuid = $is_uuid;
|
|
293
|
-
export const is_email = $is_email;
|
|
294
|
-
export const is_url = $is_url;
|
|
295
|
-
export const is_ipv4 = $is_ipv4;
|
|
296
|
-
export const is_ipv6 = $is_ipv6;
|
|
297
|
-
export const is_between = $is_between;
|
|
298
|
-
|
|
299
|
-
export const join = $join;
|
|
300
|
-
export const report = $report;
|
|
301
|
-
|
|
302
|
-
// FOR LEGACY FUNCTIONS
|
|
303
|
-
export const predicate =
|
|
304
|
-
(res: IValidation) =>
|
|
305
|
-
(
|
|
306
|
-
matched: boolean,
|
|
307
|
-
exceptionable: boolean,
|
|
308
|
-
closure: () => IValidation.IError,
|
|
309
|
-
) => {
|
|
310
|
-
// CHECK FAILURE
|
|
311
|
-
if (matched === false && exceptionable === true)
|
|
312
|
-
(() => {
|
|
313
|
-
res.success &&= false;
|
|
314
|
-
const errorList = (res as IValidation.IFailure).errors;
|
|
315
|
-
|
|
316
|
-
// TRACE ERROR
|
|
317
|
-
const error = closure();
|
|
318
|
-
if (errorList.length) {
|
|
319
|
-
const last = errorList[errorList.length - 1]!.path;
|
|
320
|
-
if (
|
|
321
|
-
last.length >= error.path.length &&
|
|
322
|
-
last.substring(0, error.path.length) === error.path
|
|
323
|
-
)
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
errorList.push(error);
|
|
327
|
-
return;
|
|
328
|
-
})();
|
|
329
|
-
return matched;
|
|
330
|
-
};
|
|
331
|
-
}
|
|
230
|
+
Object.assign(validate, Namespace.validate());
|
|
332
231
|
|
|
333
232
|
/* -----------------------------------------------------------
|
|
334
233
|
STRICT VALIDATORS
|
|
@@ -386,40 +285,10 @@ export function assertEquals<T>(input: unknown): T;
|
|
|
386
285
|
/**
|
|
387
286
|
* @internal
|
|
388
287
|
*/
|
|
389
|
-
export function assertEquals
|
|
288
|
+
export function assertEquals(): never {
|
|
390
289
|
halt("assertEquals");
|
|
391
290
|
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* @internal
|
|
395
|
-
*/
|
|
396
|
-
export namespace assertEquals {
|
|
397
|
-
export const is_uuid = $is_uuid;
|
|
398
|
-
export const is_email = $is_email;
|
|
399
|
-
export const is_url = $is_url;
|
|
400
|
-
export const is_ipv4 = $is_ipv4;
|
|
401
|
-
export const is_ipv6 = $is_ipv6;
|
|
402
|
-
export const is_between = $is_between;
|
|
403
|
-
|
|
404
|
-
export const join = $join;
|
|
405
|
-
export const every = $every;
|
|
406
|
-
// export const guardV2 = $guardV2("typia.assertEquals");
|
|
407
|
-
export const guard = $guard("typia.assertEquals");
|
|
408
|
-
|
|
409
|
-
// FOR LEGACY FUNCTIONS
|
|
410
|
-
export function predicate(
|
|
411
|
-
matched: boolean,
|
|
412
|
-
exceptionable: boolean,
|
|
413
|
-
closure: () => Omit<TypeGuardError.IProps, "method">,
|
|
414
|
-
): boolean {
|
|
415
|
-
if (matched === false && exceptionable === true)
|
|
416
|
-
throw new TypeGuardError({
|
|
417
|
-
method: "typia.assertEquals",
|
|
418
|
-
...closure(),
|
|
419
|
-
});
|
|
420
|
-
return matched;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
291
|
+
Object.assign(assertEquals, Namespace.assert("assertEquals"));
|
|
423
292
|
|
|
424
293
|
/**
|
|
425
294
|
* Tests equality between a value and its type.
|
|
@@ -477,19 +346,7 @@ export function equals<T>(input: unknown): input is T;
|
|
|
477
346
|
export function equals(): never {
|
|
478
347
|
halt("equals");
|
|
479
348
|
}
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* @internal
|
|
483
|
-
*/
|
|
484
|
-
export namespace equals {
|
|
485
|
-
export const is_uuid = $is_uuid;
|
|
486
|
-
export const is_email = $is_email;
|
|
487
|
-
export const is_url = $is_url;
|
|
488
|
-
export const is_ipv4 = $is_ipv4;
|
|
489
|
-
export const is_ipv6 = $is_ipv6;
|
|
490
|
-
export const is_between = $is_between;
|
|
491
|
-
export const join = $join;
|
|
492
|
-
}
|
|
349
|
+
Object.assign(equals, Namespace.is());
|
|
493
350
|
|
|
494
351
|
/**
|
|
495
352
|
* Validates equality between a value and its type.
|
|
@@ -549,51 +406,7 @@ export function validateEquals<T>(input: unknown): IValidation<T>;
|
|
|
549
406
|
export function validateEquals(): never {
|
|
550
407
|
halt("validateEquals");
|
|
551
408
|
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* @internal
|
|
555
|
-
*/
|
|
556
|
-
export namespace validateEquals {
|
|
557
|
-
export const is_uuid = $is_uuid;
|
|
558
|
-
export const is_email = $is_email;
|
|
559
|
-
export const is_url = $is_url;
|
|
560
|
-
export const is_ipv4 = $is_ipv4;
|
|
561
|
-
export const is_ipv6 = $is_ipv6;
|
|
562
|
-
export const is_between = $is_between;
|
|
563
|
-
export const join = $join;
|
|
564
|
-
|
|
565
|
-
export const report = validate.report;
|
|
566
|
-
|
|
567
|
-
// FOR LEGACY FUNCTIONS
|
|
568
|
-
export const predicate =
|
|
569
|
-
(res: IValidation) =>
|
|
570
|
-
(
|
|
571
|
-
matched: boolean,
|
|
572
|
-
exceptionable: boolean,
|
|
573
|
-
closure: () => IValidation.IError,
|
|
574
|
-
) => {
|
|
575
|
-
// CHECK FAILURE
|
|
576
|
-
if (matched === false && exceptionable === true)
|
|
577
|
-
(() => {
|
|
578
|
-
res.success &&= false;
|
|
579
|
-
const errorList = (res as IValidation.IFailure).errors;
|
|
580
|
-
|
|
581
|
-
// TRACE ERROR
|
|
582
|
-
const error = closure();
|
|
583
|
-
if (errorList.length) {
|
|
584
|
-
const last = errorList[errorList.length - 1]!.path;
|
|
585
|
-
if (
|
|
586
|
-
last.length >= error.path.length &&
|
|
587
|
-
last.substring(0, error.path.length) === error.path
|
|
588
|
-
)
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
errorList.push(error);
|
|
592
|
-
return;
|
|
593
|
-
})();
|
|
594
|
-
return matched;
|
|
595
|
-
};
|
|
596
|
-
}
|
|
409
|
+
Object.assign(validateEquals, Namespace.validate());
|
|
597
410
|
|
|
598
411
|
/* -----------------------------------------------------------
|
|
599
412
|
JSON FUNCTIONS
|
|
@@ -707,22 +520,7 @@ export function assertParse<T>(input: string): T;
|
|
|
707
520
|
export function assertParse<T>(): T {
|
|
708
521
|
halt("assertParse");
|
|
709
522
|
}
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* @internal
|
|
713
|
-
*/
|
|
714
|
-
export namespace assertParse {
|
|
715
|
-
export const is_uuid = $is_uuid;
|
|
716
|
-
export const is_email = $is_email;
|
|
717
|
-
export const is_url = $is_url;
|
|
718
|
-
export const is_ipv4 = $is_ipv4;
|
|
719
|
-
export const is_ipv6 = $is_ipv6;
|
|
720
|
-
export const is_between = $is_between;
|
|
721
|
-
|
|
722
|
-
export const join = $join;
|
|
723
|
-
export const every = $every;
|
|
724
|
-
export const guard = $guard("typia.assertParse");
|
|
725
|
-
}
|
|
523
|
+
Object.assign(assertParse, Namespace.assert("assertParse"));
|
|
726
524
|
|
|
727
525
|
/**
|
|
728
526
|
* > You must configure the generic argument `T`.
|
|
@@ -852,25 +650,7 @@ export function stringify<T>(input: T): string;
|
|
|
852
650
|
export function stringify(): never {
|
|
853
651
|
halt("stringify");
|
|
854
652
|
}
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* @internal
|
|
858
|
-
*/
|
|
859
|
-
export namespace stringify {
|
|
860
|
-
export const number = $number;
|
|
861
|
-
export const string = $string;
|
|
862
|
-
export const tail = $tail;
|
|
863
|
-
export const rest = $rest;
|
|
864
|
-
|
|
865
|
-
export function throws(
|
|
866
|
-
props: Pick<TypeGuardError.IProps, "expected" | "value">,
|
|
867
|
-
): void {
|
|
868
|
-
throw new TypeGuardError({
|
|
869
|
-
...props,
|
|
870
|
-
method: "typia.stringify",
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
}
|
|
653
|
+
Object.assign(stringify, Namespace.stringify("stringify"));
|
|
874
654
|
|
|
875
655
|
/**
|
|
876
656
|
* 5x faster `JSON.stringify()` function with type assertion.
|
|
@@ -924,42 +704,8 @@ export function assertStringify<T>(input: T): unknown;
|
|
|
924
704
|
export function assertStringify(): string {
|
|
925
705
|
halt("assertStringify");
|
|
926
706
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
* @internal
|
|
930
|
-
*/
|
|
931
|
-
export namespace assertStringify {
|
|
932
|
-
export const is_uuid = $is_uuid;
|
|
933
|
-
export const is_email = $is_email;
|
|
934
|
-
export const is_url = $is_url;
|
|
935
|
-
export const is_ipv4 = $is_ipv4;
|
|
936
|
-
export const is_ipv6 = $is_ipv6;
|
|
937
|
-
export const is_between = $is_between;
|
|
938
|
-
|
|
939
|
-
export const number = $number;
|
|
940
|
-
export const string = $string;
|
|
941
|
-
export const tail = $tail;
|
|
942
|
-
export const rest = $rest;
|
|
943
|
-
|
|
944
|
-
export const join = $join;
|
|
945
|
-
export const guard = $guard("typia.assertStringify");
|
|
946
|
-
export const every = $every;
|
|
947
|
-
export const throws = () => {};
|
|
948
|
-
|
|
949
|
-
// FOR LEGACY FUNCTIONS
|
|
950
|
-
export function predicate(
|
|
951
|
-
matched: boolean,
|
|
952
|
-
exceptionable: boolean,
|
|
953
|
-
closure: () => Omit<TypeGuardError.IProps, "method">,
|
|
954
|
-
): boolean {
|
|
955
|
-
if (matched === false && exceptionable === true)
|
|
956
|
-
throw new TypeGuardError({
|
|
957
|
-
method: "typia.assertStringify",
|
|
958
|
-
...closure(),
|
|
959
|
-
});
|
|
960
|
-
return matched;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
707
|
+
Object.assign(assertStringify, Namespace.assert("assertStringify"));
|
|
708
|
+
Object.assign(assertStringify, Namespace.stringify("assertStringify"));
|
|
963
709
|
|
|
964
710
|
/**
|
|
965
711
|
* 7x faster `JSON.stringify()` function with type checking.
|
|
@@ -1010,28 +756,12 @@ export function isStringify<T>(input: unknown): string | null;
|
|
|
1010
756
|
/**
|
|
1011
757
|
* @internal
|
|
1012
758
|
*/
|
|
1013
|
-
export function isStringify
|
|
759
|
+
export function isStringify(): string | null {
|
|
1014
760
|
halt("isStringify");
|
|
1015
761
|
}
|
|
1016
762
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
*/
|
|
1020
|
-
export namespace isStringify {
|
|
1021
|
-
export const is_uuid = $is_uuid;
|
|
1022
|
-
export const is_email = $is_email;
|
|
1023
|
-
export const is_url = $is_url;
|
|
1024
|
-
export const is_ipv4 = $is_ipv4;
|
|
1025
|
-
export const is_ipv6 = $is_ipv6;
|
|
1026
|
-
export const is_between = $is_between;
|
|
1027
|
-
|
|
1028
|
-
export const number = $number;
|
|
1029
|
-
export const string = $string;
|
|
1030
|
-
export const tail = $tail;
|
|
1031
|
-
export const rest = $rest;
|
|
1032
|
-
|
|
1033
|
-
export const throws = () => {};
|
|
1034
|
-
}
|
|
763
|
+
Object.assign(isStringify, Namespace.is());
|
|
764
|
+
Object.assign(isStringify, Namespace.stringify("isStringify"));
|
|
1035
765
|
|
|
1036
766
|
/**
|
|
1037
767
|
* 5x faster `JSON.stringify()` function with detailed type validation.
|
|
@@ -1087,12 +817,17 @@ export function validateStringify<T>(input: unknown): IValidation<string>;
|
|
|
1087
817
|
export function validateStringify(): IValidation<string> {
|
|
1088
818
|
halt("validateStringify");
|
|
1089
819
|
}
|
|
1090
|
-
Object.assign(validateStringify, validate);
|
|
1091
|
-
Object.assign(validateStringify, stringify);
|
|
820
|
+
Object.assign(validateStringify, Namespace.validate());
|
|
821
|
+
Object.assign(validateStringify, Namespace.stringify("validateStringify"));
|
|
1092
822
|
|
|
1093
823
|
/* -----------------------------------------------------------
|
|
1094
824
|
MISCELLANEOUS
|
|
1095
825
|
----------------------------------------------------------- */
|
|
826
|
+
/**
|
|
827
|
+
* @internal
|
|
828
|
+
*/
|
|
829
|
+
export function metadata(): never;
|
|
830
|
+
|
|
1096
831
|
/**
|
|
1097
832
|
* @internal
|
|
1098
833
|
*/
|
|
@@ -1105,6 +840,217 @@ export function metadata(): never {
|
|
|
1105
840
|
halt("metadata");
|
|
1106
841
|
}
|
|
1107
842
|
|
|
843
|
+
/**
|
|
844
|
+
* > You must configure the generic argument `T`.
|
|
845
|
+
*
|
|
846
|
+
* Generate random data.
|
|
847
|
+
*
|
|
848
|
+
* Generates a random data following type the `T`.
|
|
849
|
+
*
|
|
850
|
+
* For reference, this `typia.random()` function generates only primitive type.
|
|
851
|
+
* If there're some methods in the type `T` or its nested instances, those would
|
|
852
|
+
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
853
|
+
* would be generated instead.
|
|
854
|
+
*
|
|
855
|
+
* @template T Type of data to generate
|
|
856
|
+
* @return Randomly generated data
|
|
857
|
+
*
|
|
858
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
859
|
+
*/
|
|
860
|
+
export function random(): never;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Generate random data.
|
|
864
|
+
*
|
|
865
|
+
* Generates a random data following type the `T`.
|
|
866
|
+
*
|
|
867
|
+
* For reference, this `typia.random()` function generates only primitive type.
|
|
868
|
+
* If there're some methods in the type `T` or its nested instances, those would
|
|
869
|
+
* be ignored. Also, when the type `T` has a `toJSON()` method, its return type
|
|
870
|
+
* would be generated instead.
|
|
871
|
+
*
|
|
872
|
+
* @template T Type of data to generate
|
|
873
|
+
* @return Randomly generated data
|
|
874
|
+
*
|
|
875
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
876
|
+
*/
|
|
877
|
+
export function random<T>(): Primitive<T>;
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* @internal
|
|
881
|
+
*/
|
|
882
|
+
export function random(): never {
|
|
883
|
+
halt("random");
|
|
884
|
+
}
|
|
885
|
+
Object.assign(random, Namespace.random());
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Clone a data.
|
|
889
|
+
*
|
|
890
|
+
* Clones an instance following type `T`. If the target *input* value or its member
|
|
891
|
+
* variable contains a class instance that is having a `toJSON()` method, its return
|
|
892
|
+
* value would be cloned.
|
|
893
|
+
*
|
|
894
|
+
* For reference, this `typia.clone()` function does not validate the input value type.
|
|
895
|
+
* It just believes that the input value is following the type `T`. Therefore, if you
|
|
896
|
+
* can't ensure the input value type, it would be better to call {@link assertClone}
|
|
897
|
+
* function instead.
|
|
898
|
+
*
|
|
899
|
+
* @template T Type of the input value
|
|
900
|
+
* @param input A value to be cloned
|
|
901
|
+
* @return Cloned data
|
|
902
|
+
*
|
|
903
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
904
|
+
*/
|
|
905
|
+
export function clone<T>(input: T): Primitive<T>;
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* @internal
|
|
909
|
+
*/
|
|
910
|
+
export function clone(): never {
|
|
911
|
+
halt("clone");
|
|
912
|
+
}
|
|
913
|
+
Object.assign(clone, Namespace.clone("clone"));
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Clone a data with type assertion.
|
|
917
|
+
*
|
|
918
|
+
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
919
|
+
* value or its member variable contains a class instance that is having a `toJSON()`
|
|
920
|
+
* method, its return value would be cloned.
|
|
921
|
+
*
|
|
922
|
+
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
923
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
924
|
+
* data would be returned.
|
|
925
|
+
*
|
|
926
|
+
* @template T Type of the input value
|
|
927
|
+
* @param input A value to be cloned
|
|
928
|
+
* @return Cloned data
|
|
929
|
+
*
|
|
930
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
931
|
+
*/
|
|
932
|
+
export function assertClone<T>(input: T): Primitive<T>;
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Clone a data with type assertion.
|
|
936
|
+
*
|
|
937
|
+
* Clones an instance following type `T`, with type assertion. If the target `input`
|
|
938
|
+
* value or its member variable contains a class instance that is having a `toJSON()`
|
|
939
|
+
* method, its return value would be cloned.
|
|
940
|
+
*
|
|
941
|
+
* In such reason, when `input` value is not matched with the type `T`, it throws an
|
|
942
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, cloned
|
|
943
|
+
* data would be returned.
|
|
944
|
+
*
|
|
945
|
+
* @template T Type of the input value
|
|
946
|
+
* @param input A value to be cloned
|
|
947
|
+
* @return Cloned data
|
|
948
|
+
*
|
|
949
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
950
|
+
*/
|
|
951
|
+
export function assertClone<T>(input: unknown): Primitive<T>;
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* @internal
|
|
955
|
+
*/
|
|
956
|
+
export function assertClone(): never {
|
|
957
|
+
halt("assertClone");
|
|
958
|
+
}
|
|
959
|
+
Object.assign(assertClone, Namespace.assert("assertClone"));
|
|
960
|
+
Object.assign(assertClone, Namespace.clone("assertClone"));
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Clone a data with type checking.
|
|
964
|
+
*
|
|
965
|
+
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
966
|
+
* value or its member variable contains a class instance that is having a `toJSON()`
|
|
967
|
+
* method, its return value would be cloned.
|
|
968
|
+
*
|
|
969
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
970
|
+
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
971
|
+
* data would be returned.
|
|
972
|
+
*
|
|
973
|
+
* @template T Type of the input value
|
|
974
|
+
* @param input A value to be cloned
|
|
975
|
+
* @return Cloned data when exact type, otherwise null
|
|
976
|
+
*
|
|
977
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
978
|
+
*/
|
|
979
|
+
export function isClone<T>(input: T): Primitive<T> | null;
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Clone a data with type checking.
|
|
983
|
+
*
|
|
984
|
+
* Clones an instance following type `T`, with type checking. If the target `input`
|
|
985
|
+
* value or its member variable contains a class instance that is having a `toJSON()`
|
|
986
|
+
* method, its return value would be cloned.
|
|
987
|
+
*
|
|
988
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
989
|
+
* `null` value instead. Otherwise, there's no problem on the `input` value, cloned
|
|
990
|
+
* data would be returned.
|
|
991
|
+
*
|
|
992
|
+
* @template T Type of the input value
|
|
993
|
+
* @param input A value to be cloned
|
|
994
|
+
* @return Cloned data when exact type, otherwise null
|
|
995
|
+
*
|
|
996
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
997
|
+
*/
|
|
998
|
+
export function isClone<T>(input: unknown): Primitive<T> | null;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* @internal
|
|
1002
|
+
*/
|
|
1003
|
+
export function isClone(): never {
|
|
1004
|
+
halt("isClone");
|
|
1005
|
+
}
|
|
1006
|
+
Object.assign(isClone, Namespace.is());
|
|
1007
|
+
Object.assign(isClone, Namespace.clone("isClone"));
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Clone a data with detailed type validation.
|
|
1011
|
+
*
|
|
1012
|
+
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
1013
|
+
* `input` value or its member variable contains a class instance that is having a
|
|
1014
|
+
* `toJSON()` method, its return value would be cloned.
|
|
1015
|
+
*
|
|
1016
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
1017
|
+
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
1018
|
+
* value, cloned data would be stored in `data` property of the output
|
|
1019
|
+
* {@link IValidation.Success} instance.
|
|
1020
|
+
*
|
|
1021
|
+
* @template T Type of the input value
|
|
1022
|
+
* @param input A value to be cloned
|
|
1023
|
+
* @returns Validation result with cloned value
|
|
1024
|
+
*/
|
|
1025
|
+
export function validateClone<T>(input: T): IValidation<Primitive<T>>;
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Clone a data with detailed type validation.
|
|
1029
|
+
*
|
|
1030
|
+
* Clones an instance following type `T`, with detailed type validation. If the target
|
|
1031
|
+
* `input` value or its member variable contains a class instance that is having a
|
|
1032
|
+
* `toJSON()` method, its return value would be cloned.
|
|
1033
|
+
*
|
|
1034
|
+
* In such reason, when `input` value is not matched with the type `T`, it returns
|
|
1035
|
+
* {@link IValidation.Failure} value. Otherwise, there's no problem on the `input`
|
|
1036
|
+
* value, cloned data would be stored in `data` property of the output
|
|
1037
|
+
* {@link IValidation.Success} instance.
|
|
1038
|
+
*
|
|
1039
|
+
* @template T Type of the input value
|
|
1040
|
+
* @param input A value to be cloned
|
|
1041
|
+
* @returns Validation result with cloned value
|
|
1042
|
+
*/
|
|
1043
|
+
export function validateClone<T>(input: unknown): IValidation<Primitive<T>>;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* @internal
|
|
1047
|
+
*/
|
|
1048
|
+
export function validateClone(): never {
|
|
1049
|
+
halt("validateClone");
|
|
1050
|
+
}
|
|
1051
|
+
Object.assign(validateClone, Namespace.validate());
|
|
1052
|
+
Object.assign(validateClone, Namespace.clone("validateClone"));
|
|
1053
|
+
|
|
1108
1054
|
/**
|
|
1109
1055
|
* Prune, erase superfluous properties.
|
|
1110
1056
|
*
|
|
@@ -1134,27 +1080,7 @@ export function prune<T extends object>(input: T): void;
|
|
|
1134
1080
|
export function prune(): never {
|
|
1135
1081
|
halt("prune");
|
|
1136
1082
|
}
|
|
1137
|
-
|
|
1138
|
-
/**
|
|
1139
|
-
* @internal
|
|
1140
|
-
*/
|
|
1141
|
-
export namespace prune {
|
|
1142
|
-
export const is_uuid = $is_uuid;
|
|
1143
|
-
export const is_email = $is_email;
|
|
1144
|
-
export const is_url = $is_url;
|
|
1145
|
-
export const is_ipv4 = $is_ipv4;
|
|
1146
|
-
export const is_ipv6 = $is_ipv6;
|
|
1147
|
-
export const is_between = $is_between;
|
|
1148
|
-
|
|
1149
|
-
export function throws(
|
|
1150
|
-
props: Pick<TypeGuardError.IProps, "expected" | "value">,
|
|
1151
|
-
): void {
|
|
1152
|
-
throw new TypeGuardError({
|
|
1153
|
-
...props,
|
|
1154
|
-
method: "typia.prune",
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1083
|
+
Object.assign(prune, Namespace.prune("prune"));
|
|
1158
1084
|
|
|
1159
1085
|
/**
|
|
1160
1086
|
* Prune, erase superfluous properties, with type assertion.
|
|
@@ -1195,25 +1121,11 @@ export function assertPrune<T>(input: unknown): T;
|
|
|
1195
1121
|
/**
|
|
1196
1122
|
* @internal
|
|
1197
1123
|
*/
|
|
1198
|
-
export function assertPrune
|
|
1124
|
+
export function assertPrune(): unknown {
|
|
1199
1125
|
halt("assertPrune");
|
|
1200
1126
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
* @internal
|
|
1204
|
-
*/
|
|
1205
|
-
export namespace assertPrune {
|
|
1206
|
-
export const is_uuid = $is_uuid;
|
|
1207
|
-
export const is_email = $is_email;
|
|
1208
|
-
export const is_url = $is_url;
|
|
1209
|
-
export const is_ipv4 = $is_ipv4;
|
|
1210
|
-
export const is_ipv6 = $is_ipv6;
|
|
1211
|
-
export const is_between = $is_between;
|
|
1212
|
-
|
|
1213
|
-
export const join = $join;
|
|
1214
|
-
export const every = $every;
|
|
1215
|
-
export const guard = $guard("typia.assertPrune");
|
|
1216
|
-
}
|
|
1127
|
+
Object.assign(assertPrune, Namespace.assert("assertPrune"));
|
|
1128
|
+
Object.assign(assertPrune, Namespace.prune("assertPrune"));
|
|
1217
1129
|
|
|
1218
1130
|
/**
|
|
1219
1131
|
* Prune, erase superfluous properties, with type checking.
|
|
@@ -1259,27 +1171,8 @@ export function isPrune<T>(input: unknown): input is T;
|
|
|
1259
1171
|
export function isPrune(): never {
|
|
1260
1172
|
halt("isPrune");
|
|
1261
1173
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
* @internal
|
|
1265
|
-
*/
|
|
1266
|
-
export namespace isPrune {
|
|
1267
|
-
export const is_uuid = $is_uuid;
|
|
1268
|
-
export const is_email = $is_email;
|
|
1269
|
-
export const is_url = $is_url;
|
|
1270
|
-
export const is_ipv4 = $is_ipv4;
|
|
1271
|
-
export const is_ipv6 = $is_ipv6;
|
|
1272
|
-
export const is_between = $is_between;
|
|
1273
|
-
|
|
1274
|
-
export function throws(
|
|
1275
|
-
props: Pick<TypeGuardError.IProps, "expected" | "value">,
|
|
1276
|
-
): void {
|
|
1277
|
-
throw new TypeGuardError({
|
|
1278
|
-
...props,
|
|
1279
|
-
method: "typia.prune",
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1174
|
+
Object.assign(isPrune, Namespace.is());
|
|
1175
|
+
Object.assign(isPrune, Namespace.prune("isPrune"));
|
|
1283
1176
|
|
|
1284
1177
|
/**
|
|
1285
1178
|
* Prune, erase superfluous properties, with type validation.
|
|
@@ -1327,8 +1220,8 @@ export function validatePrune<T>(input: unknown): IValidation<T>;
|
|
|
1327
1220
|
export function validatePrune<T>(): IValidation<T> {
|
|
1328
1221
|
halt("validatePrune");
|
|
1329
1222
|
}
|
|
1330
|
-
Object.assign(validatePrune, prune);
|
|
1331
|
-
Object.assign(validatePrune, validate);
|
|
1223
|
+
Object.assign(validatePrune, Namespace.prune("validatePrune"));
|
|
1224
|
+
Object.assign(validatePrune, Namespace.validate());
|
|
1332
1225
|
|
|
1333
1226
|
/* ===========================================================
|
|
1334
1227
|
FACTORY FUNCTIONS
|
|
@@ -1764,6 +1657,153 @@ Object.assign(createValidateStringify, validateStringify);
|
|
|
1764
1657
|
/* -----------------------------------------------------------
|
|
1765
1658
|
MISCELLANEOUS
|
|
1766
1659
|
----------------------------------------------------------- */
|
|
1660
|
+
/**
|
|
1661
|
+
* Creates a reusable {@link random} function.
|
|
1662
|
+
*
|
|
1663
|
+
* @danger You have to specify the generic argument `T`
|
|
1664
|
+
* @return Nothing until specifying the generic argument `T`
|
|
1665
|
+
* @throws compile error
|
|
1666
|
+
*
|
|
1667
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1668
|
+
*/
|
|
1669
|
+
export function createRandom(): never;
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* Creates a resuable {@link random} function.
|
|
1673
|
+
*
|
|
1674
|
+
* @template T Type of the input value
|
|
1675
|
+
* @returns A reusable `random` function
|
|
1676
|
+
*
|
|
1677
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1678
|
+
*/
|
|
1679
|
+
export function createRandom<T>(): () => Primitive<T>;
|
|
1680
|
+
|
|
1681
|
+
/**
|
|
1682
|
+
* @internal
|
|
1683
|
+
*/
|
|
1684
|
+
export function createRandom(): never {
|
|
1685
|
+
halt("createRandom");
|
|
1686
|
+
}
|
|
1687
|
+
Object.assign(createRandom, random);
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* Creates a reusable {@link clone} function.
|
|
1691
|
+
*
|
|
1692
|
+
* @danger You have to specify the generic argument `T`
|
|
1693
|
+
* @return Nothing until specifying the generic argument `T`
|
|
1694
|
+
* @throws compile error
|
|
1695
|
+
*
|
|
1696
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1697
|
+
*/
|
|
1698
|
+
export function createClone(): never;
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Creates a resuable {@link clone} function.
|
|
1702
|
+
*
|
|
1703
|
+
* @template T Type of the input value
|
|
1704
|
+
* @returns A reusable `clone` function
|
|
1705
|
+
*
|
|
1706
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1707
|
+
*/
|
|
1708
|
+
export function createClone<T>(): (input: T) => Primitive<T>;
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* @internal
|
|
1712
|
+
*/
|
|
1713
|
+
export function createClone(): never {
|
|
1714
|
+
halt("createClone");
|
|
1715
|
+
}
|
|
1716
|
+
Object.assign(createClone, clone);
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* Creates a reusable {@link assertClone} function.
|
|
1720
|
+
*
|
|
1721
|
+
* @danger You have to specify the generic argument `T`
|
|
1722
|
+
* @return Nothing until specifying the generic argument `T`
|
|
1723
|
+
* @throws compile error
|
|
1724
|
+
*
|
|
1725
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1726
|
+
*/
|
|
1727
|
+
export function createAssertClone(): never;
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* Creates a resuable {@link assertClone} function.
|
|
1731
|
+
*
|
|
1732
|
+
* @template T Type of the input value
|
|
1733
|
+
* @returns A reusable `clone` function
|
|
1734
|
+
*
|
|
1735
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1736
|
+
*/
|
|
1737
|
+
export function createAssertClone<T>(): (input: unknown) => Primitive<T>;
|
|
1738
|
+
|
|
1739
|
+
/**
|
|
1740
|
+
* @internal
|
|
1741
|
+
*/
|
|
1742
|
+
export function createAssertClone(): never {
|
|
1743
|
+
halt("createAssertClone");
|
|
1744
|
+
}
|
|
1745
|
+
Object.assign(createAssertClone, assertClone);
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Creates a reusable {@link isClone} function.
|
|
1749
|
+
*
|
|
1750
|
+
* @danger You have to specify the generic argument `T`
|
|
1751
|
+
* @return Nothing until specifying the generic argument `T`
|
|
1752
|
+
* @throws compile error
|
|
1753
|
+
*
|
|
1754
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1755
|
+
*/
|
|
1756
|
+
export function createIsClone(): never;
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* Creates a resuable {@link isClone} function.
|
|
1760
|
+
*
|
|
1761
|
+
* @template T Type of the input value
|
|
1762
|
+
* @returns A reusable `clone` function
|
|
1763
|
+
*
|
|
1764
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1765
|
+
*/
|
|
1766
|
+
export function createIsClone<T>(): (input: unknown) => Primitive<T> | null;
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* @internal
|
|
1770
|
+
*/
|
|
1771
|
+
export function createIsClone(): never {
|
|
1772
|
+
halt("createIsClone");
|
|
1773
|
+
}
|
|
1774
|
+
Object.assign(createIsClone, isClone);
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* Creates a reusable {@link validateClone} function.
|
|
1778
|
+
*
|
|
1779
|
+
* @danger You have to specify the generic argument `T`
|
|
1780
|
+
* @return Nothing until specifying the generic argument `T`
|
|
1781
|
+
* @throws compile error
|
|
1782
|
+
*
|
|
1783
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1784
|
+
*/
|
|
1785
|
+
export function createValidateClone(): never;
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Creates a resuable {@link validateClone} function.
|
|
1789
|
+
*
|
|
1790
|
+
* @template T Type of the input value
|
|
1791
|
+
* @returns A reusable `clone` function
|
|
1792
|
+
*
|
|
1793
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
1794
|
+
*/
|
|
1795
|
+
export function createValidateClone<T>(): (
|
|
1796
|
+
input: unknown,
|
|
1797
|
+
) => IValidation<Primitive<T>>;
|
|
1798
|
+
|
|
1799
|
+
/**
|
|
1800
|
+
* @internal
|
|
1801
|
+
*/
|
|
1802
|
+
export function createValidateClone(): never {
|
|
1803
|
+
halt("createValidateClone");
|
|
1804
|
+
}
|
|
1805
|
+
Object.assign(createValidateClone, validateClone);
|
|
1806
|
+
|
|
1767
1807
|
/**
|
|
1768
1808
|
* Creates a reusable {@link prune} function.
|
|
1769
1809
|
*
|