compose-regexp
Advanced tools
Comparing version 0.6.15 to 0.6.16
@@ -5,11 +5,19 @@ # Change Log | ||
## v0.6.10 | ||
## v0.6.16 | ||
*2022-05-05* | ||
*2022-05-07* | ||
### New features | ||
- Better TypeScript typings | ||
## v0.6.15 | ||
*2022-05-06* | ||
### New features | ||
- Added TypeScript typings | ||
## v0.6.11, v0.6.12, v0.6.13 | ||
## v0.6.11, v0.6.12, v0.6.13, v0.6.14 | ||
@@ -16,0 +24,0 @@ *2022-05-05* |
@@ -0,17 +1,114 @@ | ||
type NonNegInteger<N extends number, S extends string> = `${N}` extends Subtract<S, NotInInteger> ? N : never | ||
export type Param = string | RegExp | [Param] | (() => Param) | ||
export type Quantifier = '*' | '+' | '?' | '*?' | '+?' | '??' | number | [number] | {'0': number, length: 2} | [number, number] | ||
export declare function either(...x: [Param]) : RegExp | ||
export declare function sequence(...x: [Param]) : RegExp | ||
export declare function suffix(s: Quantifier, ...x: [Param]) : RegExp | ||
export declare function maybe(...x: [Param]) : RegExp | ||
export interface flags { | ||
add(flags: string, ...x: [Param]) : RegExp | ||
// Machinery for the quantifiers | ||
type Subtract<T, U> = T & Exclude<T, U> | ||
type Interrogation = '' | '?' | ||
type SimpleQuantifier = '*' | '+' | '?' | '*?' | '+?' | '??' | ||
type NotInInteger = | ||
| `${string}.${string}` | ||
| `${string}E${string}` | ||
| `${string}N${string}` | ||
| `${string}I${string}` | ||
| `${string}e${string}` | ||
| `${string}-${string}` | ||
type HackyQuantifier = | ||
| number | ||
| [number] | ||
| [number, number] | ||
| {'0': number, '1': undefined, length: 2} & Array<any> | ||
type BracketQuantifier = `{${number}}${Interrogation}` | `{${number},}${Interrogation}` | `{${number},${number}}${Interrogation}` | ||
export declare function suffix<BQ extends BracketQuantifier>( | ||
s: SimpleQuantifier | HackyQuantifier | Subtract<BQ, NotInInteger>, | ||
...x: [Param] | ||
) : RegExp | ||
// Machinery for the flags | ||
// Based on https://glitch.com/~efficacious-valley-repair 's output for | ||
// `/^[dgimsuy]{6}$/` | ||
// That glitch is the work of https://github.com/AnyhowStep | ||
// repo: https://github.com/AnyhowStep/efficacious-valley-repair | ||
type Head<StrT extends string> = StrT extends `${infer HeadT}${string}` ? HeadT : never; | ||
type Tail<StrT extends string> = StrT extends `${string}${infer TailT}` ? TailT : never; | ||
interface Dfa { | ||
startState : string, | ||
acceptStates : string, | ||
transitions : Record<string, Record<string, string>>, | ||
} | ||
type AcceptsImpl< | ||
DfaT extends Dfa, | ||
StateT extends string, | ||
InputT extends string | ||
> = | ||
InputT extends "" ? | ||
(StateT extends DfaT["acceptStates"] ? true : false) : | ||
AcceptsImpl< | ||
DfaT, | ||
DfaT["transitions"][StateT][Head<InputT>], | ||
Tail<InputT> | ||
>; | ||
type Accepts<DfaT extends Dfa, InputT extends string> = AcceptsImpl<DfaT, DfaT["startState"], InputT>; | ||
type DGIMSUY<Next> = | ||
& Record<"d"|"g"|"i"|"m"|"s"|"u"|"y", Next> | ||
& Record<string, "fail"> | ||
interface Flags { | ||
startState : "0", | ||
acceptStates : "0"|"1"|"2"|"3"|"4"|"5"|"6", | ||
transitions : { | ||
"0": DGIMSUY<"1">, | ||
"1": DGIMSUY<"2">, | ||
"2": DGIMSUY<"3">, | ||
"3": DGIMSUY<"4">, | ||
"4": DGIMSUY<"5">, | ||
"5": DGIMSUY<"6">, | ||
"6": Record<string, "fail">, | ||
"fail": Record<string, "fail">, | ||
}, | ||
} | ||
type InLanguage_0 = Accepts<Flags, "df"> /** Insert your string here */ | ||
type CheckType<F extends Flags, Str extends string> = Accepts<F, Str> extends true ? Str : [`Invalid flags: ${Str}`]; | ||
type TwoFlags = | ||
| `${string}d${string}d${string}` | ||
| `${string}g${string}g${string}` | ||
| `${string}i${string}i${string}` | ||
| `${string}m${string}m${string}` | ||
| `${string}s${string}s${string}` | ||
| `${string}u${string}u${string}` | ||
| `${string}y${string}y${string}` | ||
| `${string}g${string}y${string}` | ||
| `${string}y${string}g${string}` | ||
export interface flags<Str extends string>{ | ||
add( | ||
flags: Subtract<CheckType<Flags, Str>, TwoFlags>, | ||
...x: [Param] | ||
) : RegExp | ||
} | ||
export declare function capture(...x: [Param]) : RegExp | ||
export declare function namedCapture(label: string, ...x: [Param]) : RegExp | ||
export declare function ref(n:number): RegExp | ||
@@ -21,2 +118,3 @@ export declare function ref(n:number, depth:number): RegExp | ||
export declare function lookAhead(...x: [Param]) : RegExp | ||
@@ -23,0 +121,0 @@ export declare function notAhead(...x: [Param]) : RegExp |
{ | ||
"name": "compose-regexp", | ||
"version": "0.6.15", | ||
"version": "0.6.16", | ||
"description": "A set of functions to build and compose complex regular expressions", | ||
@@ -47,3 +47,3 @@ "type": "module", | ||
"devDependencies": { | ||
"compose-regexp": "0.6.14", | ||
"compose-regexp": "0.6.15", | ||
"gosub": "1.1.0", | ||
@@ -50,0 +50,0 @@ "ospec": "^4.1.1", |
@@ -20,10 +20,17 @@ | ||
writeFileSync('./package.json', JSON.stringify(pkg, null, '\t'), 'utf-8') | ||
let success = false | ||
do { | ||
await npm('cache', 'clean', '--force') | ||
await npm('cache', 'clean', '--force') | ||
// give the npm servers some time | ||
await sleep(1) | ||
try { | ||
await npm('i') | ||
success = true | ||
} catch(e) { | ||
console.log("retrying to fetch the latest version") | ||
} | ||
} while (!success) | ||
// give the npm servers some time | ||
await sleep(1) | ||
await npm('i') | ||
await npm('run', 'test') | ||
@@ -30,0 +37,0 @@ |
157757
2883