typia 3.4.6 → 3.4.8
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 +12 -2
- package/lib/executable/internal/CommandParser.d.ts +3 -0
- package/lib/executable/internal/CommandParser.js +21 -0
- package/lib/executable/internal/CommandParser.js.map +1 -0
- package/lib/executable/internal/TypiaSetupWizard.d.ts +2 -2
- package/lib/executable/internal/TypiaSetupWizard.js +57 -35
- package/lib/executable/internal/TypiaSetupWizard.js.map +1 -1
- package/lib/executable/typia.js +22 -21
- package/lib/executable/typia.js.map +1 -1
- package/lib/factories/internal/iterate_metadata.js +1 -1
- package/lib/factories/internal/iterate_metadata.js.map +1 -1
- package/lib/factories/internal/iterate_metadata_tuple.d.ts +1 -1
- package/lib/factories/internal/iterate_metadata_tuple.js +5 -13
- package/lib/factories/internal/iterate_metadata_tuple.js.map +1 -1
- package/package.json +2 -2
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +82 -82
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/internal/CommandParser.ts +15 -0
- package/src/executable/internal/TypiaSetupWizard.ts +108 -87
- package/src/executable/typia.ts +25 -14
- package/src/factories/CommentFactory.ts +10 -10
- package/src/factories/ExpressionFactory.ts +52 -52
- package/src/factories/IdentifierFactory.ts +72 -72
- package/src/factories/LiteralFactory.ts +44 -44
- package/src/factories/MetadataCollection.ts +122 -122
- package/src/factories/MetadataFactory.ts +46 -46
- package/src/factories/StatementFactory.ts +60 -60
- package/src/factories/TemplateFactory.ts +56 -56
- package/src/factories/TypeFactory.ts +101 -101
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/MetadataHelper.ts +12 -12
- package/src/factories/internal/emplace_metadata_object.ts +140 -140
- package/src/factories/internal/explore_metadata.ts +91 -91
- package/src/factories/internal/iterate_metadata.ts +1 -2
- package/src/factories/internal/iterate_metadata_array.ts +29 -29
- package/src/factories/internal/iterate_metadata_atomic.ts +59 -59
- package/src/factories/internal/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/iterate_metadata_map.ts +41 -41
- package/src/factories/internal/iterate_metadata_object.ts +45 -45
- package/src/factories/internal/iterate_metadata_resolve.ts +27 -27
- package/src/factories/internal/iterate_metadata_set.ts +33 -33
- package/src/factories/internal/iterate_metadata_template.ts +38 -38
- package/src/factories/internal/iterate_metadata_tuple.ts +45 -51
- package/src/factories/internal/iterate_metadata_union.ts +59 -59
- package/src/functional/$every.ts +11 -11
- package/src/functional/$guard.ts +35 -35
- package/src/functional/$is_email.ts +5 -5
- package/src/functional/$is_ipv4.ts +5 -5
- package/src/functional/$is_ipv6.ts +5 -5
- package/src/functional/$is_url.ts +5 -5
- package/src/functional/$is_uuid.ts +5 -5
- package/src/functional/$join.ts +50 -50
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +37 -37
- package/src/functional/$tail.ts +6 -6
- package/src/metadata/IJsDocTagInfo.ts +10 -10
- package/src/metadata/IMetadata.ts +25 -25
- package/src/metadata/IMetadataApplication.ts +7 -7
- package/src/metadata/IMetadataConstant.ts +16 -16
- package/src/metadata/IMetadataEntry.ts +6 -6
- package/src/metadata/IMetadataObject.ts +29 -29
- package/src/metadata/IMetadataProperty.ts +11 -11
- package/src/metadata/IMetadataTag.ts +122 -122
- package/src/metadata/Metadata.ts +477 -477
- package/src/metadata/MetadataConstant.ts +3 -3
- package/src/metadata/MetadataObject.ts +131 -131
- package/src/metadata/MetadataProperty.ts +64 -64
- package/src/programmers/AssertParseProgrammer.ts +45 -45
- package/src/programmers/AssertProgrammer.ts +444 -444
- package/src/programmers/AssertStringifyProgrammer.ts +45 -45
- package/src/programmers/CheckerProgrammer.ts +798 -798
- package/src/programmers/FeatureProgrammer.ts +327 -327
- package/src/programmers/IsParseProgrammer.ts +51 -51
- package/src/programmers/IsProgrammer.ts +169 -169
- package/src/programmers/IsStringifyProgrammer.ts +49 -49
- package/src/programmers/ValidateParseProgrammer.ts +49 -49
- package/src/programmers/ValidateProgrammer.ts +236 -236
- package/src/programmers/ValidateStringifyProgrammer.ts +60 -60
- package/src/programmers/helpers/AtomicPredicator.ts +15 -15
- package/src/programmers/helpers/FunctionImporeter.ts +31 -31
- package/src/programmers/helpers/IExpressionEntry.ts +10 -10
- package/src/programmers/helpers/OptionPredicator.ts +18 -18
- package/src/programmers/helpers/StringifyJoinder.ts +111 -111
- package/src/programmers/helpers/StringifyPredicator.ts +18 -18
- package/src/programmers/helpers/UnionExplorer.ts +437 -437
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/internal/application_boolean.ts +17 -17
- package/src/programmers/internal/application_constant.ts +29 -29
- package/src/programmers/internal/application_default_string.ts +32 -32
- package/src/programmers/internal/application_native.ts +29 -29
- package/src/programmers/internal/application_schema.ts +221 -221
- package/src/programmers/internal/application_templates.ts +27 -27
- package/src/programmers/internal/application_tuple.ts +25 -25
- package/src/programmers/internal/check_array.ts +44 -44
- package/src/programmers/internal/check_dynamic_properties.ts +146 -146
- package/src/programmers/internal/check_everything.ts +25 -25
- package/src/programmers/internal/check_length.ts +46 -46
- package/src/programmers/internal/check_native.ts +9 -9
- package/src/programmers/internal/check_number.ts +181 -181
- package/src/programmers/internal/check_object.ts +42 -42
- package/src/programmers/internal/check_string.ts +24 -24
- package/src/programmers/internal/check_string_tags.ts +63 -63
- package/src/programmers/internal/check_template.ts +50 -50
- package/src/programmers/internal/decode_union_object.ts +73 -73
- package/src/programmers/internal/feature_object_entries.ts +49 -49
- package/src/programmers/internal/metadata_to_pattern.ts +31 -31
- package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
- package/src/programmers/internal/stringify_native.ts +8 -8
- package/src/programmers/internal/stringify_regular_properties.ts +81 -81
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/schemas/IJsonApplication.ts +9 -9
- package/src/transform.ts +20 -20
- package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
- package/src/transformers/FileTransformer.ts +49 -49
- package/src/transformers/IProject.ts +11 -11
- package/src/transformers/ITransformOptions.ts +4 -4
- package/src/transformers/NodeTransformer.ts +19 -19
- package/src/typings/Atomic.ts +17 -17
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +49 -49
- package/src/utils/Escaper.ts +50 -50
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PatternUtil.ts +30 -30
- package/src/utils/Singleton.ts +17 -17
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { Writable } from "../../typings/Writable";
|
|
6
|
-
|
|
7
|
-
import { MetadataCollection } from "../MetadataCollection";
|
|
8
|
-
import { MetadataFactory } from "../MetadataFactory";
|
|
9
|
-
import { TypeFactory } from "../TypeFactory";
|
|
10
|
-
import { iterate_metadata } from "./iterate_metadata";
|
|
11
|
-
|
|
12
|
-
export const iterate_metadata_union =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(collection: MetadataCollection) =>
|
|
16
|
-
(meta: Metadata, type: ts.Type, parentResolved: boolean): boolean => {
|
|
17
|
-
if (!type.isUnion()) return false;
|
|
18
|
-
else if (options.resolve === false || parentResolved === true) {
|
|
19
|
-
type.types.forEach((t) =>
|
|
20
|
-
iterate_metadata(checker)(options)(collection)(meta, t, false),
|
|
21
|
-
);
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const filter = (flag: ts.TypeFlags, t: ts.Type) =>
|
|
26
|
-
(t.getFlags() & flag) !== 0;
|
|
27
|
-
const normals: ts.Type[] = [];
|
|
28
|
-
const toJsons: ts.Type[] = [];
|
|
29
|
-
|
|
30
|
-
for (const individual of type.types) {
|
|
31
|
-
if (filter(ts.TypeFlags.Object, individual)) {
|
|
32
|
-
const resolved: ts.Type | null = TypeFactory.resolve(
|
|
33
|
-
checker,
|
|
34
|
-
individual,
|
|
35
|
-
);
|
|
36
|
-
if (resolved !== null) toJsons.push(resolved);
|
|
37
|
-
else normals.push(individual);
|
|
38
|
-
} else normals.push(individual);
|
|
39
|
-
}
|
|
40
|
-
if (toJsons.length !== 0) {
|
|
41
|
-
Writable(meta).resolved = (() => {
|
|
42
|
-
const union: Metadata = Metadata.initialize();
|
|
43
|
-
toJsons.forEach((t) =>
|
|
44
|
-
iterate_metadata(checker)(options)(collection)(
|
|
45
|
-
meta,
|
|
46
|
-
t,
|
|
47
|
-
true,
|
|
48
|
-
),
|
|
49
|
-
);
|
|
50
|
-
if (union.objects.length > 1)
|
|
51
|
-
union.union_index = collection.getUnionIndex(union);
|
|
52
|
-
return union;
|
|
53
|
-
})();
|
|
54
|
-
}
|
|
55
|
-
normals.forEach((t) =>
|
|
56
|
-
iterate_metadata(checker)(options)(collection)(meta, t, false),
|
|
57
|
-
);
|
|
58
|
-
return true;
|
|
59
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { Writable } from "../../typings/Writable";
|
|
6
|
+
|
|
7
|
+
import { MetadataCollection } from "../MetadataCollection";
|
|
8
|
+
import { MetadataFactory } from "../MetadataFactory";
|
|
9
|
+
import { TypeFactory } from "../TypeFactory";
|
|
10
|
+
import { iterate_metadata } from "./iterate_metadata";
|
|
11
|
+
|
|
12
|
+
export const iterate_metadata_union =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(collection: MetadataCollection) =>
|
|
16
|
+
(meta: Metadata, type: ts.Type, parentResolved: boolean): boolean => {
|
|
17
|
+
if (!type.isUnion()) return false;
|
|
18
|
+
else if (options.resolve === false || parentResolved === true) {
|
|
19
|
+
type.types.forEach((t) =>
|
|
20
|
+
iterate_metadata(checker)(options)(collection)(meta, t, false),
|
|
21
|
+
);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const filter = (flag: ts.TypeFlags, t: ts.Type) =>
|
|
26
|
+
(t.getFlags() & flag) !== 0;
|
|
27
|
+
const normals: ts.Type[] = [];
|
|
28
|
+
const toJsons: ts.Type[] = [];
|
|
29
|
+
|
|
30
|
+
for (const individual of type.types) {
|
|
31
|
+
if (filter(ts.TypeFlags.Object, individual)) {
|
|
32
|
+
const resolved: ts.Type | null = TypeFactory.resolve(
|
|
33
|
+
checker,
|
|
34
|
+
individual,
|
|
35
|
+
);
|
|
36
|
+
if (resolved !== null) toJsons.push(resolved);
|
|
37
|
+
else normals.push(individual);
|
|
38
|
+
} else normals.push(individual);
|
|
39
|
+
}
|
|
40
|
+
if (toJsons.length !== 0) {
|
|
41
|
+
Writable(meta).resolved = (() => {
|
|
42
|
+
const union: Metadata = Metadata.initialize();
|
|
43
|
+
toJsons.forEach((t) =>
|
|
44
|
+
iterate_metadata(checker)(options)(collection)(
|
|
45
|
+
meta,
|
|
46
|
+
t,
|
|
47
|
+
true,
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
if (union.objects.length > 1)
|
|
51
|
+
union.union_index = collection.getUnionIndex(union);
|
|
52
|
+
return union;
|
|
53
|
+
})();
|
|
54
|
+
}
|
|
55
|
+
normals.forEach((t) =>
|
|
56
|
+
iterate_metadata(checker)(options)(collection)(meta, t, false),
|
|
57
|
+
);
|
|
58
|
+
return true;
|
|
59
|
+
};
|
package/src/functional/$every.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
export const $every = <T>(
|
|
4
|
-
array: T[],
|
|
5
|
-
pred: (value: T, i: number) => null | Omit<TypeGuardError.IProps, "method">,
|
|
6
|
-
): null | Omit<TypeGuardError.IProps, "method"> => {
|
|
7
|
-
let error: null | Omit<TypeGuardError.IProps, "method"> = null;
|
|
8
|
-
for (let i: number = 0; i < array.length; ++i)
|
|
9
|
-
if (null !== (error = pred(array[i]!, i))) return error;
|
|
10
|
-
return null;
|
|
11
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
export const $every = <T>(
|
|
4
|
+
array: T[],
|
|
5
|
+
pred: (value: T, i: number) => null | Omit<TypeGuardError.IProps, "method">,
|
|
6
|
+
): null | Omit<TypeGuardError.IProps, "method"> => {
|
|
7
|
+
let error: null | Omit<TypeGuardError.IProps, "method"> = null;
|
|
8
|
+
for (let i: number = 0; i < array.length; ++i)
|
|
9
|
+
if (null !== (error = pred(array[i]!, i))) return error;
|
|
10
|
+
return null;
|
|
11
|
+
};
|
package/src/functional/$guard.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
-
|
|
3
|
-
/* -----------------------------------------------------------
|
|
4
|
-
ASSERT V2 -> USE (NULL OR ERROR) CONDITION
|
|
5
|
-
----------------------------------------------------------- */
|
|
6
|
-
// /**
|
|
7
|
-
// * @internal
|
|
8
|
-
// */
|
|
9
|
-
// export const $guardV2 =
|
|
10
|
-
// (method: string) => (props: Omit<TypeGuardError.IProps, "method">) =>
|
|
11
|
-
// new TypeGuardError({
|
|
12
|
-
// method,
|
|
13
|
-
// path: props.path,
|
|
14
|
-
// expected: props.expected,
|
|
15
|
-
// value: props.value,
|
|
16
|
-
// });
|
|
17
|
-
|
|
18
|
-
/* -----------------------------------------------------------
|
|
19
|
-
ASSERT V3 -> (CONDITION OR THROW(exceptable): FALSE)
|
|
20
|
-
----------------------------------------------------------- */
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export const $guard =
|
|
25
|
-
(method: string) =>
|
|
26
|
-
(exceptionable: boolean, props: Omit<TypeGuardError.IProps, "method">) => {
|
|
27
|
-
if (exceptionable === true)
|
|
28
|
-
throw new TypeGuardError({
|
|
29
|
-
method,
|
|
30
|
-
path: props.path,
|
|
31
|
-
expected: props.expected,
|
|
32
|
-
value: props.value,
|
|
33
|
-
});
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
1
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
2
|
+
|
|
3
|
+
/* -----------------------------------------------------------
|
|
4
|
+
ASSERT V2 -> USE (NULL OR ERROR) CONDITION
|
|
5
|
+
----------------------------------------------------------- */
|
|
6
|
+
// /**
|
|
7
|
+
// * @internal
|
|
8
|
+
// */
|
|
9
|
+
// export const $guardV2 =
|
|
10
|
+
// (method: string) => (props: Omit<TypeGuardError.IProps, "method">) =>
|
|
11
|
+
// new TypeGuardError({
|
|
12
|
+
// method,
|
|
13
|
+
// path: props.path,
|
|
14
|
+
// expected: props.expected,
|
|
15
|
+
// value: props.value,
|
|
16
|
+
// });
|
|
17
|
+
|
|
18
|
+
/* -----------------------------------------------------------
|
|
19
|
+
ASSERT V3 -> (CONDITION OR THROW(exceptable): FALSE)
|
|
20
|
+
----------------------------------------------------------- */
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const $guard =
|
|
25
|
+
(method: string) =>
|
|
26
|
+
(exceptionable: boolean, props: Omit<TypeGuardError.IProps, "method">) => {
|
|
27
|
+
if (exceptionable === true)
|
|
28
|
+
throw new TypeGuardError({
|
|
29
|
+
method,
|
|
30
|
+
path: props.path,
|
|
31
|
+
expected: props.expected,
|
|
32
|
+
value: props.value,
|
|
33
|
+
});
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function $is_email(str: string): boolean {
|
|
2
|
-
return REGEX.test(str);
|
|
3
|
-
}
|
|
4
|
-
const REGEX =
|
|
5
|
-
/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
|
|
1
|
+
export function $is_email(str: string): boolean {
|
|
2
|
+
return REGEX.test(str);
|
|
3
|
+
}
|
|
4
|
+
const REGEX =
|
|
5
|
+
/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function $is_ipv4(str: string): boolean {
|
|
2
|
-
return REGEX.test(str);
|
|
3
|
-
}
|
|
4
|
-
const REGEX =
|
|
5
|
-
/^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
1
|
+
export function $is_ipv4(str: string): boolean {
|
|
2
|
+
return REGEX.test(str);
|
|
3
|
+
}
|
|
4
|
+
const REGEX =
|
|
5
|
+
/^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function $is_ipv6(str: string): boolean {
|
|
2
|
-
return REGEX.test(str);
|
|
3
|
-
}
|
|
4
|
-
const REGEX =
|
|
5
|
-
/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
1
|
+
export function $is_ipv6(str: string): boolean {
|
|
2
|
+
return REGEX.test(str);
|
|
3
|
+
}
|
|
4
|
+
const REGEX =
|
|
5
|
+
/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function $is_url(str: string): boolean {
|
|
2
|
-
return REGEX.test(str);
|
|
3
|
-
}
|
|
4
|
-
const REGEX =
|
|
5
|
-
/^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;
|
|
1
|
+
export function $is_url(str: string): boolean {
|
|
2
|
+
return REGEX.test(str);
|
|
3
|
+
}
|
|
4
|
+
const REGEX =
|
|
5
|
+
/^[a-zA-Z0-9]+:\/\/(?:www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function $is_uuid(str: string): boolean {
|
|
2
|
-
return REGEX.test(str);
|
|
3
|
-
}
|
|
4
|
-
const REGEX =
|
|
5
|
-
/[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
|
|
1
|
+
export function $is_uuid(str: string): boolean {
|
|
2
|
+
return REGEX.test(str);
|
|
3
|
+
}
|
|
4
|
+
const REGEX =
|
|
5
|
+
/[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
|
package/src/functional/$join.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
export function $join(str: string): string {
|
|
2
|
-
return variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function variable(str: string): boolean {
|
|
6
|
-
return reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function reserved(str: string): boolean {
|
|
10
|
-
return RESERVED.has(str);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const RESERVED: Set<string> = new Set([
|
|
14
|
-
"break",
|
|
15
|
-
"case",
|
|
16
|
-
"catch",
|
|
17
|
-
"class",
|
|
18
|
-
"const",
|
|
19
|
-
"continue",
|
|
20
|
-
"debugger",
|
|
21
|
-
"default",
|
|
22
|
-
"delete",
|
|
23
|
-
"do",
|
|
24
|
-
"else",
|
|
25
|
-
"enum",
|
|
26
|
-
"export",
|
|
27
|
-
"extends",
|
|
28
|
-
"false",
|
|
29
|
-
"finally",
|
|
30
|
-
"for",
|
|
31
|
-
"function",
|
|
32
|
-
"if",
|
|
33
|
-
"import",
|
|
34
|
-
"in",
|
|
35
|
-
"instanceof",
|
|
36
|
-
"new",
|
|
37
|
-
"null",
|
|
38
|
-
"return",
|
|
39
|
-
"super",
|
|
40
|
-
"switch",
|
|
41
|
-
"this",
|
|
42
|
-
"throw",
|
|
43
|
-
"true",
|
|
44
|
-
"try",
|
|
45
|
-
"typeof",
|
|
46
|
-
"var",
|
|
47
|
-
"void",
|
|
48
|
-
"while",
|
|
49
|
-
"with",
|
|
50
|
-
]);
|
|
1
|
+
export function $join(str: string): string {
|
|
2
|
+
return variable(str) ? `.${str}` : `[${JSON.stringify(str)}]`;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function variable(str: string): boolean {
|
|
6
|
+
return reserved(str) === false && /^[a-zA-Z_$][a-zA-Z_$0-9]*$/g.test(str);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function reserved(str: string): boolean {
|
|
10
|
+
return RESERVED.has(str);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const RESERVED: Set<string> = new Set([
|
|
14
|
+
"break",
|
|
15
|
+
"case",
|
|
16
|
+
"catch",
|
|
17
|
+
"class",
|
|
18
|
+
"const",
|
|
19
|
+
"continue",
|
|
20
|
+
"debugger",
|
|
21
|
+
"default",
|
|
22
|
+
"delete",
|
|
23
|
+
"do",
|
|
24
|
+
"else",
|
|
25
|
+
"enum",
|
|
26
|
+
"export",
|
|
27
|
+
"extends",
|
|
28
|
+
"false",
|
|
29
|
+
"finally",
|
|
30
|
+
"for",
|
|
31
|
+
"function",
|
|
32
|
+
"if",
|
|
33
|
+
"import",
|
|
34
|
+
"in",
|
|
35
|
+
"instanceof",
|
|
36
|
+
"new",
|
|
37
|
+
"null",
|
|
38
|
+
"return",
|
|
39
|
+
"super",
|
|
40
|
+
"switch",
|
|
41
|
+
"this",
|
|
42
|
+
"throw",
|
|
43
|
+
"true",
|
|
44
|
+
"try",
|
|
45
|
+
"typeof",
|
|
46
|
+
"var",
|
|
47
|
+
"void",
|
|
48
|
+
"while",
|
|
49
|
+
"with",
|
|
50
|
+
]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IValidation } from "../IValidation";
|
|
2
|
-
|
|
3
|
-
export const $report = (array: IValidation.IError[]) => {
|
|
4
|
-
const reportable = (path: string): boolean => {
|
|
5
|
-
if (array.length === 0) return true;
|
|
6
|
-
const last: string = array[array.length - 1]!.path;
|
|
7
|
-
return (
|
|
8
|
-
path.length > last.length || last.substring(0, path.length) !== path
|
|
9
|
-
);
|
|
10
|
-
};
|
|
11
|
-
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
12
|
-
if (exceptable && reportable(error.path)) array.push(error);
|
|
13
|
-
return false;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
1
|
+
import { IValidation } from "../IValidation";
|
|
2
|
+
|
|
3
|
+
export const $report = (array: IValidation.IError[]) => {
|
|
4
|
+
const reportable = (path: string): boolean => {
|
|
5
|
+
if (array.length === 0) return true;
|
|
6
|
+
const last: string = array[array.length - 1]!.path;
|
|
7
|
+
return (
|
|
8
|
+
path.length > last.length || last.substring(0, path.length) !== path
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
12
|
+
if (exceptable && reportable(error.path)) array.push(error);
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
};
|
package/src/functional/$rest.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function $rest(str: string): string {
|
|
2
|
-
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
-
}
|
|
1
|
+
export function $rest(str: string): string {
|
|
2
|
+
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export function $string(str: string): string {
|
|
5
|
-
if (str.length > 41) return JSON.stringify(str);
|
|
6
|
-
|
|
7
|
-
const length = str.length;
|
|
8
|
-
let result = "";
|
|
9
|
-
let last = 0;
|
|
10
|
-
let found = false;
|
|
11
|
-
let surrogateFound = false;
|
|
12
|
-
let point = 255;
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line
|
|
15
|
-
for (let i = 0; i < length && point >= 32; i++) {
|
|
16
|
-
point = str.charCodeAt(i);
|
|
17
|
-
if (0xd800 <= point && point <= 0xdfff) {
|
|
18
|
-
// The current character is a surrogate.
|
|
19
|
-
surrogateFound = true;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
if (point === 34 || point === 92) {
|
|
23
|
-
result += str.slice(last, i) + "\\";
|
|
24
|
-
last = i;
|
|
25
|
-
found = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!found) {
|
|
30
|
-
result = str;
|
|
31
|
-
} else {
|
|
32
|
-
result += str.slice(last);
|
|
33
|
-
}
|
|
34
|
-
return point < 32 || surrogateFound === true
|
|
35
|
-
? JSON.stringify(str)
|
|
36
|
-
: `"${result}"`;
|
|
37
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export function $string(str: string): string {
|
|
5
|
+
if (str.length > 41) return JSON.stringify(str);
|
|
6
|
+
|
|
7
|
+
const length = str.length;
|
|
8
|
+
let result = "";
|
|
9
|
+
let last = 0;
|
|
10
|
+
let found = false;
|
|
11
|
+
let surrogateFound = false;
|
|
12
|
+
let point = 255;
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line
|
|
15
|
+
for (let i = 0; i < length && point >= 32; i++) {
|
|
16
|
+
point = str.charCodeAt(i);
|
|
17
|
+
if (0xd800 <= point && point <= 0xdfff) {
|
|
18
|
+
// The current character is a surrogate.
|
|
19
|
+
surrogateFound = true;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if (point === 34 || point === 92) {
|
|
23
|
+
result += str.slice(last, i) + "\\";
|
|
24
|
+
last = i;
|
|
25
|
+
found = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!found) {
|
|
30
|
+
result = str;
|
|
31
|
+
} else {
|
|
32
|
+
result += str.slice(last);
|
|
33
|
+
}
|
|
34
|
+
return point < 32 || surrogateFound === true
|
|
35
|
+
? JSON.stringify(str)
|
|
36
|
+
: `"${result}"`;
|
|
37
|
+
}
|
package/src/functional/$tail.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export function $tail(str: string): string {
|
|
5
|
-
return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
|
|
6
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export function $tail(str: string): string {
|
|
5
|
+
return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
|
|
6
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export interface IJsDocTagInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
text?: IJsDocTagInfo.IText[];
|
|
4
|
-
}
|
|
5
|
-
export namespace IJsDocTagInfo {
|
|
6
|
-
export interface IText {
|
|
7
|
-
text: string;
|
|
8
|
-
kind: string;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
export interface IJsDocTagInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
text?: IJsDocTagInfo.IText[];
|
|
4
|
+
}
|
|
5
|
+
export namespace IJsDocTagInfo {
|
|
6
|
+
export interface IText {
|
|
7
|
+
text: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Atomic } from "../typings/Atomic";
|
|
2
|
-
|
|
3
|
-
import { IMetadataConstant } from "./IMetadataConstant";
|
|
4
|
-
import { IMetadataEntry } from "./IMetadataEntry";
|
|
5
|
-
|
|
6
|
-
export interface IMetadata {
|
|
7
|
-
any: boolean;
|
|
8
|
-
required: boolean;
|
|
9
|
-
nullable: boolean;
|
|
10
|
-
functional: boolean;
|
|
11
|
-
|
|
12
|
-
atomics: Atomic.Literal[];
|
|
13
|
-
constants: IMetadataConstant[];
|
|
14
|
-
templates: IMetadata[][];
|
|
15
|
-
resolved: IMetadata | null;
|
|
16
|
-
|
|
17
|
-
rest: IMetadata | null;
|
|
18
|
-
arrays: IMetadata[];
|
|
19
|
-
tuples: IMetadata[][];
|
|
20
|
-
objects: string[];
|
|
21
|
-
|
|
22
|
-
natives: string[];
|
|
23
|
-
sets: IMetadata[];
|
|
24
|
-
maps: IMetadataEntry[];
|
|
25
|
-
}
|
|
1
|
+
import { Atomic } from "../typings/Atomic";
|
|
2
|
+
|
|
3
|
+
import { IMetadataConstant } from "./IMetadataConstant";
|
|
4
|
+
import { IMetadataEntry } from "./IMetadataEntry";
|
|
5
|
+
|
|
6
|
+
export interface IMetadata {
|
|
7
|
+
any: boolean;
|
|
8
|
+
required: boolean;
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
functional: boolean;
|
|
11
|
+
|
|
12
|
+
atomics: Atomic.Literal[];
|
|
13
|
+
constants: IMetadataConstant[];
|
|
14
|
+
templates: IMetadata[][];
|
|
15
|
+
resolved: IMetadata | null;
|
|
16
|
+
|
|
17
|
+
rest: IMetadata | null;
|
|
18
|
+
arrays: IMetadata[];
|
|
19
|
+
tuples: IMetadata[][];
|
|
20
|
+
objects: string[];
|
|
21
|
+
|
|
22
|
+
natives: string[];
|
|
23
|
+
sets: IMetadata[];
|
|
24
|
+
maps: IMetadataEntry[];
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IMetadata } from "./IMetadata";
|
|
2
|
-
import { IMetadataObject } from "./IMetadataObject";
|
|
3
|
-
|
|
4
|
-
export interface IMetadataApplication {
|
|
5
|
-
metadatas: IMetadata[];
|
|
6
|
-
collection: IMetadataObject[];
|
|
7
|
-
}
|
|
1
|
+
import { IMetadata } from "./IMetadata";
|
|
2
|
+
import { IMetadataObject } from "./IMetadataObject";
|
|
3
|
+
|
|
4
|
+
export interface IMetadataApplication {
|
|
5
|
+
metadatas: IMetadata[];
|
|
6
|
+
collection: IMetadataObject[];
|
|
7
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Atomic } from "../typings/Atomic";
|
|
2
|
-
|
|
3
|
-
export type IMetadataConstant =
|
|
4
|
-
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
|
-
| IMetadataConstant.IBase<"number", number>
|
|
6
|
-
| IMetadataConstant.IBase<"string", string>
|
|
7
|
-
| IMetadataConstant.IBase<"bigint", bigint>;
|
|
8
|
-
export namespace IMetadataConstant {
|
|
9
|
-
export interface IBase<
|
|
10
|
-
Type extends Atomic.Literal,
|
|
11
|
-
Value extends Atomic.Type,
|
|
12
|
-
> {
|
|
13
|
-
type: Type;
|
|
14
|
-
values: Value[];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { Atomic } from "../typings/Atomic";
|
|
2
|
+
|
|
3
|
+
export type IMetadataConstant =
|
|
4
|
+
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
|
+
| IMetadataConstant.IBase<"number", number>
|
|
6
|
+
| IMetadataConstant.IBase<"string", string>
|
|
7
|
+
| IMetadataConstant.IBase<"bigint", bigint>;
|
|
8
|
+
export namespace IMetadataConstant {
|
|
9
|
+
export interface IBase<
|
|
10
|
+
Type extends Atomic.Literal,
|
|
11
|
+
Value extends Atomic.Type,
|
|
12
|
+
> {
|
|
13
|
+
type: Type;
|
|
14
|
+
values: Value[];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IMetadata } from "./IMetadata";
|
|
2
|
-
|
|
3
|
-
export interface IMetadataEntry {
|
|
4
|
-
key: IMetadata;
|
|
5
|
-
value: IMetadata;
|
|
6
|
-
}
|
|
1
|
+
import { IMetadata } from "./IMetadata";
|
|
2
|
+
|
|
3
|
+
export interface IMetadataEntry {
|
|
4
|
+
key: IMetadata;
|
|
5
|
+
value: IMetadata;
|
|
6
|
+
}
|