-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.d.ts
120 lines (99 loc) · 2.91 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
export interface Location {
start: Position;
end: Position;
get show(): string;
}
export interface Position {
line: number;
column: number;
}
// Classes with markers so the union type works properly
declare class ParserFlavorJSClass {
private __marker: 'js';
}
declare class ParserFlavorJVMClass {
private __marker: 'jvm';
}
export const ParserFlavorJS: ParserFlavorJSClass;
export const ParserFlavorJVM: ParserFlavorJVMClass;
export type ParserFlavor = typeof ParserFlavorJS | typeof ParserFlavorJVM;
export interface TokenMutator {
name: string;
levels: number[];
}
export interface MutationOptions {
mutators?: TokenMutator[];
mutationLevels?: number[];
flavor?: ParserFlavor;
}
export interface Mutant {
/** The replacement pattern
*/
pattern: string;
/** Name of the mutation
*/
name: string;
/** [[weaponregex.model.Location]] in the original string where the mutation occurred
*/
location: Location;
/** The mutation levels of the mutator
*/
levels: number[];
/** Description on the mutation
*/
description: string;
/** The part of the pattern that has been changed
*/
replacement: string;
}
/** Mutate a regex pattern and flags with the given options.
*
* @param pattern
* Input regex string
* @param flags
* Optional regex flags
* @param options
* Optional JavaScript object for Mutation options
* {{{
* {
* mutators: [Mutators to be used for mutation. If this is `null`, all built-in mutators will be used.],
* mutationLevels: [Target mutation levels. If this is `null`, the `mutators`, will not be filtered.],
* flavor: [Regex flavor. By the default, `ParerFlavorJS` will be used.]
* }
* }}}
* @return
* A JavaScript Array of [[weaponregex.model.mutation.Mutant]] if can be parsed, or throw an exception otherwise
*/
export function mutate(
pattern: string,
flags?: string | null,
options?: MutationOptions | null
): Mutant[];
/** JS Map that maps from a token mutator class names to the associating token mutator
*/
export const mutators: Map<string, TokenMutator>;
export const BuiltinMutators: {
/** JS Array of all built-in token mutators
*/
all: TokenMutator[];
/** JS Map that maps from a token mutator class names to the associating token mutator
*/
byName: Map<string, TokenMutator>;
/** JS Map that maps from mutation level number to token mutators in that level
*/
byLevel: Map<number, TokenMutator[]>;
/** Get all the token mutators in the given mutation level
* @param mutationLevel
* Mutation level number
* @return
* Array of all the tokens mutators in that level, if any
*/
atLevel(mutationLevel: number): TokenMutator[];
/** Get all the token mutators in the given mutation levels
* @param mutationLevels
* Mutation level numbers
* @return
* Array of all the tokens mutators in that levels, if any
*/
atLevels(mutationLevels: number[]): TokenMutator[];
};