arkregex 0.0.16-beta.2 → 0.0.16-rc.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/out/_util/registry.d.ts +1 -1
- package/out/internal.js +2 -0
- package/out/quantify.d.ts +17 -1
- package/package.json +2 -2
package/out/_util/registry.d.ts
CHANGED
package/out/internal.js
CHANGED
|
@@ -23,6 +23,7 @@ var unescapedLiteralQuestionMarkMessage = "literal ? must be escaped at the star
|
|
|
23
23
|
// out/quantify.js
|
|
24
24
|
var writeUnmatchedQuantifierError = (quantifier) => `Quantifier ${quantifier} requires a preceding token`;
|
|
25
25
|
var writeUnnaturalNumberQuantifierError = (quantifier) => `Quantifier ${quantifier} must use natural numbers`;
|
|
26
|
+
var writeMinExceedsMaxQuantifierError = (quantifier) => `Quantifier ${quantifier} min cannot exceed max`;
|
|
26
27
|
|
|
27
28
|
// out/state.js
|
|
28
29
|
var writeIncompleteReferenceError = (ref) => `Reference to incomplete group '${ref}' has no effect`;
|
|
@@ -41,6 +42,7 @@ export {
|
|
|
41
42
|
writeInvalidModifierMessage,
|
|
42
43
|
writeInvalidUnicodePropertyMessage,
|
|
43
44
|
writeMidAnchorError,
|
|
45
|
+
writeMinExceedsMaxQuantifierError,
|
|
44
46
|
writeStringEscapableMessage,
|
|
45
47
|
writeUnmatchedQuantifierError,
|
|
46
48
|
writeUnnaturalNumberQuantifierError,
|
package/out/quantify.d.ts
CHANGED
|
@@ -24,11 +24,25 @@ type parsePossibleRangeString<unscanned extends string> = unscanned extends (`${
|
|
|
24
24
|
max: parseNonNegativeInteger<l>;
|
|
25
25
|
unscanned: skipPossibleQuestionMark<next>;
|
|
26
26
|
}> : null;
|
|
27
|
+
type GreaterDigits = {
|
|
28
|
+
"0": never;
|
|
29
|
+
"1": "0";
|
|
30
|
+
"2": "0" | "1";
|
|
31
|
+
"3": "0" | "1" | "2";
|
|
32
|
+
"4": "0" | "1" | "2" | "3";
|
|
33
|
+
"5": "0" | "1" | "2" | "3" | "4";
|
|
34
|
+
"6": "0" | "1" | "2" | "3" | "4" | "5";
|
|
35
|
+
"7": "0" | "1" | "2" | "3" | "4" | "5" | "6";
|
|
36
|
+
"8": "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7";
|
|
37
|
+
"9": "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8";
|
|
38
|
+
};
|
|
39
|
+
type isGreaterNaturalString<l extends string, r extends string, decided extends boolean | null = null> = l extends `${infer ld extends keyof GreaterDigits}${infer lRest}` ? r extends `${infer rd extends keyof GreaterDigits}${infer rRest}` ? isGreaterNaturalString<lRest, rRest, decided extends boolean ? decided : ld extends rd ? null : rd extends GreaterDigits[ld] ? true : false> : true : r extends "" ? decided extends true ? true : false : false;
|
|
40
|
+
type exceedsMax<min extends number, max extends number | null> = max extends number ? min extends 0 | max ? false : isGreaterNaturalString<`${min}`, `${max}`> : false;
|
|
27
41
|
type parseQuantifier<unscanned extends string, parsed extends ParsedRange> = unscanned extends `${infer range}${parsed["unscanned"]}` ? `{${range}` : never;
|
|
28
42
|
export type parsePossibleRange<s extends State, unscanned extends string, parsed extends ParsedRange | null = parsePossibleRangeString<unscanned>> = parsed extends ParsedRange ? s["root"] extends "" ? s.error<writeUnmatchedQuantifierError<parseQuantifier<unscanned, parsed>>> : [parsed["min"], parsed["max"]] extends ([
|
|
29
43
|
never,
|
|
30
44
|
unknown
|
|
31
|
-
] | [unknown, never]) ? s.error<writeUnnaturalNumberQuantifierError<parseQuantifier<unscanned, parsed>>> :
|
|
45
|
+
] | [unknown, never]) ? s.error<writeUnnaturalNumberQuantifierError<parseQuantifier<unscanned, parsed>>> : exceedsMax<parsed["min"], parsed["max"]> extends true ? s.error<writeMinExceedsMaxQuantifierError<parseQuantifier<unscanned, parsed>>> : s.pushQuantifier<s, parsed["min"], parsed["max"], parsed["unscanned"]> : s.shiftQuantifiable<s, "{", unscanned>;
|
|
32
46
|
export type quantify<pattern extends string, min extends number, max extends number | null> = tryFastPath<pattern, min, max>;
|
|
33
47
|
type tryFastPath<pattern extends string, min extends number, max extends number | null> = max extends 0 ? "" : string extends pattern ? string : [pattern, `${number}`] extends [`${number}`, pattern] ? max extends null ? string : min extends 0 ? "" | `${number}` : `${number}` : min extends 0 ? max extends 1 ? "" | pattern : max extends number ? loopFromZero<pattern, max, "", []> : // max is null, all we can do is append ${string}
|
|
34
48
|
"" | `${pattern}${string}` : loopUntilMin<pattern, min, max, "", []>;
|
|
@@ -40,4 +54,6 @@ export declare const writeUnmatchedQuantifierError: <quantifier extends string>(
|
|
|
40
54
|
export type writeUnmatchedQuantifierError<quantifier extends string> = `Quantifier ${quantifier} requires a preceding token`;
|
|
41
55
|
export declare const writeUnnaturalNumberQuantifierError: <quantifier extends string>(quantifier: quantifier) => writeUnnaturalNumberQuantifierError<quantifier>;
|
|
42
56
|
export type writeUnnaturalNumberQuantifierError<quantifier extends string> = `Quantifier ${quantifier} must use natural numbers`;
|
|
57
|
+
export declare const writeMinExceedsMaxQuantifierError: <quantifier extends string>(quantifier: quantifier) => writeMinExceedsMaxQuantifierError<quantifier>;
|
|
58
|
+
export type writeMinExceedsMaxQuantifierError<quantifier extends string> = `Quantifier ${quantifier} min cannot exceed max`;
|
|
43
59
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkregex",
|
|
3
3
|
"description": "A drop-in replacement for new RegExp() with types",
|
|
4
|
-
"version": "0.0.16-
|
|
4
|
+
"version": "0.0.16-rc.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"out"
|
|
52
52
|
],
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@ark/util": "3.0.0-
|
|
54
|
+
"@ark/util": "3.0.0-rc.0"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|