rregex 1.1.0 → 1.1.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/lib/browser.d.ts +29 -24
- package/lib/browser.js +12 -8
- package/lib/commonjs.d.ts +29 -23
- package/lib/commonjs.js +12 -8
- package/lib/module.d.ts +29 -23
- package/lib/module.js +0 -8
- package/lib/rregex.wasm +0 -0
- package/lib/rregex.wasm.d.ts +0 -1
- package/lib/types.d.ts +29 -24
- package/package.json +15 -2
- package/babel.config.js +0 -7
- package/jest.transform.js +0 -3
- package/test/rregex.test.ts +0 -235
package/lib/browser.d.ts
CHANGED
|
@@ -5,17 +5,11 @@
|
|
|
5
5
|
* @returns {string}
|
|
6
6
|
*/
|
|
7
7
|
export function escape(text: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* @returns {any}
|
|
10
|
-
*/
|
|
11
|
-
export function get_metadata(): any;
|
|
12
8
|
|
|
13
9
|
export type Hir = {
|
|
14
10
|
'@type': 'struct'
|
|
15
11
|
'@name': 'regex_syntax::hir::Hir'
|
|
16
|
-
|
|
17
|
-
italic: boolean;
|
|
18
|
-
size: number;
|
|
12
|
+
kind: HirKind
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
|
|
@@ -41,56 +35,56 @@ export type HirKindLiteralVariant = {
|
|
|
41
35
|
'@type': 'struct'
|
|
42
36
|
'@name': 'regex_syntax::hir::HirKind'
|
|
43
37
|
'@variant': 'Literal'
|
|
44
|
-
'
|
|
38
|
+
'@values': [Literal]
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export type HirKindClassVariant = {
|
|
48
42
|
'@type': 'struct'
|
|
49
43
|
'@name': 'regex_syntax::hir::HirKind'
|
|
50
44
|
'@variant': 'Class'
|
|
51
|
-
'
|
|
45
|
+
'@values': [Class]
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
export type HirKindAnchorVariant = {
|
|
55
49
|
'@type': 'struct'
|
|
56
50
|
'@name': 'regex_syntax::hir::HirKind'
|
|
57
51
|
'@variant': 'Anchor'
|
|
58
|
-
'
|
|
52
|
+
'@values': [Anchor]
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
export type HirKindWordBoundaryVariant = {
|
|
62
56
|
'@type': 'struct'
|
|
63
57
|
'@name': 'regex_syntax::hir::HirKind'
|
|
64
58
|
'@variant': 'WordBoundary'
|
|
65
|
-
'
|
|
59
|
+
'@values': [WordBoundary]
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export type HirKindRepetitionVariant = {
|
|
69
63
|
'@type': 'struct'
|
|
70
64
|
'@name': 'regex_syntax::hir::HirKind'
|
|
71
65
|
'@variant': 'Repetition'
|
|
72
|
-
'
|
|
66
|
+
'@values': [Repetition]
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
export type HirKindGroupVariant = {
|
|
76
70
|
'@type': 'struct'
|
|
77
71
|
'@name': 'regex_syntax::hir::HirKind'
|
|
78
72
|
'@variant': 'Group'
|
|
79
|
-
'
|
|
73
|
+
'@values': [Group]
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
export type HirKindConcatVariant = {
|
|
83
77
|
'@type': 'struct'
|
|
84
78
|
'@name': 'regex_syntax::hir::HirKind'
|
|
85
79
|
'@variant': 'Concat'
|
|
86
|
-
'
|
|
80
|
+
'@values': [Hir[]]
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
export type HirKindAlternationVariant = {
|
|
90
84
|
'@type': 'struct'
|
|
91
85
|
'@name': 'regex_syntax::hir::HirKind'
|
|
92
86
|
'@variant': 'Alternation'
|
|
93
|
-
'
|
|
87
|
+
'@values': [Hir[]]
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
|
|
@@ -103,14 +97,14 @@ export type LiteralUnicodeVariant = {
|
|
|
103
97
|
'@type': 'struct'
|
|
104
98
|
'@name': 'regex_syntax::hir::Literal'
|
|
105
99
|
'@variant': 'Unicode'
|
|
106
|
-
'
|
|
100
|
+
'@values': [string]
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
export type LiteralByteVariant = {
|
|
110
104
|
'@type': 'struct'
|
|
111
105
|
'@name': 'regex_syntax::hir::Literal'
|
|
112
106
|
'@variant': 'Byte'
|
|
113
|
-
'
|
|
107
|
+
'@values': [number]
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
|
|
@@ -123,14 +117,14 @@ export type ClassUnicodeVariant = {
|
|
|
123
117
|
'@type': 'struct'
|
|
124
118
|
'@name': 'regex_syntax::hir::Class'
|
|
125
119
|
'@variant': 'Unicode'
|
|
126
|
-
'
|
|
120
|
+
'@values': [ClassUnicode]
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
export type ClassByteVariant = {
|
|
130
124
|
'@type': 'struct'
|
|
131
125
|
'@name': 'regex_syntax::hir::Class'
|
|
132
126
|
'@variant': 'Bytes'
|
|
133
|
-
'
|
|
127
|
+
'@values': [ClassBytes]
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
|
|
@@ -271,7 +265,7 @@ export type RepetitionKindRangeVariant = {
|
|
|
271
265
|
'@type': 'struct'
|
|
272
266
|
'@name': 'regex_syntax::hir::Repetition'
|
|
273
267
|
'@variant': 'Range'
|
|
274
|
-
|
|
268
|
+
'@values': [RepetitionRange]
|
|
275
269
|
}
|
|
276
270
|
|
|
277
271
|
|
|
@@ -285,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
|
|
|
285
279
|
'@type': 'struct'
|
|
286
280
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
287
281
|
'@variant': 'Exactly'
|
|
288
|
-
|
|
282
|
+
'@values': [number]
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
export type RepetitionRangeAtLeastVariant = {
|
|
292
286
|
'@type': 'struct'
|
|
293
287
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
294
288
|
'@variant': 'AtLeast'
|
|
295
|
-
|
|
289
|
+
'@values': [number]
|
|
296
290
|
}
|
|
297
291
|
|
|
298
292
|
export type RepetitionRangeBoundedVariant = {
|
|
299
293
|
'@type': 'struct'
|
|
300
294
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
301
295
|
'@variant': 'Bounded'
|
|
302
|
-
|
|
296
|
+
'@values': [number, number]
|
|
303
297
|
}
|
|
304
298
|
|
|
305
299
|
|
|
@@ -526,7 +520,6 @@ export interface InitOutput {
|
|
|
526
520
|
readonly rregex_shortestMatchAt: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
527
521
|
readonly rregex_syntax: (a: number) => number;
|
|
528
522
|
readonly rregex_toString: (a: number, b: number) => void;
|
|
529
|
-
readonly get_metadata: () => number;
|
|
530
523
|
readonly __wbg_rregexset_free: (a: number) => void;
|
|
531
524
|
readonly rregexset_new: (a: number) => number;
|
|
532
525
|
readonly rregexset_isMatch: (a: number, b: number, c: number) => number;
|
|
@@ -547,3 +540,15 @@ export interface InitOutput {
|
|
|
547
540
|
* @returns {Promise<InitOutput>}
|
|
548
541
|
*/
|
|
549
542
|
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
543
|
+
|
|
544
|
+
export const metadata: {
|
|
545
|
+
"name": "rregex",
|
|
546
|
+
"description": "Rust Regex binding for Javascript",
|
|
547
|
+
"authors": [
|
|
548
|
+
"Fede Ramirez <i@2fd.me>"
|
|
549
|
+
],
|
|
550
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
551
|
+
"repository": "https://github.com/2fd/rregex",
|
|
552
|
+
"regex": "1.1.9",
|
|
553
|
+
"regex-syntax": "0.6.25"
|
|
554
|
+
}
|
package/lib/browser.js
CHANGED
|
@@ -196,14 +196,6 @@ export function escape(text) {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
/**
|
|
200
|
-
* @returns {any}
|
|
201
|
-
*/
|
|
202
|
-
export function get_metadata() {
|
|
203
|
-
var ret = wasm.get_metadata();
|
|
204
|
-
return takeObject(ret);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
199
|
let stack_pointer = 32;
|
|
208
200
|
|
|
209
201
|
function addBorrowedObject(obj) {
|
|
@@ -670,3 +662,15 @@ async function init(input) {
|
|
|
670
662
|
|
|
671
663
|
export default init;
|
|
672
664
|
|
|
665
|
+
|
|
666
|
+
export const metadata = {
|
|
667
|
+
"name": "rregex",
|
|
668
|
+
"description": "Rust Regex binding for Javascript",
|
|
669
|
+
"authors": [
|
|
670
|
+
"Fede Ramirez <i@2fd.me>"
|
|
671
|
+
],
|
|
672
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
673
|
+
"repository": "https://github.com/2fd/rregex",
|
|
674
|
+
"regex": "1.1.9",
|
|
675
|
+
"regex-syntax": "0.6.25"
|
|
676
|
+
}
|
package/lib/commonjs.d.ts
CHANGED
|
@@ -5,17 +5,11 @@
|
|
|
5
5
|
* @returns {string}
|
|
6
6
|
*/
|
|
7
7
|
export function escape(text: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* @returns {any}
|
|
10
|
-
*/
|
|
11
|
-
export function get_metadata(): any;
|
|
12
8
|
|
|
13
9
|
export type Hir = {
|
|
14
10
|
'@type': 'struct'
|
|
15
11
|
'@name': 'regex_syntax::hir::Hir'
|
|
16
|
-
|
|
17
|
-
italic: boolean;
|
|
18
|
-
size: number;
|
|
12
|
+
kind: HirKind
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
|
|
@@ -41,56 +35,56 @@ export type HirKindLiteralVariant = {
|
|
|
41
35
|
'@type': 'struct'
|
|
42
36
|
'@name': 'regex_syntax::hir::HirKind'
|
|
43
37
|
'@variant': 'Literal'
|
|
44
|
-
'
|
|
38
|
+
'@values': [Literal]
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export type HirKindClassVariant = {
|
|
48
42
|
'@type': 'struct'
|
|
49
43
|
'@name': 'regex_syntax::hir::HirKind'
|
|
50
44
|
'@variant': 'Class'
|
|
51
|
-
'
|
|
45
|
+
'@values': [Class]
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
export type HirKindAnchorVariant = {
|
|
55
49
|
'@type': 'struct'
|
|
56
50
|
'@name': 'regex_syntax::hir::HirKind'
|
|
57
51
|
'@variant': 'Anchor'
|
|
58
|
-
'
|
|
52
|
+
'@values': [Anchor]
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
export type HirKindWordBoundaryVariant = {
|
|
62
56
|
'@type': 'struct'
|
|
63
57
|
'@name': 'regex_syntax::hir::HirKind'
|
|
64
58
|
'@variant': 'WordBoundary'
|
|
65
|
-
'
|
|
59
|
+
'@values': [WordBoundary]
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export type HirKindRepetitionVariant = {
|
|
69
63
|
'@type': 'struct'
|
|
70
64
|
'@name': 'regex_syntax::hir::HirKind'
|
|
71
65
|
'@variant': 'Repetition'
|
|
72
|
-
'
|
|
66
|
+
'@values': [Repetition]
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
export type HirKindGroupVariant = {
|
|
76
70
|
'@type': 'struct'
|
|
77
71
|
'@name': 'regex_syntax::hir::HirKind'
|
|
78
72
|
'@variant': 'Group'
|
|
79
|
-
'
|
|
73
|
+
'@values': [Group]
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
export type HirKindConcatVariant = {
|
|
83
77
|
'@type': 'struct'
|
|
84
78
|
'@name': 'regex_syntax::hir::HirKind'
|
|
85
79
|
'@variant': 'Concat'
|
|
86
|
-
'
|
|
80
|
+
'@values': [Hir[]]
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
export type HirKindAlternationVariant = {
|
|
90
84
|
'@type': 'struct'
|
|
91
85
|
'@name': 'regex_syntax::hir::HirKind'
|
|
92
86
|
'@variant': 'Alternation'
|
|
93
|
-
'
|
|
87
|
+
'@values': [Hir[]]
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
|
|
@@ -103,14 +97,14 @@ export type LiteralUnicodeVariant = {
|
|
|
103
97
|
'@type': 'struct'
|
|
104
98
|
'@name': 'regex_syntax::hir::Literal'
|
|
105
99
|
'@variant': 'Unicode'
|
|
106
|
-
'
|
|
100
|
+
'@values': [string]
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
export type LiteralByteVariant = {
|
|
110
104
|
'@type': 'struct'
|
|
111
105
|
'@name': 'regex_syntax::hir::Literal'
|
|
112
106
|
'@variant': 'Byte'
|
|
113
|
-
'
|
|
107
|
+
'@values': [number]
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
|
|
@@ -123,14 +117,14 @@ export type ClassUnicodeVariant = {
|
|
|
123
117
|
'@type': 'struct'
|
|
124
118
|
'@name': 'regex_syntax::hir::Class'
|
|
125
119
|
'@variant': 'Unicode'
|
|
126
|
-
'
|
|
120
|
+
'@values': [ClassUnicode]
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
export type ClassByteVariant = {
|
|
130
124
|
'@type': 'struct'
|
|
131
125
|
'@name': 'regex_syntax::hir::Class'
|
|
132
126
|
'@variant': 'Bytes'
|
|
133
|
-
'
|
|
127
|
+
'@values': [ClassBytes]
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
|
|
@@ -271,7 +265,7 @@ export type RepetitionKindRangeVariant = {
|
|
|
271
265
|
'@type': 'struct'
|
|
272
266
|
'@name': 'regex_syntax::hir::Repetition'
|
|
273
267
|
'@variant': 'Range'
|
|
274
|
-
|
|
268
|
+
'@values': [RepetitionRange]
|
|
275
269
|
}
|
|
276
270
|
|
|
277
271
|
|
|
@@ -285,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
|
|
|
285
279
|
'@type': 'struct'
|
|
286
280
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
287
281
|
'@variant': 'Exactly'
|
|
288
|
-
|
|
282
|
+
'@values': [number]
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
export type RepetitionRangeAtLeastVariant = {
|
|
292
286
|
'@type': 'struct'
|
|
293
287
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
294
288
|
'@variant': 'AtLeast'
|
|
295
|
-
|
|
289
|
+
'@values': [number]
|
|
296
290
|
}
|
|
297
291
|
|
|
298
292
|
export type RepetitionRangeBoundedVariant = {
|
|
299
293
|
'@type': 'struct'
|
|
300
294
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
301
295
|
'@variant': 'Bounded'
|
|
302
|
-
|
|
296
|
+
'@values': [number, number]
|
|
303
297
|
}
|
|
304
298
|
|
|
305
299
|
|
|
@@ -504,3 +498,15 @@ export class RRegexSet {
|
|
|
504
498
|
*/
|
|
505
499
|
matches(text: string): any;
|
|
506
500
|
}
|
|
501
|
+
|
|
502
|
+
export const metadata: {
|
|
503
|
+
"name": "rregex",
|
|
504
|
+
"description": "Rust Regex binding for Javascript",
|
|
505
|
+
"authors": [
|
|
506
|
+
"Fede Ramirez <i@2fd.me>"
|
|
507
|
+
],
|
|
508
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
509
|
+
"repository": "https://github.com/2fd/rregex",
|
|
510
|
+
"regex": "1.1.9",
|
|
511
|
+
"regex-syntax": "0.6.25"
|
|
512
|
+
}
|
package/lib/commonjs.js
CHANGED
|
@@ -198,14 +198,6 @@ module.exports.escape = function(text) {
|
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
-
/**
|
|
202
|
-
* @returns {any}
|
|
203
|
-
*/
|
|
204
|
-
module.exports.get_metadata = function() {
|
|
205
|
-
var ret = wasm.get_metadata();
|
|
206
|
-
return takeObject(ret);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
201
|
let stack_pointer = 32;
|
|
210
202
|
|
|
211
203
|
function addBorrowedObject(obj) {
|
|
@@ -643,3 +635,15 @@ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
|
643
635
|
wasm = wasmInstance.exports;
|
|
644
636
|
module.exports.__wasm = wasm;
|
|
645
637
|
|
|
638
|
+
|
|
639
|
+
module.exports.metadata = {
|
|
640
|
+
"name": "rregex",
|
|
641
|
+
"description": "Rust Regex binding for Javascript",
|
|
642
|
+
"authors": [
|
|
643
|
+
"Fede Ramirez <i@2fd.me>"
|
|
644
|
+
],
|
|
645
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
646
|
+
"repository": "https://github.com/2fd/rregex",
|
|
647
|
+
"regex": "1.1.9",
|
|
648
|
+
"regex-syntax": "0.6.25"
|
|
649
|
+
}
|
package/lib/module.d.ts
CHANGED
|
@@ -5,17 +5,11 @@
|
|
|
5
5
|
* @returns {string}
|
|
6
6
|
*/
|
|
7
7
|
export function escape(text: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* @returns {any}
|
|
10
|
-
*/
|
|
11
|
-
export function get_metadata(): any;
|
|
12
8
|
|
|
13
9
|
export type Hir = {
|
|
14
10
|
'@type': 'struct'
|
|
15
11
|
'@name': 'regex_syntax::hir::Hir'
|
|
16
|
-
|
|
17
|
-
italic: boolean;
|
|
18
|
-
size: number;
|
|
12
|
+
kind: HirKind
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
|
|
@@ -41,56 +35,56 @@ export type HirKindLiteralVariant = {
|
|
|
41
35
|
'@type': 'struct'
|
|
42
36
|
'@name': 'regex_syntax::hir::HirKind'
|
|
43
37
|
'@variant': 'Literal'
|
|
44
|
-
'
|
|
38
|
+
'@values': [Literal]
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export type HirKindClassVariant = {
|
|
48
42
|
'@type': 'struct'
|
|
49
43
|
'@name': 'regex_syntax::hir::HirKind'
|
|
50
44
|
'@variant': 'Class'
|
|
51
|
-
'
|
|
45
|
+
'@values': [Class]
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
export type HirKindAnchorVariant = {
|
|
55
49
|
'@type': 'struct'
|
|
56
50
|
'@name': 'regex_syntax::hir::HirKind'
|
|
57
51
|
'@variant': 'Anchor'
|
|
58
|
-
'
|
|
52
|
+
'@values': [Anchor]
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
export type HirKindWordBoundaryVariant = {
|
|
62
56
|
'@type': 'struct'
|
|
63
57
|
'@name': 'regex_syntax::hir::HirKind'
|
|
64
58
|
'@variant': 'WordBoundary'
|
|
65
|
-
'
|
|
59
|
+
'@values': [WordBoundary]
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export type HirKindRepetitionVariant = {
|
|
69
63
|
'@type': 'struct'
|
|
70
64
|
'@name': 'regex_syntax::hir::HirKind'
|
|
71
65
|
'@variant': 'Repetition'
|
|
72
|
-
'
|
|
66
|
+
'@values': [Repetition]
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
export type HirKindGroupVariant = {
|
|
76
70
|
'@type': 'struct'
|
|
77
71
|
'@name': 'regex_syntax::hir::HirKind'
|
|
78
72
|
'@variant': 'Group'
|
|
79
|
-
'
|
|
73
|
+
'@values': [Group]
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
export type HirKindConcatVariant = {
|
|
83
77
|
'@type': 'struct'
|
|
84
78
|
'@name': 'regex_syntax::hir::HirKind'
|
|
85
79
|
'@variant': 'Concat'
|
|
86
|
-
'
|
|
80
|
+
'@values': [Hir[]]
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
export type HirKindAlternationVariant = {
|
|
90
84
|
'@type': 'struct'
|
|
91
85
|
'@name': 'regex_syntax::hir::HirKind'
|
|
92
86
|
'@variant': 'Alternation'
|
|
93
|
-
'
|
|
87
|
+
'@values': [Hir[]]
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
|
|
@@ -103,14 +97,14 @@ export type LiteralUnicodeVariant = {
|
|
|
103
97
|
'@type': 'struct'
|
|
104
98
|
'@name': 'regex_syntax::hir::Literal'
|
|
105
99
|
'@variant': 'Unicode'
|
|
106
|
-
'
|
|
100
|
+
'@values': [string]
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
export type LiteralByteVariant = {
|
|
110
104
|
'@type': 'struct'
|
|
111
105
|
'@name': 'regex_syntax::hir::Literal'
|
|
112
106
|
'@variant': 'Byte'
|
|
113
|
-
'
|
|
107
|
+
'@values': [number]
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
|
|
@@ -123,14 +117,14 @@ export type ClassUnicodeVariant = {
|
|
|
123
117
|
'@type': 'struct'
|
|
124
118
|
'@name': 'regex_syntax::hir::Class'
|
|
125
119
|
'@variant': 'Unicode'
|
|
126
|
-
'
|
|
120
|
+
'@values': [ClassUnicode]
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
export type ClassByteVariant = {
|
|
130
124
|
'@type': 'struct'
|
|
131
125
|
'@name': 'regex_syntax::hir::Class'
|
|
132
126
|
'@variant': 'Bytes'
|
|
133
|
-
'
|
|
127
|
+
'@values': [ClassBytes]
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
|
|
@@ -271,7 +265,7 @@ export type RepetitionKindRangeVariant = {
|
|
|
271
265
|
'@type': 'struct'
|
|
272
266
|
'@name': 'regex_syntax::hir::Repetition'
|
|
273
267
|
'@variant': 'Range'
|
|
274
|
-
|
|
268
|
+
'@values': [RepetitionRange]
|
|
275
269
|
}
|
|
276
270
|
|
|
277
271
|
|
|
@@ -285,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
|
|
|
285
279
|
'@type': 'struct'
|
|
286
280
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
287
281
|
'@variant': 'Exactly'
|
|
288
|
-
|
|
282
|
+
'@values': [number]
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
export type RepetitionRangeAtLeastVariant = {
|
|
292
286
|
'@type': 'struct'
|
|
293
287
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
294
288
|
'@variant': 'AtLeast'
|
|
295
|
-
|
|
289
|
+
'@values': [number]
|
|
296
290
|
}
|
|
297
291
|
|
|
298
292
|
export type RepetitionRangeBoundedVariant = {
|
|
299
293
|
'@type': 'struct'
|
|
300
294
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
301
295
|
'@variant': 'Bounded'
|
|
302
|
-
|
|
296
|
+
'@values': [number, number]
|
|
303
297
|
}
|
|
304
298
|
|
|
305
299
|
|
|
@@ -504,3 +498,15 @@ export class RRegexSet {
|
|
|
504
498
|
*/
|
|
505
499
|
matches(text: string): any;
|
|
506
500
|
}
|
|
501
|
+
|
|
502
|
+
export const metadata: {
|
|
503
|
+
"name": "rregex",
|
|
504
|
+
"description": "Rust Regex binding for Javascript",
|
|
505
|
+
"authors": [
|
|
506
|
+
"Fede Ramirez <i@2fd.me>"
|
|
507
|
+
],
|
|
508
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
509
|
+
"repository": "https://github.com/2fd/rregex",
|
|
510
|
+
"regex": "1.1.9",
|
|
511
|
+
"regex-syntax": "0.6.25"
|
|
512
|
+
}
|
package/lib/module.js
CHANGED
|
@@ -199,14 +199,6 @@ export function escape(text) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
/**
|
|
203
|
-
* @returns {any}
|
|
204
|
-
*/
|
|
205
|
-
export function get_metadata() {
|
|
206
|
-
var ret = wasm.get_metadata();
|
|
207
|
-
return takeObject(ret);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
202
|
let stack_pointer = 32;
|
|
211
203
|
|
|
212
204
|
function addBorrowedObject(obj) {
|
package/lib/rregex.wasm
CHANGED
|
Binary file
|
package/lib/rregex.wasm.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export function rregex_shortestMatch(a: number, b: number, c: number, d: number)
|
|
|
18
18
|
export function rregex_shortestMatchAt(a: number, b: number, c: number, d: number, e: number): void;
|
|
19
19
|
export function rregex_syntax(a: number): number;
|
|
20
20
|
export function rregex_toString(a: number, b: number): void;
|
|
21
|
-
export function get_metadata(): number;
|
|
22
21
|
export function __wbg_rregexset_free(a: number): void;
|
|
23
22
|
export function rregexset_new(a: number): number;
|
|
24
23
|
export function rregexset_isMatch(a: number, b: number, c: number): number;
|
package/lib/types.d.ts
CHANGED
|
@@ -5,17 +5,11 @@
|
|
|
5
5
|
* @returns {string}
|
|
6
6
|
*/
|
|
7
7
|
export function escape(text: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* @returns {any}
|
|
10
|
-
*/
|
|
11
|
-
export function get_metadata(): any;
|
|
12
8
|
|
|
13
9
|
export type Hir = {
|
|
14
10
|
'@type': 'struct'
|
|
15
11
|
'@name': 'regex_syntax::hir::Hir'
|
|
16
|
-
|
|
17
|
-
italic: boolean;
|
|
18
|
-
size: number;
|
|
12
|
+
kind: HirKind
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
|
|
@@ -41,56 +35,56 @@ export type HirKindLiteralVariant = {
|
|
|
41
35
|
'@type': 'struct'
|
|
42
36
|
'@name': 'regex_syntax::hir::HirKind'
|
|
43
37
|
'@variant': 'Literal'
|
|
44
|
-
'
|
|
38
|
+
'@values': [Literal]
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export type HirKindClassVariant = {
|
|
48
42
|
'@type': 'struct'
|
|
49
43
|
'@name': 'regex_syntax::hir::HirKind'
|
|
50
44
|
'@variant': 'Class'
|
|
51
|
-
'
|
|
45
|
+
'@values': [Class]
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
export type HirKindAnchorVariant = {
|
|
55
49
|
'@type': 'struct'
|
|
56
50
|
'@name': 'regex_syntax::hir::HirKind'
|
|
57
51
|
'@variant': 'Anchor'
|
|
58
|
-
'
|
|
52
|
+
'@values': [Anchor]
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
export type HirKindWordBoundaryVariant = {
|
|
62
56
|
'@type': 'struct'
|
|
63
57
|
'@name': 'regex_syntax::hir::HirKind'
|
|
64
58
|
'@variant': 'WordBoundary'
|
|
65
|
-
'
|
|
59
|
+
'@values': [WordBoundary]
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export type HirKindRepetitionVariant = {
|
|
69
63
|
'@type': 'struct'
|
|
70
64
|
'@name': 'regex_syntax::hir::HirKind'
|
|
71
65
|
'@variant': 'Repetition'
|
|
72
|
-
'
|
|
66
|
+
'@values': [Repetition]
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
export type HirKindGroupVariant = {
|
|
76
70
|
'@type': 'struct'
|
|
77
71
|
'@name': 'regex_syntax::hir::HirKind'
|
|
78
72
|
'@variant': 'Group'
|
|
79
|
-
'
|
|
73
|
+
'@values': [Group]
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
export type HirKindConcatVariant = {
|
|
83
77
|
'@type': 'struct'
|
|
84
78
|
'@name': 'regex_syntax::hir::HirKind'
|
|
85
79
|
'@variant': 'Concat'
|
|
86
|
-
'
|
|
80
|
+
'@values': [Hir[]]
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
export type HirKindAlternationVariant = {
|
|
90
84
|
'@type': 'struct'
|
|
91
85
|
'@name': 'regex_syntax::hir::HirKind'
|
|
92
86
|
'@variant': 'Alternation'
|
|
93
|
-
'
|
|
87
|
+
'@values': [Hir[]]
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
|
|
@@ -103,14 +97,14 @@ export type LiteralUnicodeVariant = {
|
|
|
103
97
|
'@type': 'struct'
|
|
104
98
|
'@name': 'regex_syntax::hir::Literal'
|
|
105
99
|
'@variant': 'Unicode'
|
|
106
|
-
'
|
|
100
|
+
'@values': [string]
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
export type LiteralByteVariant = {
|
|
110
104
|
'@type': 'struct'
|
|
111
105
|
'@name': 'regex_syntax::hir::Literal'
|
|
112
106
|
'@variant': 'Byte'
|
|
113
|
-
'
|
|
107
|
+
'@values': [number]
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
|
|
@@ -123,14 +117,14 @@ export type ClassUnicodeVariant = {
|
|
|
123
117
|
'@type': 'struct'
|
|
124
118
|
'@name': 'regex_syntax::hir::Class'
|
|
125
119
|
'@variant': 'Unicode'
|
|
126
|
-
'
|
|
120
|
+
'@values': [ClassUnicode]
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
export type ClassByteVariant = {
|
|
130
124
|
'@type': 'struct'
|
|
131
125
|
'@name': 'regex_syntax::hir::Class'
|
|
132
126
|
'@variant': 'Bytes'
|
|
133
|
-
'
|
|
127
|
+
'@values': [ClassBytes]
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
|
|
@@ -271,7 +265,7 @@ export type RepetitionKindRangeVariant = {
|
|
|
271
265
|
'@type': 'struct'
|
|
272
266
|
'@name': 'regex_syntax::hir::Repetition'
|
|
273
267
|
'@variant': 'Range'
|
|
274
|
-
|
|
268
|
+
'@values': [RepetitionRange]
|
|
275
269
|
}
|
|
276
270
|
|
|
277
271
|
|
|
@@ -285,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
|
|
|
285
279
|
'@type': 'struct'
|
|
286
280
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
287
281
|
'@variant': 'Exactly'
|
|
288
|
-
|
|
282
|
+
'@values': [number]
|
|
289
283
|
}
|
|
290
284
|
|
|
291
285
|
export type RepetitionRangeAtLeastVariant = {
|
|
292
286
|
'@type': 'struct'
|
|
293
287
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
294
288
|
'@variant': 'AtLeast'
|
|
295
|
-
|
|
289
|
+
'@values': [number]
|
|
296
290
|
}
|
|
297
291
|
|
|
298
292
|
export type RepetitionRangeBoundedVariant = {
|
|
299
293
|
'@type': 'struct'
|
|
300
294
|
'@name': 'regex_syntax::hir::RepetitionRange'
|
|
301
295
|
'@variant': 'Bounded'
|
|
302
|
-
|
|
296
|
+
'@values': [number, number]
|
|
303
297
|
}
|
|
304
298
|
|
|
305
299
|
|
|
@@ -526,7 +520,6 @@ export interface InitOutput {
|
|
|
526
520
|
readonly rregex_shortestMatchAt: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
527
521
|
readonly rregex_syntax: (a: number) => number;
|
|
528
522
|
readonly rregex_toString: (a: number, b: number) => void;
|
|
529
|
-
readonly get_metadata: () => number;
|
|
530
523
|
readonly __wbg_rregexset_free: (a: number) => void;
|
|
531
524
|
readonly rregexset_new: (a: number) => number;
|
|
532
525
|
readonly rregexset_isMatch: (a: number, b: number, c: number) => number;
|
|
@@ -547,3 +540,15 @@ export interface InitOutput {
|
|
|
547
540
|
* @returns {Promise<InitOutput>}
|
|
548
541
|
*/
|
|
549
542
|
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
543
|
+
|
|
544
|
+
export const metadata: {
|
|
545
|
+
"name": "rregex",
|
|
546
|
+
"description": "Rust Regex binding for Javascript",
|
|
547
|
+
"authors": [
|
|
548
|
+
"Fede Ramirez <i@2fd.me>"
|
|
549
|
+
],
|
|
550
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
551
|
+
"repository": "https://github.com/2fd/rregex",
|
|
552
|
+
"regex": "1.1.9",
|
|
553
|
+
"regex-syntax": "0.6.25"
|
|
554
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rregex",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Rust Regex binding for Javascript",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./lib/commonjs.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"babel-jest": "^27.4.2",
|
|
17
17
|
"jest": "^27.4.3",
|
|
18
18
|
"semantic-release": "^18.0.1",
|
|
19
|
+
"toml": "^3.0.0",
|
|
19
20
|
"typescript": "^4.5.2"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
@@ -29,7 +30,19 @@
|
|
|
29
30
|
"release": {
|
|
30
31
|
"ci": false,
|
|
31
32
|
"branches": [
|
|
32
|
-
|
|
33
|
+
{
|
|
34
|
+
"name": "1.0.x",
|
|
35
|
+
"range": "1.0.x",
|
|
36
|
+
"channel": "1.0.x"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "1.1.x",
|
|
40
|
+
"range": "1.1.x",
|
|
41
|
+
"channel": "1.1.x"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "master"
|
|
45
|
+
}
|
|
33
46
|
]
|
|
34
47
|
},
|
|
35
48
|
"repository": {
|
package/babel.config.js
DELETED
package/jest.transform.js
DELETED
package/test/rregex.test.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { RRegex, RRegexSet } from '../lib/commonjs'
|
|
2
|
-
|
|
3
|
-
describe(`RRegex`, () => {
|
|
4
|
-
test(`toString`, () => {
|
|
5
|
-
expect(new RRegex('a').toString()).toBe('a')
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test(`isMatch`, () => {
|
|
9
|
-
const regex = new RRegex('a')
|
|
10
|
-
expect(regex.isMatch('abc')).toBe(true)
|
|
11
|
-
expect(regex.isMatch('def')).toBe(false)
|
|
12
|
-
|
|
13
|
-
const text = 'I categorically deny having triskaidekaphobia.';
|
|
14
|
-
const re = new RRegex('\\b\\w{13}\\b')
|
|
15
|
-
expect(re.isMatch(text)).toEqual(true);
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test(`isMatchAt`, () => {
|
|
19
|
-
const regex = new RRegex('a')
|
|
20
|
-
expect(regex.isMatchAt('ab', 0)).toBe(true)
|
|
21
|
-
expect(regex.isMatchAt('ab', 1)).toBe(false)
|
|
22
|
-
expect(regex.isMatchAt('ab', 1)).toBe(false)
|
|
23
|
-
expect(regex.isMatchAt('ab', 100)).toBe(false)
|
|
24
|
-
expect(regex.isMatchAt('aba', 0)).toBe(true)
|
|
25
|
-
expect(regex.isMatchAt('aba', 1)).toBe(true)
|
|
26
|
-
expect(regex.isMatchAt('aba', 2)).toBe(true)
|
|
27
|
-
expect(regex.isMatchAt('aba', 3)).toBe(false)
|
|
28
|
-
expect(regex.isMatchAt('aba', 100)).toBe(false)
|
|
29
|
-
expect(regex.isMatchAt('def', 0)).toBe(false)
|
|
30
|
-
|
|
31
|
-
const text = 'I categorically deny having triskaidekaphobia.'
|
|
32
|
-
const re = new RRegex('\\b\\w{13}\\b')
|
|
33
|
-
expect(re.isMatchAt(text, 1)).toBe(true)
|
|
34
|
-
expect(re.isMatchAt(text, 5)).toBe(false)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
test(`find`, () => {
|
|
38
|
-
const regex = new RRegex('a')
|
|
39
|
-
expect(regex.find('abc')).toEqual({ value: 'a', start: 0, end: 1 })
|
|
40
|
-
expect(regex.find('def')).toBeUndefined()
|
|
41
|
-
|
|
42
|
-
const text = 'I categorically deny having triskaidekaphobia.'
|
|
43
|
-
const re = new RRegex('\\b\\w{13}\\b')
|
|
44
|
-
expect(re.find(text)).toEqual({
|
|
45
|
-
value: 'categorically',
|
|
46
|
-
start: 2,
|
|
47
|
-
end: 15,
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test(`findAt`, () => {
|
|
52
|
-
const regex = new RRegex('a')
|
|
53
|
-
expect(regex.find('abc')).toEqual({ value: 'a', start: 0, end: 1 })
|
|
54
|
-
expect(regex.findAt('abc', 1)).toBeUndefined()
|
|
55
|
-
expect(regex.findAt('abc', 100)).toBeUndefined()
|
|
56
|
-
expect(regex.find('def')).toBeUndefined()
|
|
57
|
-
|
|
58
|
-
const text = 'I categorically deny having triskaidekaphobia.'
|
|
59
|
-
const re = new RRegex('\\b\\w{13}\\b')
|
|
60
|
-
expect(re.findAt(text, 1)).toEqual({
|
|
61
|
-
value: 'categorically',
|
|
62
|
-
start: 2,
|
|
63
|
-
end: 15,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
expect(re.findAt(text, 5)).toEqual(undefined)
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test(`findAll`, () => {
|
|
70
|
-
const regex = new RRegex('a')
|
|
71
|
-
expect(regex.findAll('abcabcabc')).toEqual([
|
|
72
|
-
{ value: 'a', start: 0, end: 1 },
|
|
73
|
-
{ value: 'a', start: 3, end: 4 },
|
|
74
|
-
{ value: 'a', start: 6, end: 7 },
|
|
75
|
-
])
|
|
76
|
-
expect(regex.findAll('def')).toEqual([])
|
|
77
|
-
|
|
78
|
-
const text = 'Retroactively relinquishing remunerations is reprehensible.'
|
|
79
|
-
const re = new RRegex('\\b\\w{13}\\b')
|
|
80
|
-
expect(re.findAll(text)).toEqual([
|
|
81
|
-
{
|
|
82
|
-
"end": 13,
|
|
83
|
-
"start": 0,
|
|
84
|
-
"value": "Retroactively",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"end": 27,
|
|
88
|
-
"start": 14,
|
|
89
|
-
"value": "relinquishing",
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"end": 41,
|
|
93
|
-
"start": 28,
|
|
94
|
-
"value": "remunerations",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"end": 58,
|
|
98
|
-
"start": 45,
|
|
99
|
-
"value": "reprehensible",
|
|
100
|
-
},
|
|
101
|
-
])
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test(`replace`, () => {
|
|
105
|
-
const regex = new RRegex('a')
|
|
106
|
-
expect(regex.replace('abcabcabc', 'z')).toEqual('zbcabcabc')
|
|
107
|
-
expect(regex.replace('defdefdef', 'z')).toEqual('defdefdef')
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
const re = new RRegex('[^01]+')
|
|
111
|
-
expect(re.replace('1078910', '')).toBe('1010')
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
const re = new RRegex('(?P<last>[^,\\s]+),\\s+(?P<first>\\S+)')
|
|
116
|
-
const result = re.replace('Springsteen, Bruce', '$first $last')
|
|
117
|
-
expect(result).toEqual('Bruce Springsteen')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
const re = new RRegex('(?P<first>\\w+)\\s+(?P<second>\\w+)')
|
|
122
|
-
const result = re.replace("deep fried", "${first}_$second");
|
|
123
|
-
expect(result).toEqual('deep_fried')
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
test(`replaceAll`, () => {
|
|
128
|
-
const regex = new RRegex('a')
|
|
129
|
-
expect(regex.replaceAll('abcabcabc', 'z')).toEqual('zbczbczbc')
|
|
130
|
-
expect(regex.replaceAll('defdefdef', 'z')).toEqual('defdefdef')
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test(`replacen`, () => {
|
|
134
|
-
const regex = new RRegex('a')
|
|
135
|
-
expect(regex.replacen('abcabcabc', 2, 'z')).toEqual('zbczbcabc')
|
|
136
|
-
expect(regex.replacen('defdefdef', 2, 'z')).toEqual('defdefdef')
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test(`split`, () => {
|
|
140
|
-
const regex = new RRegex('a')
|
|
141
|
-
expect(regex.split('abcabcabc')).toEqual(['', 'bc', 'bc', 'bc'])
|
|
142
|
-
expect(regex.split('defdefdef')).toEqual(['defdefdef'])
|
|
143
|
-
|
|
144
|
-
const re = new RRegex('[ \\t]+')
|
|
145
|
-
const fields = re.split('a b \t c\td e');
|
|
146
|
-
expect(fields).toEqual(['a', 'b', 'c', 'd', 'e']);
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
test(`splitn`, () => {
|
|
150
|
-
const regex = new RRegex(',')
|
|
151
|
-
expect(regex.splitn('a,b,c', 0)).toEqual([])
|
|
152
|
-
expect(regex.splitn('a,b,c', 1)).toEqual(['a,b,c'])
|
|
153
|
-
expect(regex.splitn('a,b,c', 2)).toEqual(['a', 'b,c'])
|
|
154
|
-
expect(regex.splitn('a,b,c', 3)).toEqual(['a', 'b', 'c'])
|
|
155
|
-
expect(regex.splitn('a,b,c', 4)).toEqual(['a', 'b', 'c', ''])
|
|
156
|
-
expect(regex.splitn('a,b,c', 5)).toEqual(['a', 'b', 'c'])
|
|
157
|
-
expect(regex.splitn('abc', 0)).toEqual([])
|
|
158
|
-
expect(regex.splitn('abc', 1)).toEqual(['abc'])
|
|
159
|
-
expect(regex.splitn('abc', 2)).toEqual(['abc', ''])
|
|
160
|
-
expect(regex.splitn('abc', 3)).toEqual(['abc'])
|
|
161
|
-
|
|
162
|
-
const re = new RRegex('\\W+')
|
|
163
|
-
const fields = re.splitn('Hey! How are you?', 3)
|
|
164
|
-
expect(fields).toEqual(['Hey', 'How', 'are you?'])
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
test(`shortestMatch`, () => {
|
|
168
|
-
const regex = new RRegex('a')
|
|
169
|
-
expect(regex.shortestMatch('abcabcabc')).toEqual(1)
|
|
170
|
-
expect(regex.shortestMatch('bcabcabc')).toEqual(3)
|
|
171
|
-
expect(regex.shortestMatch('cabcabc')).toEqual(2)
|
|
172
|
-
expect(regex.shortestMatch('defdefdef')).toBeUndefined()
|
|
173
|
-
|
|
174
|
-
const text = 'aaaaa'
|
|
175
|
-
const pos = new RRegex('a+')
|
|
176
|
-
expect(pos.shortestMatch(text)).toBe(1)
|
|
177
|
-
})
|
|
178
|
-
|
|
179
|
-
test(`shortestMatchAt`, () => {
|
|
180
|
-
const regex = new RRegex('a')
|
|
181
|
-
expect(regex.shortestMatchAt('abcabca', 0)).toEqual(1)
|
|
182
|
-
expect(regex.shortestMatchAt('abcabca', 1)).toEqual(4)
|
|
183
|
-
expect(regex.shortestMatchAt('abcabca', 2)).toEqual(4)
|
|
184
|
-
expect(regex.shortestMatchAt('abcabca', 3)).toEqual(4)
|
|
185
|
-
expect(regex.shortestMatchAt('abcabca', 4)).toEqual(7)
|
|
186
|
-
expect(regex.shortestMatchAt('abcabca', 5)).toEqual(7)
|
|
187
|
-
expect(regex.shortestMatchAt('abcabca', 6)).toEqual(7)
|
|
188
|
-
expect(regex.shortestMatchAt('abcabca', 7)).toBeUndefined()
|
|
189
|
-
expect(regex.shortestMatchAt('abcabca', 100)).toBeUndefined()
|
|
190
|
-
expect(regex.shortestMatchAt('defdefdef', 0)).toBeUndefined()
|
|
191
|
-
expect(regex.shortestMatchAt('defdefdef', 1)).toBeUndefined()
|
|
192
|
-
expect(regex.shortestMatchAt('defdefdef', 2)).toBeUndefined()
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
test(`syntax`, () => {
|
|
196
|
-
const regex = new RRegex('a')
|
|
197
|
-
expect(regex.syntax()).toEqual({
|
|
198
|
-
"@name": "regex_syntax::hir::Hir",
|
|
199
|
-
"@type": "struct",
|
|
200
|
-
"kind": {
|
|
201
|
-
"@name": "regex_syntax::hir::HirKind",
|
|
202
|
-
"@type": "enum",
|
|
203
|
-
"@variant": "Literal",
|
|
204
|
-
"value": {
|
|
205
|
-
"@name": "regex_syntax::hir::Literal",
|
|
206
|
-
"@type": "enum",
|
|
207
|
-
"@variant": "Unicode",
|
|
208
|
-
"value": "a"
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
describe(`RRegexSet`, () => {
|
|
217
|
-
test(`isMatch`, () => {
|
|
218
|
-
let set = new RRegexSet(['\\w+', '\\d+'])
|
|
219
|
-
expect(set.isMatch('foo')).toBe(true)
|
|
220
|
-
expect(set.isMatch('☃')).toBe(false)
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
test(`matches`, () => {
|
|
224
|
-
let set = new RRegexSet([
|
|
225
|
-
'\\w+',
|
|
226
|
-
'\\d+',
|
|
227
|
-
'\\pL+',
|
|
228
|
-
'foo',
|
|
229
|
-
'bar',
|
|
230
|
-
'barfoo',
|
|
231
|
-
'foobar',
|
|
232
|
-
])
|
|
233
|
-
expect(set.matches('foobar')).toEqual([0, 2, 3, 4, 6])
|
|
234
|
-
})
|
|
235
|
-
})
|