typia 13.1.19 → 13.2.0
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/executable/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +24 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -2
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +14 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +33 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +0 -9
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomFormatByte.ts +30 -3
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +21 -3
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +45 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -3,11 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._randomFormatIpv4 = void 0;
|
|
4
4
|
const _randomInteger_1 = require("./_randomInteger");
|
|
5
5
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
6
|
-
const
|
|
6
|
+
const __randomComposition_1 = require("./private/__randomComposition");
|
|
7
|
+
const _randomFormatIpv4 = (props) => {
|
|
8
|
+
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
9
|
+
return new Array(4).fill(0).map(random).join(".");
|
|
10
|
+
// Three dots plus four octets of one to three digits: `0.0.0.0` is the
|
|
11
|
+
// shortest address and `255.255.255.255` the longest, and every length
|
|
12
|
+
// between them is reached by choosing how many digits each octet spends.
|
|
13
|
+
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, {
|
|
14
|
+
minimum: 4 * DIGITS_MIN + DOTS,
|
|
15
|
+
maximum: 4 * DIGITS_MAX + DOTS,
|
|
16
|
+
spread: 8,
|
|
17
|
+
}));
|
|
18
|
+
return (0, __randomComposition_1.__randomComposition)({
|
|
19
|
+
total: length - DOTS,
|
|
20
|
+
count: 4,
|
|
21
|
+
minimum: DIGITS_MIN,
|
|
22
|
+
maximum: DIGITS_MAX,
|
|
23
|
+
})
|
|
24
|
+
.map(octet)
|
|
25
|
+
.join(".");
|
|
26
|
+
};
|
|
7
27
|
exports._randomFormatIpv4 = _randomFormatIpv4;
|
|
28
|
+
const DOTS = 3;
|
|
29
|
+
const DIGITS_MIN = 1;
|
|
30
|
+
const DIGITS_MAX = 3;
|
|
8
31
|
const random = () => (0, _randomInteger_1._randomInteger)({
|
|
9
32
|
type: "integer",
|
|
10
33
|
minimum: 0,
|
|
11
34
|
maximum: 255,
|
|
12
35
|
});
|
|
36
|
+
// An octet is bounded by 255, so a three-digit one starts at 100 and stops
|
|
37
|
+
// there rather than at 999.
|
|
38
|
+
const octet = (digits) => String((0, _randomInteger_1._randomInteger)({
|
|
39
|
+
type: "integer",
|
|
40
|
+
minimum: digits === 1 ? 0 : Math.pow(10, digits - 1),
|
|
41
|
+
maximum: digits === 3 ? 255 : Math.pow(10, digits) - 1,
|
|
42
|
+
}));
|
|
13
43
|
//# sourceMappingURL=_randomFormatIpv4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatIpv4.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv4.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+
|
|
1
|
+
{"version":3,"file":"_randomFormatIpv4.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv4.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAI+B;AAC/B,uEAAoE;AAE7D,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACjE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,uEAAuE;IACvE,uEAAuE;IACvE,yEAAyE;IACzE,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE;QACzB,OAAO,EAAE,CAAC,GAAG,UAAU,GAAG,IAAI;QAC9B,OAAO,EAAE,CAAC,GAAG,UAAU,GAAG,IAAI;QAC9B,MAAM,EAAE,CAAC;KACV,CAAC,CACH,CAAC;IACF,OAAO,IAAA,yCAAmB,EAAC;QACzB,KAAK,EAAE,MAAM,GAAG,IAAI;QACpB,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,UAAU;KACpB,CAAC;SACC,GAAG,CAAC,KAAK,CAAC;SACV,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC;AArBW,QAAA,iBAAiB,GAAjB,iBAAiB,CAqB5B;AAEF,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,IAAA,+BAAc,EAAC;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,GAAG;CACb,CAAC,CAAC;AAEL,2EAA2E;AAC3E,4BAA4B;AAC5B,MAAM,KAAK,GAAG,CAAC,MAAc,EAAU,EAAE,CACvC,MAAM,CACJ,IAAA,+BAAc,EAAC;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IACpD,OAAO,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;CACvD,CAAC,CACH,CAAC"}
|
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { _randomInteger } from "./_randomInteger.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
|
|
3
|
+
import { __randomComposition } from "./private/__randomComposition.mjs";
|
|
3
4
|
//#region src/internal/_randomFormatIpv4.ts
|
|
4
|
-
const _randomFormatIpv4 = (props) =>
|
|
5
|
+
const _randomFormatIpv4 = (props) => {
|
|
6
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return new Array(4).fill(0).map(random).join(".");
|
|
7
|
+
return __randomComposition({
|
|
8
|
+
total: _randomLengthPick(_randomLengthWindow(props, {
|
|
9
|
+
minimum: 4 * DIGITS_MIN + DOTS,
|
|
10
|
+
maximum: 4 * DIGITS_MAX + DOTS,
|
|
11
|
+
spread: 8
|
|
12
|
+
})) - DOTS,
|
|
13
|
+
count: 4,
|
|
14
|
+
minimum: DIGITS_MIN,
|
|
15
|
+
maximum: DIGITS_MAX
|
|
16
|
+
}).map(octet).join(".");
|
|
17
|
+
};
|
|
18
|
+
const DOTS = 3;
|
|
19
|
+
const DIGITS_MIN = 1;
|
|
20
|
+
const DIGITS_MAX = 3;
|
|
5
21
|
const random = () => _randomInteger({
|
|
6
22
|
type: "integer",
|
|
7
23
|
minimum: 0,
|
|
8
24
|
maximum: 255
|
|
9
25
|
});
|
|
26
|
+
const octet = (digits) => String(_randomInteger({
|
|
27
|
+
type: "integer",
|
|
28
|
+
minimum: digits === 1 ? 0 : Math.pow(10, digits - 1),
|
|
29
|
+
maximum: digits === 3 ? 255 : Math.pow(10, digits) - 1
|
|
30
|
+
}));
|
|
10
31
|
//#endregion
|
|
11
32
|
export { _randomFormatIpv4 };
|
|
12
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatIpv4.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv4.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {
|
|
1
|
+
{"version":3,"file":"_randomFormatIpv4.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv4.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomComposition } from \"./private/__randomComposition\";\n\nexport const _randomFormatIpv4 = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return new Array(4).fill(0).map(random).join(\".\");\n // Three dots plus four octets of one to three digits: `0.0.0.0` is the\n // shortest address and `255.255.255.255` the longest, and every length\n // between them is reached by choosing how many digits each octet spends.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, {\n minimum: 4 * DIGITS_MIN + DOTS,\n maximum: 4 * DIGITS_MAX + DOTS,\n spread: 8,\n }),\n );\n return __randomComposition({\n total: length - DOTS,\n count: 4,\n minimum: DIGITS_MIN,\n maximum: DIGITS_MAX,\n })\n .map(octet)\n .join(\".\");\n};\n\nconst DOTS = 3;\nconst DIGITS_MIN = 1;\nconst DIGITS_MAX = 3;\n\nconst random = () =>\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 255,\n });\n\n// An octet is bounded by 255, so a three-digit one starts at 100 and stops\n// there rather than at 999.\nconst octet = (digits: number): string =>\n String(\n _randomInteger({\n type: \"integer\",\n minimum: digits === 1 ? 0 : Math.pow(10, digits - 1),\n maximum: digits === 3 ? 255 : Math.pow(10, digits) - 1,\n }),\n );\n"],"mappings":";;;;AAQA,MAAa,qBAAqB,UAAkC;CAClE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG;CAWlD,OAAO,oBAAoB;EACzB,OARqB,kBACrB,oBAAoB,OAAO;GACzB,SAAS,IAAI,aAAa;GAC1B,SAAS,IAAI,aAAa;GAC1B,QAAQ;EACV,CAAC,CAGW,IAAI;EAChB,OAAO;EACP,SAAS;EACT,SAAS;CACX,CAAC,CAAC,CACC,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;AACb;AAEA,MAAM,OAAO;AACb,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,eACJ,eAAe;CACb,MAAM;CACN,SAAS;CACT,SAAS;AACX,CAAC;AAIH,MAAM,SAAS,WACb,OACE,eAAe;CACb,MAAM;CACN,SAAS,WAAW,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,CAAC;CACnD,SAAS,WAAW,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI;AACvD,CAAC,CACH"}
|
|
@@ -1,13 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._randomFormatIpv6 = void 0;
|
|
4
|
+
const _randomFormatIpv4_1 = require("./_randomFormatIpv4");
|
|
4
5
|
const _randomInteger_1 = require("./_randomInteger");
|
|
5
6
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
6
|
-
const
|
|
7
|
+
const __randomComposition_1 = require("./private/__randomComposition");
|
|
8
|
+
const _randomFormatIpv6 = (props) => {
|
|
9
|
+
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
10
|
+
return new Array(GROUPS).fill(0).map(random).join(":");
|
|
11
|
+
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, {
|
|
12
|
+
minimum: SHORTEST,
|
|
13
|
+
maximum: LONGEST,
|
|
14
|
+
spread: 12,
|
|
15
|
+
}));
|
|
16
|
+
// `::` alone is the all-zero address, and the three forms below cover every
|
|
17
|
+
// length between it and the padded IPv4-suffixed address: a compressed prefix
|
|
18
|
+
// for the short ones, eight groups of one to four hexadecimal digits for the
|
|
19
|
+
// middle, and six groups plus a dotted-quad tail for the long ones.
|
|
20
|
+
if (length === SHORTEST)
|
|
21
|
+
return "::";
|
|
22
|
+
if (length < GROUPS * DIGITS_MIN + COLONS) {
|
|
23
|
+
// `::` plus `count` groups spends one colon between each pair.
|
|
24
|
+
const count = Math.ceil((length - 1) / (DIGITS_MAX + 1));
|
|
25
|
+
return `::${compose(length - 1 - count, count)}`;
|
|
26
|
+
}
|
|
27
|
+
if (length <= GROUPS * DIGITS_MAX + COLONS)
|
|
28
|
+
return compose(length - COLONS, GROUPS);
|
|
29
|
+
// The dotted-quad tail is drawn at its longest so the six leading groups keep
|
|
30
|
+
// a composable number of digits.
|
|
31
|
+
const tail = (0, _randomFormatIpv4_1._randomFormatIpv4)({
|
|
32
|
+
minLength: IPV4_MAX,
|
|
33
|
+
maxLength: IPV4_MAX,
|
|
34
|
+
});
|
|
35
|
+
return `${compose(length - IPV4_MAX - EMBEDDED, EMBEDDED)}:${tail}`;
|
|
36
|
+
};
|
|
7
37
|
exports._randomFormatIpv6 = _randomFormatIpv6;
|
|
38
|
+
const GROUPS = 8;
|
|
39
|
+
const COLONS = GROUPS - 1;
|
|
40
|
+
const DIGITS_MIN = 1;
|
|
41
|
+
const DIGITS_MAX = 4;
|
|
42
|
+
const EMBEDDED = 6; // groups preceding a dotted-quad tail
|
|
43
|
+
const IPV4_MAX = "255.255.255.255".length;
|
|
44
|
+
const SHORTEST = "::".length;
|
|
45
|
+
const LONGEST = EMBEDDED * DIGITS_MAX + EMBEDDED + IPV4_MAX;
|
|
46
|
+
const compose = (digits, count) => (0, __randomComposition_1.__randomComposition)({
|
|
47
|
+
total: digits,
|
|
48
|
+
count,
|
|
49
|
+
minimum: DIGITS_MIN,
|
|
50
|
+
maximum: DIGITS_MAX,
|
|
51
|
+
})
|
|
52
|
+
.map(group)
|
|
53
|
+
.join(":");
|
|
8
54
|
const random = () => (0, _randomInteger_1._randomInteger)({
|
|
9
55
|
type: "integer",
|
|
10
56
|
minimum: 0,
|
|
11
57
|
maximum: 65535,
|
|
12
58
|
}).toString(16);
|
|
59
|
+
const group = (digits) => {
|
|
60
|
+
let text = "";
|
|
61
|
+
for (let i = 0; i < digits; ++i)
|
|
62
|
+
text += (0, _randomInteger_1._randomInteger)({
|
|
63
|
+
type: "integer",
|
|
64
|
+
minimum: 0,
|
|
65
|
+
maximum: 15,
|
|
66
|
+
}).toString(16);
|
|
67
|
+
return text;
|
|
68
|
+
};
|
|
13
69
|
//# sourceMappingURL=_randomFormatIpv6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatIpv6.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv6.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+
|
|
1
|
+
{"version":3,"file":"_randomFormatIpv6.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv6.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AACxD,qDAAkD;AAClD,+DAI+B;AAC/B,uEAAoE;AAE7D,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACjE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE;QACzB,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,EAAE;KACX,CAAC,CACH,CAAC;IACF,4EAA4E;IAC5E,8EAA8E;IAC9E,6EAA6E;IAC7E,oEAAoE;IACpE,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,EAAE,CAAC;QAC1C,+DAA+D;QAC/D,MAAM,KAAK,GAAW,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;QACjE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;IACnD,CAAC;IACD,IAAI,MAAM,IAAI,MAAM,GAAG,UAAU,GAAG,MAAM;QACxC,OAAO,OAAO,CAAC,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AI,GAAW,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,IAAA,+BAAc,EAAC;YACrB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1,12 +1,55 @@
|
|
|
1
1
|
import { _randomInteger } from "./_randomInteger.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
|
|
3
|
+
import { __randomComposition } from "./private/__randomComposition.mjs";
|
|
4
|
+
import { _randomFormatIpv4 } from "./_randomFormatIpv4.mjs";
|
|
3
5
|
//#region src/internal/_randomFormatIpv6.ts
|
|
4
|
-
const _randomFormatIpv6 = (props) =>
|
|
6
|
+
const _randomFormatIpv6 = (props) => {
|
|
7
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return new Array(GROUPS).fill(0).map(random).join(":");
|
|
8
|
+
const length = _randomLengthPick(_randomLengthWindow(props, {
|
|
9
|
+
minimum: SHORTEST,
|
|
10
|
+
maximum: LONGEST,
|
|
11
|
+
spread: 12
|
|
12
|
+
}));
|
|
13
|
+
if (length === SHORTEST) return "::";
|
|
14
|
+
if (length < GROUPS * DIGITS_MIN + COLONS) {
|
|
15
|
+
const count = Math.ceil((length - 1) / (DIGITS_MAX + 1));
|
|
16
|
+
return `::${compose(length - 1 - count, count)}`;
|
|
17
|
+
}
|
|
18
|
+
if (length <= GROUPS * DIGITS_MAX + COLONS) return compose(length - COLONS, GROUPS);
|
|
19
|
+
const tail = _randomFormatIpv4({
|
|
20
|
+
minLength: IPV4_MAX,
|
|
21
|
+
maxLength: IPV4_MAX
|
|
22
|
+
});
|
|
23
|
+
return `${compose(length - IPV4_MAX - EMBEDDED, EMBEDDED)}:${tail}`;
|
|
24
|
+
};
|
|
25
|
+
const GROUPS = 8;
|
|
26
|
+
const COLONS = GROUPS - 1;
|
|
27
|
+
const DIGITS_MIN = 1;
|
|
28
|
+
const DIGITS_MAX = 4;
|
|
29
|
+
const EMBEDDED = 6;
|
|
30
|
+
const IPV4_MAX = 15;
|
|
31
|
+
const SHORTEST = 2;
|
|
32
|
+
const LONGEST = 45;
|
|
33
|
+
const compose = (digits, count) => __randomComposition({
|
|
34
|
+
total: digits,
|
|
35
|
+
count,
|
|
36
|
+
minimum: DIGITS_MIN,
|
|
37
|
+
maximum: DIGITS_MAX
|
|
38
|
+
}).map(group).join(":");
|
|
5
39
|
const random = () => _randomInteger({
|
|
6
40
|
type: "integer",
|
|
7
41
|
minimum: 0,
|
|
8
42
|
maximum: 65535
|
|
9
43
|
}).toString(16);
|
|
44
|
+
const group = (digits) => {
|
|
45
|
+
let text = "";
|
|
46
|
+
for (let i = 0; i < digits; ++i) text += _randomInteger({
|
|
47
|
+
type: "integer",
|
|
48
|
+
minimum: 0,
|
|
49
|
+
maximum: 15
|
|
50
|
+
}).toString(16);
|
|
51
|
+
return text;
|
|
52
|
+
};
|
|
10
53
|
//#endregion
|
|
11
54
|
export { _randomFormatIpv6 };
|
|
12
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatIpv6.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv6.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {
|
|
1
|
+
{"version":3,"file":"_randomFormatIpv6.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv6.ts"],"sourcesContent":["import { _randomFormatIpv4 } from \"./_randomFormatIpv4\";\nimport { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomComposition } from \"./private/__randomComposition\";\n\nexport const _randomFormatIpv6 = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return new Array(GROUPS).fill(0).map(random).join(\":\");\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, {\n minimum: SHORTEST,\n maximum: LONGEST,\n spread: 12,\n }),\n );\n // `::` alone is the all-zero address, and the three forms below cover every\n // length between it and the padded IPv4-suffixed address: a compressed prefix\n // for the short ones, eight groups of one to four hexadecimal digits for the\n // middle, and six groups plus a dotted-quad tail for the long ones.\n if (length === SHORTEST) return \"::\";\n if (length < GROUPS * DIGITS_MIN + COLONS) {\n // `::` plus `count` groups spends one colon between each pair.\n const count: number = Math.ceil((length - 1) / (DIGITS_MAX + 1));\n return `::${compose(length - 1 - count, count)}`;\n }\n if (length <= GROUPS * DIGITS_MAX + COLONS)\n return compose(length - COLONS, GROUPS);\n // The dotted-quad tail is drawn at its longest so the six leading groups keep\n // a composable number of digits.\n const tail: string = _randomFormatIpv4({\n minLength: IPV4_MAX,\n maxLength: IPV4_MAX,\n });\n return `${compose(length - IPV4_MAX - EMBEDDED, EMBEDDED)}:${tail}`;\n};\n\nconst GROUPS = 8;\nconst COLONS = GROUPS - 1;\nconst DIGITS_MIN = 1;\nconst DIGITS_MAX = 4;\nconst EMBEDDED = 6; // groups preceding a dotted-quad tail\nconst IPV4_MAX = \"255.255.255.255\".length;\nconst SHORTEST = \"::\".length;\nconst LONGEST = EMBEDDED * DIGITS_MAX + EMBEDDED + IPV4_MAX;\n\nconst compose = (digits: number, count: number): string =>\n __randomComposition({\n total: digits,\n count,\n minimum: DIGITS_MIN,\n maximum: DIGITS_MAX,\n })\n .map(group)\n .join(\":\");\n\nconst random = () =>\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 65_535,\n }).toString(16);\n\nconst group = (digits: number): string => {\n let text: string = \"\";\n for (let i: number = 0; i < digits; ++i)\n text += _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 15,\n }).toString(16);\n return text;\n};\n"],"mappings":";;;;;AASA,MAAa,qBAAqB,UAAkC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_randomString_1 = require("./_randomString");
|
|
|
5
5
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
6
6
|
const _randomFormatJsonPointer = (props) => {
|
|
7
7
|
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
8
|
-
return
|
|
8
|
+
return `${PREFIX}${random()}`;
|
|
9
9
|
// The `/components/schemas/` prefix (20 chars) is fixed; the reference token
|
|
10
10
|
// after it grows or shrinks to hit the requested length.
|
|
11
|
-
|
|
11
|
+
if (props.maxLength === undefined || props.maxLength >= PREFIX.length)
|
|
12
|
+
return `${PREFIX}${(0, _randomStringLength_1._randomSegmentLength)(props, PREFIX.length, 10, 0)}`;
|
|
13
|
+
// Below that prefix a pointer still exists: the empty pointer addresses the
|
|
14
|
+
// whole document, and one `/`-prefixed token addresses a member of it.
|
|
15
|
+
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 0, spread: 6 }));
|
|
16
|
+
return length === 0
|
|
17
|
+
? ""
|
|
18
|
+
: `/${(0, _randomString_1._randomString)({
|
|
19
|
+
type: "string",
|
|
20
|
+
minLength: length - 1,
|
|
21
|
+
maxLength: length - 1,
|
|
22
|
+
})}`;
|
|
12
23
|
};
|
|
13
24
|
exports._randomFormatJsonPointer = _randomFormatJsonPointer;
|
|
25
|
+
const PREFIX = "/components/schemas/";
|
|
14
26
|
const random = () => (0, _randomString_1._randomString)({ type: "string", minLength: 10, maxLength: 10 });
|
|
15
27
|
//# sourceMappingURL=_randomFormatJsonPointer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatJsonPointer.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+
|
|
1
|
+
{"version":3,"file":"_randomFormatJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatJsonPointer.ts"],"names":[],"m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omString.mjs";
|
|
2
|
-
import { _randomSegmentLength } from "./_randomStringLength.mjs";
|
|
2
|
+
import { _randomLengthPick, _randomLengthWindow, _randomSegmentLength } from "./_randomStringLength.mjs";
|
|
3
3
|
//#region src/internal/_randomFormatJsonPointer.ts
|
|
4
4
|
const _randomFormatJsonPointer = (props) => {
|
|
5
|
-
if (props?.minLength === void 0 && props?.maxLength === void 0) return
|
|
6
|
-
return
|
|
5
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return `${PREFIX}${random()}`;
|
|
6
|
+
if (props.maxLength === void 0 || props.maxLength >= PREFIX.length) return `${PREFIX}${_randomSegmentLength(props, PREFIX.length, 10, 0)}`;
|
|
7
|
+
const length = _randomLengthPick(_randomLengthWindow(props, {
|
|
8
|
+
minimum: 0,
|
|
9
|
+
spread: 6
|
|
10
|
+
}));
|
|
11
|
+
return length === 0 ? "" : `/${_randomString({
|
|
12
|
+
type: "string",
|
|
13
|
+
minLength: length - 1,
|
|
14
|
+
maxLength: length - 1
|
|
15
|
+
})}`;
|
|
7
16
|
};
|
|
17
|
+
const PREFIX = "/components/schemas/";
|
|
8
18
|
const random = () => _randomString({
|
|
9
19
|
type: "string",
|
|
10
20
|
minLength: 10,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatJsonPointer.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {
|
|
1
|
+
{"version":3,"file":"_randomFormatJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatJsonPointer.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n _randomSegmentLength,\n} from \"./_randomStringLength\";\n\nexport const _randomFormatJsonPointer = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${PREFIX}${random()}`;\n // The `/components/schemas/` prefix (20 chars) is fixed; the reference token\n // after it grows or shrinks to hit the requested length.\n if (props.maxLength === undefined || props.maxLength >= PREFIX.length)\n return `${PREFIX}${_randomSegmentLength(props, PREFIX.length, 10, 0)}`;\n // Below that prefix a pointer still exists: the empty pointer addresses the\n // whole document, and one `/`-prefixed token addresses a member of it.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 0, spread: 6 }),\n );\n return length === 0\n ? \"\"\n : `/${_randomString({\n type: \"string\",\n minLength: length - 1,\n maxLength: length - 1,\n })}`;\n};\n\nconst PREFIX = \"/components/schemas/\";\n\nconst random = () =>\n _randomString({ type: \"string\", minLength: 10, maxLength: 10 });\n"],"mappings":";;;AAQA,MAAa,4BAA4B,UAAkC;CACzE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,SAAS,OAAO;CAG5B,IAAI,MAAM,cAAc,KAAA,KAAa,MAAM,aAAa,OAAO,QAC7D,OAAO,GAAG,SAAS,qBAAqB,OAAO,OAAO,QAAQ,IAAI,CAAC;CAGrE,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAE,CAAC,CACtD;CACA,OAAO,WAAW,IACd,KACA,IAAI,cAAc;EAChB,MAAM;EACN,WAAW,SAAS;EACpB,WAAW,SAAS;CACtB,CAAC;AACP;AAEA,MAAM,SAAS;AAEf,MAAM,eACJ,cAAc;CAAE,MAAM;CAAU,WAAW;CAAI,WAAW;AAAG,CAAC"}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._randomFormatRegex = void 0;
|
|
4
|
+
const _randomString_1 = require("./_randomString");
|
|
4
5
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
5
|
-
const _randomFormatRegex = (props) =>
|
|
6
|
+
const _randomFormatRegex = (props) => {
|
|
7
|
+
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
8
|
+
return FIXED;
|
|
9
|
+
// Every character `_randomString` emits is a literal in regular expression
|
|
10
|
+
// syntax, so a source of any length — including the empty source `new
|
|
11
|
+
// RegExp("")` accepts — compiles.
|
|
12
|
+
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 0, spread: 16 }));
|
|
13
|
+
return (0, _randomString_1._randomString)({
|
|
14
|
+
type: "string",
|
|
15
|
+
minLength: length,
|
|
16
|
+
maxLength: length,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
6
19
|
exports._randomFormatRegex = _randomFormatRegex;
|
|
7
20
|
const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
|
|
8
21
|
//# sourceMappingURL=_randomFormatRegex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatRegex.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRegex.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"_randomFormatRegex.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRegex.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+DAI+B;AAExB,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE;IAClE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,KAAK,CAAC;IACf,2EAA2E;IAC3E,sEAAsE;IACtE,kCAAkC;IAClC,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACvD,CAAC;IACF,OAAO,IAAA,6BAAa,EAAC;QACnB,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;KAClB,CAAC,CAAC;AACL,CAAC,CAAC;AAdW,QAAA,kBAAkB,GAAlB,kBAAkB,CAc7B;AAEF,MAAM,KAAK,GACT,8FAA8F,CAAC"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _randomString } from "./_randomString.mjs";
|
|
2
|
+
import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
|
|
2
3
|
//#region src/internal/_randomFormatRegex.ts
|
|
3
|
-
const _randomFormatRegex = (props) =>
|
|
4
|
+
const _randomFormatRegex = (props) => {
|
|
5
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return FIXED;
|
|
6
|
+
const length = _randomLengthPick(_randomLengthWindow(props, {
|
|
7
|
+
minimum: 0,
|
|
8
|
+
spread: 16
|
|
9
|
+
}));
|
|
10
|
+
return _randomString({
|
|
11
|
+
type: "string",
|
|
12
|
+
minLength: length,
|
|
13
|
+
maxLength: length
|
|
14
|
+
});
|
|
15
|
+
};
|
|
4
16
|
const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
|
|
5
17
|
//#endregion
|
|
6
18
|
export { _randomFormatRegex };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\n\nexport const _randomFormatRegex = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return FIXED;\n // Every character `_randomString` emits is a literal in regular expression\n // syntax, so a source of any length — including the empty source `new\n // RegExp(\"\")` accepts — compiles.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 0, spread: 16 }),\n );\n return _randomString({\n type: \"string\",\n minLength: length,\n maxLength: length,\n });\n};\n\nconst FIXED =\n \"/^(?:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)\\\\.){3}(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)$/\";\n"],"mappings":";;;AAOA,MAAa,sBAAsB,UAAkC;CACnE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO;CAIT,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAG,CAAC,CACvD;CACA,OAAO,cAAc;EACnB,MAAM;EACN,WAAW;EACX,WAAW;CACb,CAAC;AACH;AAEA,MAAM,QACJ"}
|
|
@@ -2,11 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._randomFormatRelativeJsonPointer = void 0;
|
|
4
4
|
const _randomInteger_1 = require("./_randomInteger");
|
|
5
|
+
const _randomString_1 = require("./_randomString");
|
|
5
6
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const __randomComposition_1 = require("./private/__randomComposition");
|
|
8
|
+
const _randomFormatRelativeJsonPointer = (props) => {
|
|
9
|
+
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
10
|
+
return `${(0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 10 })}#`;
|
|
11
|
+
// The leading non-negative integer stands alone as a pointer, so a single
|
|
12
|
+
// digit is the shortest form; `#` names the key and a `/`-prefixed token names
|
|
13
|
+
// a member, which absorbs any remaining length.
|
|
14
|
+
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 1, spread: 6 }));
|
|
15
|
+
if (length === 1)
|
|
16
|
+
return (0, __randomComposition_1.__randomNumeric)(1);
|
|
17
|
+
if (length === 2)
|
|
18
|
+
return `${(0, __randomComposition_1.__randomNumeric)(1)}#`;
|
|
19
|
+
return `${(0, __randomComposition_1.__randomNumeric)(1)}/${(0, _randomString_1._randomString)({
|
|
20
|
+
type: "string",
|
|
21
|
+
minLength: length - 2,
|
|
22
|
+
maxLength: length - 2,
|
|
23
|
+
})}`;
|
|
24
|
+
};
|
|
11
25
|
exports._randomFormatRelativeJsonPointer = _randomFormatRelativeJsonPointer;
|
|
12
26
|
//# sourceMappingURL=_randomFormatRelativeJsonPointer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatRelativeJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+
|
|
1
|
+
{"version":3,"file":"_randomFormatRelativeJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,mDAAgD;AAChD,+DAI+B;AAC/B,uEAAgE;AAEzD,MAAM,gCAAgC,GAAG,CAC9C,KAAqB,EACb,EAAE;IACV,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,GAAG,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,gDAAgD;IAChD,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CACtD,CAAC;IACF,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,IAAA,qCAAe,EAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,IAAA,qCAAe,EAAC,CAAC,CAAC,GAAG,CAAC;IAClD,OAAO,GAAG,IAAA,qCAAe,EAAC,CAAC,CAAC,IAAI,IAAA,6BAAa,EAAC;QAC5C,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM,GAAG,CAAC;QACrB,SAAS,EAAE,MAAM,GAAG,CAAC;KACtB,CAAC,EAAE,CAAC;AACP,CAAC,CAAC;AAlBW,QAAA,gCAAgC,GAAhC,gCAAgC,CAkB3C"}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { _randomInteger } from "./_randomInteger.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { _randomString } from "./_randomString.mjs";
|
|
3
|
+
import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
|
|
4
|
+
import { __randomNumeric } from "./private/__randomComposition.mjs";
|
|
3
5
|
//#region src/internal/_randomFormatRelativeJsonPointer.ts
|
|
4
|
-
const _randomFormatRelativeJsonPointer = (props) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const _randomFormatRelativeJsonPointer = (props) => {
|
|
7
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return `${_randomInteger({
|
|
8
|
+
type: "integer",
|
|
9
|
+
minimum: 0,
|
|
10
|
+
maximum: 10
|
|
11
|
+
})}#`;
|
|
12
|
+
const length = _randomLengthPick(_randomLengthWindow(props, {
|
|
13
|
+
minimum: 1,
|
|
14
|
+
spread: 6
|
|
15
|
+
}));
|
|
16
|
+
if (length === 1) return __randomNumeric(1);
|
|
17
|
+
if (length === 2) return `${__randomNumeric(1)}#`;
|
|
18
|
+
return `${__randomNumeric(1)}/${_randomString({
|
|
19
|
+
type: "string",
|
|
20
|
+
minLength: length - 2,
|
|
21
|
+
maxLength: length - 2
|
|
22
|
+
})}`;
|
|
23
|
+
};
|
|
9
24
|
//#endregion
|
|
10
25
|
export { _randomFormatRelativeJsonPointer };
|
|
11
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatRelativeJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {
|
|
1
|
+
{"version":3,"file":"_randomFormatRelativeJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomNumeric } from \"./private/__randomComposition\";\n\nexport const _randomFormatRelativeJsonPointer = (\n props?: _ILengthProps,\n): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${_randomInteger({ type: \"integer\", minimum: 0, maximum: 10 })}#`;\n // The leading non-negative integer stands alone as a pointer, so a single\n // digit is the shortest form; `#` names the key and a `/`-prefixed token names\n // a member, which absorbs any remaining length.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 1, spread: 6 }),\n );\n if (length === 1) return __randomNumeric(1);\n if (length === 2) return `${__randomNumeric(1)}#`;\n return `${__randomNumeric(1)}/${_randomString({\n type: \"string\",\n minLength: length - 2,\n maxLength: length - 2,\n })}`;\n};\n"],"mappings":";;;;;AASA,MAAa,oCACX,UACW;CACX,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,eAAe;EAAE,MAAM;EAAW,SAAS;EAAG,SAAS;CAAG,CAAC,EAAE;CAIzE,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAE,CAAC,CACtD;CACA,IAAI,WAAW,GAAG,OAAO,gBAAgB,CAAC;CAC1C,IAAI,WAAW,GAAG,OAAO,GAAG,gBAAgB,CAAC,EAAE;CAC/C,OAAO,GAAG,gBAAgB,CAAC,EAAE,GAAG,cAAc;EAC5C,MAAM;EACN,WAAW,SAAS;EACpB,WAAW,SAAS;CACtB,CAAC;AACH"}
|
|
@@ -3,13 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._randomFormatTime = void 0;
|
|
4
4
|
const _randomInteger_1 = require("./_randomInteger");
|
|
5
5
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
minimum: 0,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
6
|
+
const __randomComposition_1 = require("./private/__randomComposition");
|
|
7
|
+
const _randomFormatTime = (props) => {
|
|
8
|
+
const clock = () => new Date((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: DAY })).toISOString();
|
|
9
|
+
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
10
|
+
return clock().substring(11);
|
|
11
|
+
// `HH:MM:SS` carries a mandatory offset — one character as `Z`, six as
|
|
12
|
+
// `+HH:MM` — and an optional fraction of one to nine digits between them.
|
|
13
|
+
// Together they express 9 and every length from 11 through 24; 10 is the one
|
|
14
|
+
// gap, because a fraction needs both a dot and a digit.
|
|
15
|
+
const window = (0, _randomStringLength_1._randomLengthWindow)(props, {
|
|
16
|
+
minimum: CLOCK + 1,
|
|
17
|
+
maximum: CLOCK + 1 + FRACTION_MAX + OFFSET,
|
|
18
|
+
spread: 6,
|
|
19
|
+
});
|
|
20
|
+
let length = (0, _randomStringLength_1._randomLengthPick)(window);
|
|
21
|
+
if (length === CLOCK + 2)
|
|
22
|
+
length = window.high >= CLOCK + 3 ? CLOCK + 3 : CLOCK + 1;
|
|
23
|
+
if (length < window.low || length > window.high)
|
|
24
|
+
throw new Error(_randomStringLength_1._RANDOM_LENGTH_ERROR);
|
|
25
|
+
const base = clock().substring(11, 11 + CLOCK);
|
|
26
|
+
if (length === CLOCK + 1)
|
|
27
|
+
return `${base}Z`;
|
|
28
|
+
// Nine fraction digits cap the `Z` form at 19 characters, so anything longer
|
|
29
|
+
// spends the extra five on a numeric offset instead.
|
|
30
|
+
return length <= CLOCK + 2 + FRACTION_MAX
|
|
31
|
+
? `${base}.${(0, __randomComposition_1.__randomDigits)(length - CLOCK - 2)}Z`
|
|
32
|
+
: `${base}.${(0, __randomComposition_1.__randomDigits)(length - CLOCK - 1 - OFFSET)}${offset()}`;
|
|
33
|
+
};
|
|
13
34
|
exports._randomFormatTime = _randomFormatTime;
|
|
14
35
|
const DAY = 86400000;
|
|
36
|
+
const CLOCK = "00:00:00".length;
|
|
37
|
+
const OFFSET = "+00:00".length;
|
|
38
|
+
const FRACTION_MAX = 9;
|
|
39
|
+
const offset = () => `${(0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 1 }) === 0 ? "+" : "-"}${pad((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 23 }))}:${pad((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 59 }))}`;
|
|
40
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
15
41
|
//# sourceMappingURL=_randomFormatTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatTime.js","sourceRoot":"","sources":["../../src/internal/_randomFormatTime.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+
|
|
1
|
+
{"version":3,"file":"_randomFormatTime.js","sourceRoot":"","sources":["../../src/internal/_randomFormatTime.ts"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CAAC,CAAC"}
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
import { _randomInteger } from "./_randomInteger.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { _RANDOM_LENGTH_ERROR, _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
|
|
3
|
+
import { __randomDigits } from "./private/__randomComposition.mjs";
|
|
3
4
|
//#region src/internal/_randomFormatTime.ts
|
|
4
|
-
const _randomFormatTime = (props) =>
|
|
5
|
+
const _randomFormatTime = (props) => {
|
|
6
|
+
const clock = () => new Date(_randomInteger({
|
|
7
|
+
type: "integer",
|
|
8
|
+
minimum: 0,
|
|
9
|
+
maximum: DAY
|
|
10
|
+
})).toISOString();
|
|
11
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return clock().substring(11);
|
|
12
|
+
const window = _randomLengthWindow(props, {
|
|
13
|
+
minimum: CLOCK + 1,
|
|
14
|
+
maximum: CLOCK + 1 + FRACTION_MAX + OFFSET,
|
|
15
|
+
spread: 6
|
|
16
|
+
});
|
|
17
|
+
let length = _randomLengthPick(window);
|
|
18
|
+
if (length === CLOCK + 2) length = window.high >= CLOCK + 3 ? CLOCK + 3 : CLOCK + 1;
|
|
19
|
+
if (length < window.low || length > window.high) throw new Error(_RANDOM_LENGTH_ERROR);
|
|
20
|
+
const base = clock().substring(11, 11 + CLOCK);
|
|
21
|
+
if (length === CLOCK + 1) return `${base}Z`;
|
|
22
|
+
return length <= CLOCK + 2 + FRACTION_MAX ? `${base}.${__randomDigits(length - CLOCK - 2)}Z` : `${base}.${__randomDigits(length - CLOCK - 1 - OFFSET)}${offset()}`;
|
|
23
|
+
};
|
|
24
|
+
const DAY = 864e5;
|
|
25
|
+
const CLOCK = 8;
|
|
26
|
+
const OFFSET = 6;
|
|
27
|
+
const FRACTION_MAX = 9;
|
|
28
|
+
const offset = () => `${_randomInteger({
|
|
5
29
|
type: "integer",
|
|
6
30
|
minimum: 0,
|
|
7
|
-
maximum:
|
|
8
|
-
})
|
|
9
|
-
|
|
31
|
+
maximum: 1
|
|
32
|
+
}) === 0 ? "+" : "-"}${pad(_randomInteger({
|
|
33
|
+
type: "integer",
|
|
34
|
+
minimum: 0,
|
|
35
|
+
maximum: 23
|
|
36
|
+
}))}:${pad(_randomInteger({
|
|
37
|
+
type: "integer",
|
|
38
|
+
minimum: 0,
|
|
39
|
+
maximum: 59
|
|
40
|
+
}))}`;
|
|
41
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
10
42
|
//#endregion
|
|
11
43
|
export { _randomFormatTime };
|
|
12
44
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatTime.mjs","names":[],"sources":["../../src/internal/_randomFormatTime.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {
|
|
1
|
+
{"version":3,"file":"_randomFormatTime.mjs","names":[],"sources":["../../src/internal/_randomFormatTime.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _RANDOM_LENGTH_ERROR,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomDigits } from \"./private/__randomComposition\";\n\nexport const _randomFormatTime = (props?: _ILengthProps): string => {\n const clock = (): string =>\n new Date(\n _randomInteger({ type: \"integer\", minimum: 0, maximum: DAY }),\n ).toISOString();\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return clock().substring(11);\n // `HH:MM:SS` carries a mandatory offset — one character as `Z`, six as\n // `+HH:MM` — and an optional fraction of one to nine digits between them.\n // Together they express 9 and every length from 11 through 24; 10 is the one\n // gap, because a fraction needs both a dot and a digit.\n const window = _randomLengthWindow(props, {\n minimum: CLOCK + 1,\n maximum: CLOCK + 1 + FRACTION_MAX + OFFSET,\n spread: 6,\n });\n let length: number = _randomLengthPick(window);\n if (length === CLOCK + 2)\n length = window.high >= CLOCK + 3 ? CLOCK + 3 : CLOCK + 1;\n if (length < window.low || length > window.high)\n throw new Error(_RANDOM_LENGTH_ERROR);\n const base: string = clock().substring(11, 11 + CLOCK);\n if (length === CLOCK + 1) return `${base}Z`;\n // Nine fraction digits cap the `Z` form at 19 characters, so anything longer\n // spends the extra five on a numeric offset instead.\n return length <= CLOCK + 2 + FRACTION_MAX\n ? `${base}.${__randomDigits(length - CLOCK - 2)}Z`\n : `${base}.${__randomDigits(length - CLOCK - 1 - OFFSET)}${offset()}`;\n};\n\nconst DAY = 86_400_000;\nconst CLOCK = \"00:00:00\".length;\nconst OFFSET = \"+00:00\".length;\nconst FRACTION_MAX = 9;\n\nconst offset = (): string =>\n `${_randomInteger({ type: \"integer\", minimum: 0, maximum: 1 }) === 0 ? \"+\" : \"-\"}${pad(\n _randomInteger({ type: \"integer\", minimum: 0, maximum: 23 }),\n )}:${pad(_randomInteger({ type: \"integer\", minimum: 0, maximum: 59 }))}`;\n\nconst pad = (value: number): string => String(value).padStart(2, \"0\");\n"],"mappings":";;;;AASA,MAAa,qBAAqB,UAAkC;CAClE,MAAM,cACJ,IAAI,KACF,eAAe;EAAE,MAAM;EAAW,SAAS;EAAG,SAAS;CAAI,CAAC,CAC9D,CAAC,CAAC,YAAY;CAChB,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,MAAM,CAAC,CAAC,UAAU,EAAE;CAK7B,MAAM,SAAS,oBAAoB,OAAO;EACxC,SAAS,QAAQ;EACjB,SAAS,QAAQ,IAAI,eAAe;EACpC,QAAQ;CACV,CAAC;CACD,IAAI,SAAiB,kBAAkB,MAAM;CAC7C,IAAI,WAAW,QAAQ,GACrB,SAAS,OAAO,QAAQ,QAAQ,IAAI,QAAQ,IAAI,QAAQ;CAC1D,IAAI,SAAS,OAAO,OAAO,SAAS,OAAO,MACzC,MAAM,IAAI,MAAM,oBAAoB;CACtC,MAAM,OAAe,MAAM,CAAC,CAAC,UAAU,IAAI,KAAK,KAAK;CACrD,IAAI,WAAW,QAAQ,GAAG,OAAO,GAAG,KAAK;CAGzC,OAAO,UAAU,QAAQ,IAAI,eACzB,GAAG,KAAK,GAAG,eAAe,SAAS,QAAQ,CAAC,EAAE,KAC9C,GAAG,KAAK,GAAG,eAAe,SAAS,QAAQ,IAAI,MAAM,IAAI,OAAO;AACtE;AAEA,MAAM,MAAM;AACZ,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,eAAe;AAErB,MAAM,eACJ,GAAG,eAAe;CAAE,MAAM;CAAW,SAAS;CAAG,SAAS;AAAE,CAAC,MAAM,IAAI,MAAM,MAAM,IACjF,eAAe;CAAE,MAAM;CAAW,SAAS;CAAG,SAAS;AAAG,CAAC,CAC7D,EAAE,GAAG,IAAI,eAAe;CAAE,MAAM;CAAW,SAAS;CAAG,SAAS;AAAG,CAAC,CAAC;AAEvE,MAAM,OAAO,UAA0B,OAAO,KAAK,CAAC,CAAC,SAAS,GAAG,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomPattern.js","sourceRoot":"","sources":["../../src/internal/_randomPattern.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAIvB,MAAM,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"_randomPattern.js","sourceRoot":"","sources":["../../src/internal/_randomPattern.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAIvB,MAAM,cAAc,GAAG,CAC5B,KAAa,EACb,KAAqB,EACb,EAAE;IACV,MAAM,CAAC,GAAY,IAAI,iBAAO,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,GAAG,GAAuB,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;IACjD,MAAM,GAAG,GAAuB,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;IAEjD,6EAA6E;IAC7E,8EAA8E;IAC9E,6EAA6E;IAC7E,IAAI,GAAG,KAAK,SAAS;QAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;SAC9B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG;QAAE,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;IAE/D,MAAM,OAAO,GAAY,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,CAAC;IAChE,MAAM,KAAK,GAAW,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;QACvC,MAAM,GAAG,GAAW,CAAC,CAAC,GAAG,EAAE,CAAC;QAC5B,IACE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;YACf,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;YACxC,CAAC,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;YAExC,OAAO,GAAG,CAAC;IACf,CAAC;IACD,MAAM,IAAI,KAAK,CACb,OAAO;QACL,CAAC,CAAC,kFAAkF;QACpF,CAAC,CAAC,0DAA0D,CAC/D,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,cAAc,GAAd,cAAc,CA8BzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomPattern.mjs","names":[],"sources":["../../src/internal/_randomPattern.ts"],"sourcesContent":["import RandExp from \"randexp\";\n\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomPattern = (regex: RegExp
|
|
1
|
+
{"version":3,"file":"_randomPattern.mjs","names":[],"sources":["../../src/internal/_randomPattern.ts"],"sourcesContent":["import RandExp from \"randexp\";\n\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomPattern = (\n regex: RegExp,\n props?: _ILengthProps,\n): string => {\n const r: RandExp = new RandExp(regex);\n const min: number | undefined = props?.minLength;\n const max: number | undefined = props?.maxLength;\n\n // RandExp expands an unbounded quantifier to `randInt(token.min, token.min +\n // r.max)`, so steering `r.max` biases the generated length toward the window.\n // There is no matching floor control, so the length is still verified below.\n if (max !== undefined) r.max = max;\n else if (min !== undefined && min * 2 > r.max) r.max = min * 2;\n\n const bounded: boolean = min !== undefined || max !== undefined;\n const limit: number = bounded ? 1024 : 10;\n for (let i: number = 0; i < limit; ++i) {\n const str: string = r.gen();\n if (\n regex.test(str) &&\n (min === undefined || str.length >= min) &&\n (max === undefined || str.length <= max)\n )\n return str;\n }\n throw new Error(\n bounded\n ? \"unable to generate a random string matching the pattern within the length range.\"\n : \"unable to generate a random string matching the pattern.\",\n );\n};\n"],"mappings":";;AAIA,MAAa,kBACX,OACA,UACW;CACX,MAAM,IAAa,IAAI,QAAQ,KAAK;CACpC,MAAM,MAA0B,OAAO;CACvC,MAAM,MAA0B,OAAO;CAKvC,IAAI,QAAQ,KAAA,GAAW,EAAE,MAAM;MAC1B,IAAI,QAAQ,KAAA,KAAa,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,MAAM;CAE7D,MAAM,UAAmB,QAAQ,KAAA,KAAa,QAAQ,KAAA;CACtD,MAAM,QAAgB,UAAU,OAAO;CACvC,KAAK,IAAI,IAAY,GAAG,IAAI,OAAO,EAAE,GAAG;EACtC,MAAM,MAAc,EAAE,IAAI;EAC1B,IACE,MAAM,KAAK,GAAG,MACb,QAAQ,KAAA,KAAa,IAAI,UAAU,SACnC,QAAQ,KAAA,KAAa,IAAI,UAAU,MAEpC,OAAO;CACX;CACA,MAAM,IAAI,MACR,UACI,qFACA,0DACN;AACF"}
|