arkregex 0.0.3 → 0.0.4
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/quantify.d.ts +1 -1
- package/out/regex.d.ts +5 -4
- package/out/state.d.ts +2 -2
- package/package.json +2 -2
package/out/quantify.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type parsePossibleRange<s extends State, unscanned extends string, parsed
|
|
|
30
30
|
unknown
|
|
31
31
|
] | [unknown, never]) ? s.error<writeUnnaturalNumberQuantifierError<parseQuantifier<unscanned, parsed>>> : s.pushQuantifier<s, parsed["min"], parsed["max"], parsed["unscanned"] extends Scanner.shift<"?", infer lazyUnscanned> ? lazyUnscanned : parsed["unscanned"]> : s.shiftQuantifiable<s, "{", unscanned>;
|
|
32
32
|
export type quantify<pattern extends string, min extends number, max extends number | null> = tryFastPath<pattern, min, max>;
|
|
33
|
-
type tryFastPath<pattern extends string, min extends number, max extends number | null> = max extends 0 ? "" : string extends pattern ? string :
|
|
33
|
+
type tryFastPath<pattern extends string, min extends number, max extends number | null> = max extends 0 ? "" : string extends pattern ? string : min extends 0 ? max extends 1 ? "" | pattern : max extends number ? loopFromZero<pattern, max, "", []> : // max is null, all we can do is append ${string}
|
|
34
34
|
"" | `${pattern}${string}` : loopUntilMin<pattern, min, max, "", []>;
|
|
35
35
|
type loopFromZero<base extends string, max extends number, acc extends string, repetitions extends 1[]> = repetitions["length"] extends max ? acc : loopFromZero<base, max, acc | `${acc}${base}`, [...repetitions, 1]>;
|
|
36
36
|
type loopUntilMin<base extends string, min extends number, max extends number | null, acc extends string, repetitions extends 1[]> = repetitions["length"] extends min ? max extends number ? loopUntilMax<base, min, max, acc, repetitions> : repetitions["length"] extends 0 ? acc | `${acc}${base}${string}` : `${acc}${string}` : loopUntilMin<base, min, max, `${acc}${base}`, [...repetitions, 1]>;
|
package/out/regex.d.ts
CHANGED
|
@@ -16,12 +16,13 @@ export interface Regex<out pattern extends string = string, out ctx extends Rege
|
|
|
16
16
|
infer: pattern;
|
|
17
17
|
inferCaptures: ctx["captures"] extends IndexedCaptures ? ctx["captures"] : [];
|
|
18
18
|
inferNamedCaptures: ctx["names"] extends NamedCaptures ? ctx["names"] : {};
|
|
19
|
-
|
|
20
|
-
test(s: string): s is pattern;
|
|
21
|
-
exec(s: string): RegexExecArray<[
|
|
19
|
+
inferExecArray: RegexExecArray<[
|
|
22
20
|
pattern,
|
|
23
21
|
...this["inferCaptures"]
|
|
24
|
-
], this["inferNamedCaptures"], this["flags"]
|
|
22
|
+
], this["inferNamedCaptures"], this["flags"]>;
|
|
23
|
+
flags: ctx["flags"] extends Flags ? ctx["flags"] : "";
|
|
24
|
+
test(s: string): s is pattern;
|
|
25
|
+
exec(s: string): this["inferExecArray"] | null;
|
|
25
26
|
exec(s: string): never;
|
|
26
27
|
}
|
|
27
28
|
export interface RegexParser {
|
package/out/state.d.ts
CHANGED
|
@@ -352,8 +352,8 @@ export type finalizeTree<tree, ctx extends FinalizationContext> = tree extends s
|
|
|
352
352
|
}> : tree extends SequenceTree ? SequenceTree.finalize<tree, ctx> : tree extends UnionTree ? UnionTree.finalize<tree, ctx> : tree extends GroupTree ? GroupTree.finalize<tree, ctx> : tree extends QuantifierTree ? QuantifierTree.finalize<tree, ctx> : tree extends ReferenceNode ? ReferenceNode.finalize<tree, ctx> : never;
|
|
353
353
|
type applyAnchors<pattern extends string> = pattern extends `${StartAnchorMarker}${infer startStripped}` ? startStripped extends `${infer bothStripped}${EndAnchorMarker}` ? bothStripped : appendNonRedundant<startStripped, string> : pattern extends `${infer endStripped}${EndAnchorMarker}` ? prependNonRedundant<endStripped, string> : prependNonRedundant<appendNonRedundant<pattern, string>, string>;
|
|
354
354
|
type anchorsAway<pattern extends string> = pattern extends `${StartAnchorMarker}${infer startStripped}` ? startStripped extends `${infer bothStripped}${EndAnchorMarker}` ? bothStripped : startStripped : pattern extends `${infer endStripped}${EndAnchorMarker}` ? endStripped : pattern;
|
|
355
|
-
type appendNonRedundant<base extends string, suffix extends string> = string extends base ? string extends suffix ? string : `${base}${suffix}` : `${
|
|
356
|
-
type prependNonRedundant<base extends string, prefix extends string> = string extends base ? string extends prefix ? string : `${prefix}${base}` : `${
|
|
355
|
+
type appendNonRedundant<base extends string, suffix extends string> = string extends base ? string extends suffix ? string : `${base}${suffix}` : `${base}${suffix}`;
|
|
356
|
+
type prependNonRedundant<base extends string, prefix extends string> = string extends base ? string extends prefix ? string : `${prefix}${base}` : `${prefix}${base}`;
|
|
357
357
|
export declare const writeMidAnchorError: <anchor extends Anchor>(anchor: anchor) => writeMidAnchorError<anchor>;
|
|
358
358
|
type writeMidAnchorError<anchor extends Anchor> = `Anchor ${anchor} may not appear mid-pattern`;
|
|
359
359
|
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.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "David Blass",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"out"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ark/util": "0.
|
|
32
|
+
"@ark/util": "0.56.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|