rregex 1.1.1 → 1.2.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/lib/browser.d.ts CHANGED
@@ -9,9 +9,7 @@ export function escape(text: string): string;
9
9
  export type Hir = {
10
10
  '@type': 'struct'
11
11
  '@name': 'regex_syntax::hir::Hir'
12
- bold: boolean;
13
- italic: boolean;
14
- size: number;
12
+ kind: HirKind
15
13
  }
16
14
 
17
15
 
@@ -37,56 +35,56 @@ export type HirKindLiteralVariant = {
37
35
  '@type': 'struct'
38
36
  '@name': 'regex_syntax::hir::HirKind'
39
37
  '@variant': 'Literal'
40
- 'value': Literal
38
+ '@values': [Literal]
41
39
  }
42
40
 
43
41
  export type HirKindClassVariant = {
44
42
  '@type': 'struct'
45
43
  '@name': 'regex_syntax::hir::HirKind'
46
44
  '@variant': 'Class'
47
- 'value': Class
45
+ '@values': [Class]
48
46
  }
49
47
 
50
48
  export type HirKindAnchorVariant = {
51
49
  '@type': 'struct'
52
50
  '@name': 'regex_syntax::hir::HirKind'
53
51
  '@variant': 'Anchor'
54
- 'value': Anchor
52
+ '@values': [Anchor]
55
53
  }
56
54
 
57
55
  export type HirKindWordBoundaryVariant = {
58
56
  '@type': 'struct'
59
57
  '@name': 'regex_syntax::hir::HirKind'
60
58
  '@variant': 'WordBoundary'
61
- 'value': WordBoundary
59
+ '@values': [WordBoundary]
62
60
  }
63
61
 
64
62
  export type HirKindRepetitionVariant = {
65
63
  '@type': 'struct'
66
64
  '@name': 'regex_syntax::hir::HirKind'
67
65
  '@variant': 'Repetition'
68
- 'value': Repetition
66
+ '@values': [Repetition]
69
67
  }
70
68
 
71
69
  export type HirKindGroupVariant = {
72
70
  '@type': 'struct'
73
71
  '@name': 'regex_syntax::hir::HirKind'
74
72
  '@variant': 'Group'
75
- 'value': Group
73
+ '@values': [Group]
76
74
  }
77
75
 
78
76
  export type HirKindConcatVariant = {
79
77
  '@type': 'struct'
80
78
  '@name': 'regex_syntax::hir::HirKind'
81
79
  '@variant': 'Concat'
82
- 'value': Hir[]
80
+ '@values': [Hir[]]
83
81
  }
84
82
 
85
83
  export type HirKindAlternationVariant = {
86
84
  '@type': 'struct'
87
85
  '@name': 'regex_syntax::hir::HirKind'
88
86
  '@variant': 'Alternation'
89
- 'value': Hir[]
87
+ '@values': [Hir[]]
90
88
  }
91
89
 
92
90
 
@@ -99,14 +97,14 @@ export type LiteralUnicodeVariant = {
99
97
  '@type': 'struct'
100
98
  '@name': 'regex_syntax::hir::Literal'
101
99
  '@variant': 'Unicode'
102
- 'value': string
100
+ '@values': [string]
103
101
  }
104
102
 
105
103
  export type LiteralByteVariant = {
106
104
  '@type': 'struct'
107
105
  '@name': 'regex_syntax::hir::Literal'
108
106
  '@variant': 'Byte'
109
- 'value': number
107
+ '@values': [number]
110
108
  }
111
109
 
112
110
 
@@ -119,14 +117,14 @@ export type ClassUnicodeVariant = {
119
117
  '@type': 'struct'
120
118
  '@name': 'regex_syntax::hir::Class'
121
119
  '@variant': 'Unicode'
122
- 'value': ClassUnicode
120
+ '@values': [ClassUnicode]
123
121
  }
124
122
 
125
123
  export type ClassByteVariant = {
126
124
  '@type': 'struct'
127
125
  '@name': 'regex_syntax::hir::Class'
128
126
  '@variant': 'Bytes'
129
- 'value': ClassBytes
127
+ '@values': [ClassBytes]
130
128
  }
131
129
 
132
130
 
@@ -267,7 +265,7 @@ export type RepetitionKindRangeVariant = {
267
265
  '@type': 'struct'
268
266
  '@name': 'regex_syntax::hir::Repetition'
269
267
  '@variant': 'Range'
270
- value: RepetitionRange
268
+ '@values': [RepetitionRange]
271
269
  }
272
270
 
273
271
 
@@ -281,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
281
279
  '@type': 'struct'
282
280
  '@name': 'regex_syntax::hir::RepetitionRange'
283
281
  '@variant': 'Exactly'
284
- value: number
282
+ '@values': [number]
285
283
  }
286
284
 
287
285
  export type RepetitionRangeAtLeastVariant = {
288
286
  '@type': 'struct'
289
287
  '@name': 'regex_syntax::hir::RepetitionRange'
290
288
  '@variant': 'AtLeast'
291
- value: number
289
+ '@values': [number]
292
290
  }
293
291
 
294
292
  export type RepetitionRangeBoundedVariant = {
295
293
  '@type': 'struct'
296
294
  '@name': 'regex_syntax::hir::RepetitionRange'
297
295
  '@variant': 'Bounded'
298
- value: [number, number]
296
+ '@values': [number, number]
299
297
  }
300
298
 
301
299
 
@@ -551,6 +549,6 @@ export const metadata: {
551
549
  ],
552
550
  "homepage": "https://2fd.github.io/rregex",
553
551
  "repository": "https://github.com/2fd/rregex",
554
- "regex": "1.1.9",
552
+ "regex": "1.2.1",
555
553
  "regex-syntax": "0.6.25"
556
554
  }
package/lib/browser.js CHANGED
@@ -671,6 +671,6 @@ export const metadata = {
671
671
  ],
672
672
  "homepage": "https://2fd.github.io/rregex",
673
673
  "repository": "https://github.com/2fd/rregex",
674
- "regex": "1.1.9",
674
+ "regex": "1.2.1",
675
675
  "regex-syntax": "0.6.25"
676
676
  }
package/lib/commonjs.d.ts CHANGED
@@ -9,9 +9,7 @@ export function escape(text: string): string;
9
9
  export type Hir = {
10
10
  '@type': 'struct'
11
11
  '@name': 'regex_syntax::hir::Hir'
12
- bold: boolean;
13
- italic: boolean;
14
- size: number;
12
+ kind: HirKind
15
13
  }
16
14
 
17
15
 
@@ -37,56 +35,56 @@ export type HirKindLiteralVariant = {
37
35
  '@type': 'struct'
38
36
  '@name': 'regex_syntax::hir::HirKind'
39
37
  '@variant': 'Literal'
40
- 'value': Literal
38
+ '@values': [Literal]
41
39
  }
42
40
 
43
41
  export type HirKindClassVariant = {
44
42
  '@type': 'struct'
45
43
  '@name': 'regex_syntax::hir::HirKind'
46
44
  '@variant': 'Class'
47
- 'value': Class
45
+ '@values': [Class]
48
46
  }
49
47
 
50
48
  export type HirKindAnchorVariant = {
51
49
  '@type': 'struct'
52
50
  '@name': 'regex_syntax::hir::HirKind'
53
51
  '@variant': 'Anchor'
54
- 'value': Anchor
52
+ '@values': [Anchor]
55
53
  }
56
54
 
57
55
  export type HirKindWordBoundaryVariant = {
58
56
  '@type': 'struct'
59
57
  '@name': 'regex_syntax::hir::HirKind'
60
58
  '@variant': 'WordBoundary'
61
- 'value': WordBoundary
59
+ '@values': [WordBoundary]
62
60
  }
63
61
 
64
62
  export type HirKindRepetitionVariant = {
65
63
  '@type': 'struct'
66
64
  '@name': 'regex_syntax::hir::HirKind'
67
65
  '@variant': 'Repetition'
68
- 'value': Repetition
66
+ '@values': [Repetition]
69
67
  }
70
68
 
71
69
  export type HirKindGroupVariant = {
72
70
  '@type': 'struct'
73
71
  '@name': 'regex_syntax::hir::HirKind'
74
72
  '@variant': 'Group'
75
- 'value': Group
73
+ '@values': [Group]
76
74
  }
77
75
 
78
76
  export type HirKindConcatVariant = {
79
77
  '@type': 'struct'
80
78
  '@name': 'regex_syntax::hir::HirKind'
81
79
  '@variant': 'Concat'
82
- 'value': Hir[]
80
+ '@values': [Hir[]]
83
81
  }
84
82
 
85
83
  export type HirKindAlternationVariant = {
86
84
  '@type': 'struct'
87
85
  '@name': 'regex_syntax::hir::HirKind'
88
86
  '@variant': 'Alternation'
89
- 'value': Hir[]
87
+ '@values': [Hir[]]
90
88
  }
91
89
 
92
90
 
@@ -99,14 +97,14 @@ export type LiteralUnicodeVariant = {
99
97
  '@type': 'struct'
100
98
  '@name': 'regex_syntax::hir::Literal'
101
99
  '@variant': 'Unicode'
102
- 'value': string
100
+ '@values': [string]
103
101
  }
104
102
 
105
103
  export type LiteralByteVariant = {
106
104
  '@type': 'struct'
107
105
  '@name': 'regex_syntax::hir::Literal'
108
106
  '@variant': 'Byte'
109
- 'value': number
107
+ '@values': [number]
110
108
  }
111
109
 
112
110
 
@@ -119,14 +117,14 @@ export type ClassUnicodeVariant = {
119
117
  '@type': 'struct'
120
118
  '@name': 'regex_syntax::hir::Class'
121
119
  '@variant': 'Unicode'
122
- 'value': ClassUnicode
120
+ '@values': [ClassUnicode]
123
121
  }
124
122
 
125
123
  export type ClassByteVariant = {
126
124
  '@type': 'struct'
127
125
  '@name': 'regex_syntax::hir::Class'
128
126
  '@variant': 'Bytes'
129
- 'value': ClassBytes
127
+ '@values': [ClassBytes]
130
128
  }
131
129
 
132
130
 
@@ -267,7 +265,7 @@ export type RepetitionKindRangeVariant = {
267
265
  '@type': 'struct'
268
266
  '@name': 'regex_syntax::hir::Repetition'
269
267
  '@variant': 'Range'
270
- value: RepetitionRange
268
+ '@values': [RepetitionRange]
271
269
  }
272
270
 
273
271
 
@@ -281,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
281
279
  '@type': 'struct'
282
280
  '@name': 'regex_syntax::hir::RepetitionRange'
283
281
  '@variant': 'Exactly'
284
- value: number
282
+ '@values': [number]
285
283
  }
286
284
 
287
285
  export type RepetitionRangeAtLeastVariant = {
288
286
  '@type': 'struct'
289
287
  '@name': 'regex_syntax::hir::RepetitionRange'
290
288
  '@variant': 'AtLeast'
291
- value: number
289
+ '@values': [number]
292
290
  }
293
291
 
294
292
  export type RepetitionRangeBoundedVariant = {
295
293
  '@type': 'struct'
296
294
  '@name': 'regex_syntax::hir::RepetitionRange'
297
295
  '@variant': 'Bounded'
298
- value: [number, number]
296
+ '@values': [number, number]
299
297
  }
300
298
 
301
299
 
@@ -509,6 +507,6 @@ export const metadata: {
509
507
  ],
510
508
  "homepage": "https://2fd.github.io/rregex",
511
509
  "repository": "https://github.com/2fd/rregex",
512
- "regex": "1.1.9",
510
+ "regex": "1.2.1",
513
511
  "regex-syntax": "0.6.25"
514
512
  }
package/lib/commonjs.js CHANGED
@@ -644,6 +644,6 @@ module.exports.metadata = {
644
644
  ],
645
645
  "homepage": "https://2fd.github.io/rregex",
646
646
  "repository": "https://github.com/2fd/rregex",
647
- "regex": "1.1.9",
647
+ "regex": "1.2.1",
648
648
  "regex-syntax": "0.6.25"
649
649
  }
package/lib/module.d.ts CHANGED
@@ -9,9 +9,7 @@ export function escape(text: string): string;
9
9
  export type Hir = {
10
10
  '@type': 'struct'
11
11
  '@name': 'regex_syntax::hir::Hir'
12
- bold: boolean;
13
- italic: boolean;
14
- size: number;
12
+ kind: HirKind
15
13
  }
16
14
 
17
15
 
@@ -37,56 +35,56 @@ export type HirKindLiteralVariant = {
37
35
  '@type': 'struct'
38
36
  '@name': 'regex_syntax::hir::HirKind'
39
37
  '@variant': 'Literal'
40
- 'value': Literal
38
+ '@values': [Literal]
41
39
  }
42
40
 
43
41
  export type HirKindClassVariant = {
44
42
  '@type': 'struct'
45
43
  '@name': 'regex_syntax::hir::HirKind'
46
44
  '@variant': 'Class'
47
- 'value': Class
45
+ '@values': [Class]
48
46
  }
49
47
 
50
48
  export type HirKindAnchorVariant = {
51
49
  '@type': 'struct'
52
50
  '@name': 'regex_syntax::hir::HirKind'
53
51
  '@variant': 'Anchor'
54
- 'value': Anchor
52
+ '@values': [Anchor]
55
53
  }
56
54
 
57
55
  export type HirKindWordBoundaryVariant = {
58
56
  '@type': 'struct'
59
57
  '@name': 'regex_syntax::hir::HirKind'
60
58
  '@variant': 'WordBoundary'
61
- 'value': WordBoundary
59
+ '@values': [WordBoundary]
62
60
  }
63
61
 
64
62
  export type HirKindRepetitionVariant = {
65
63
  '@type': 'struct'
66
64
  '@name': 'regex_syntax::hir::HirKind'
67
65
  '@variant': 'Repetition'
68
- 'value': Repetition
66
+ '@values': [Repetition]
69
67
  }
70
68
 
71
69
  export type HirKindGroupVariant = {
72
70
  '@type': 'struct'
73
71
  '@name': 'regex_syntax::hir::HirKind'
74
72
  '@variant': 'Group'
75
- 'value': Group
73
+ '@values': [Group]
76
74
  }
77
75
 
78
76
  export type HirKindConcatVariant = {
79
77
  '@type': 'struct'
80
78
  '@name': 'regex_syntax::hir::HirKind'
81
79
  '@variant': 'Concat'
82
- 'value': Hir[]
80
+ '@values': [Hir[]]
83
81
  }
84
82
 
85
83
  export type HirKindAlternationVariant = {
86
84
  '@type': 'struct'
87
85
  '@name': 'regex_syntax::hir::HirKind'
88
86
  '@variant': 'Alternation'
89
- 'value': Hir[]
87
+ '@values': [Hir[]]
90
88
  }
91
89
 
92
90
 
@@ -99,14 +97,14 @@ export type LiteralUnicodeVariant = {
99
97
  '@type': 'struct'
100
98
  '@name': 'regex_syntax::hir::Literal'
101
99
  '@variant': 'Unicode'
102
- 'value': string
100
+ '@values': [string]
103
101
  }
104
102
 
105
103
  export type LiteralByteVariant = {
106
104
  '@type': 'struct'
107
105
  '@name': 'regex_syntax::hir::Literal'
108
106
  '@variant': 'Byte'
109
- 'value': number
107
+ '@values': [number]
110
108
  }
111
109
 
112
110
 
@@ -119,14 +117,14 @@ export type ClassUnicodeVariant = {
119
117
  '@type': 'struct'
120
118
  '@name': 'regex_syntax::hir::Class'
121
119
  '@variant': 'Unicode'
122
- 'value': ClassUnicode
120
+ '@values': [ClassUnicode]
123
121
  }
124
122
 
125
123
  export type ClassByteVariant = {
126
124
  '@type': 'struct'
127
125
  '@name': 'regex_syntax::hir::Class'
128
126
  '@variant': 'Bytes'
129
- 'value': ClassBytes
127
+ '@values': [ClassBytes]
130
128
  }
131
129
 
132
130
 
@@ -267,7 +265,7 @@ export type RepetitionKindRangeVariant = {
267
265
  '@type': 'struct'
268
266
  '@name': 'regex_syntax::hir::Repetition'
269
267
  '@variant': 'Range'
270
- value: RepetitionRange
268
+ '@values': [RepetitionRange]
271
269
  }
272
270
 
273
271
 
@@ -281,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
281
279
  '@type': 'struct'
282
280
  '@name': 'regex_syntax::hir::RepetitionRange'
283
281
  '@variant': 'Exactly'
284
- value: number
282
+ '@values': [number]
285
283
  }
286
284
 
287
285
  export type RepetitionRangeAtLeastVariant = {
288
286
  '@type': 'struct'
289
287
  '@name': 'regex_syntax::hir::RepetitionRange'
290
288
  '@variant': 'AtLeast'
291
- value: number
289
+ '@values': [number]
292
290
  }
293
291
 
294
292
  export type RepetitionRangeBoundedVariant = {
295
293
  '@type': 'struct'
296
294
  '@name': 'regex_syntax::hir::RepetitionRange'
297
295
  '@variant': 'Bounded'
298
- value: [number, number]
296
+ '@values': [number, number]
299
297
  }
300
298
 
301
299
 
@@ -509,6 +507,6 @@ export const metadata: {
509
507
  ],
510
508
  "homepage": "https://2fd.github.io/rregex",
511
509
  "repository": "https://github.com/2fd/rregex",
512
- "regex": "1.1.9",
510
+ "regex": "1.2.1",
513
511
  "regex-syntax": "0.6.25"
514
512
  }
package/lib/rregex.wasm CHANGED
Binary file
package/lib/types.d.ts CHANGED
@@ -9,9 +9,7 @@ export function escape(text: string): string;
9
9
  export type Hir = {
10
10
  '@type': 'struct'
11
11
  '@name': 'regex_syntax::hir::Hir'
12
- bold: boolean;
13
- italic: boolean;
14
- size: number;
12
+ kind: HirKind
15
13
  }
16
14
 
17
15
 
@@ -37,56 +35,56 @@ export type HirKindLiteralVariant = {
37
35
  '@type': 'struct'
38
36
  '@name': 'regex_syntax::hir::HirKind'
39
37
  '@variant': 'Literal'
40
- 'value': Literal
38
+ '@values': [Literal]
41
39
  }
42
40
 
43
41
  export type HirKindClassVariant = {
44
42
  '@type': 'struct'
45
43
  '@name': 'regex_syntax::hir::HirKind'
46
44
  '@variant': 'Class'
47
- 'value': Class
45
+ '@values': [Class]
48
46
  }
49
47
 
50
48
  export type HirKindAnchorVariant = {
51
49
  '@type': 'struct'
52
50
  '@name': 'regex_syntax::hir::HirKind'
53
51
  '@variant': 'Anchor'
54
- 'value': Anchor
52
+ '@values': [Anchor]
55
53
  }
56
54
 
57
55
  export type HirKindWordBoundaryVariant = {
58
56
  '@type': 'struct'
59
57
  '@name': 'regex_syntax::hir::HirKind'
60
58
  '@variant': 'WordBoundary'
61
- 'value': WordBoundary
59
+ '@values': [WordBoundary]
62
60
  }
63
61
 
64
62
  export type HirKindRepetitionVariant = {
65
63
  '@type': 'struct'
66
64
  '@name': 'regex_syntax::hir::HirKind'
67
65
  '@variant': 'Repetition'
68
- 'value': Repetition
66
+ '@values': [Repetition]
69
67
  }
70
68
 
71
69
  export type HirKindGroupVariant = {
72
70
  '@type': 'struct'
73
71
  '@name': 'regex_syntax::hir::HirKind'
74
72
  '@variant': 'Group'
75
- 'value': Group
73
+ '@values': [Group]
76
74
  }
77
75
 
78
76
  export type HirKindConcatVariant = {
79
77
  '@type': 'struct'
80
78
  '@name': 'regex_syntax::hir::HirKind'
81
79
  '@variant': 'Concat'
82
- 'value': Hir[]
80
+ '@values': [Hir[]]
83
81
  }
84
82
 
85
83
  export type HirKindAlternationVariant = {
86
84
  '@type': 'struct'
87
85
  '@name': 'regex_syntax::hir::HirKind'
88
86
  '@variant': 'Alternation'
89
- 'value': Hir[]
87
+ '@values': [Hir[]]
90
88
  }
91
89
 
92
90
 
@@ -99,14 +97,14 @@ export type LiteralUnicodeVariant = {
99
97
  '@type': 'struct'
100
98
  '@name': 'regex_syntax::hir::Literal'
101
99
  '@variant': 'Unicode'
102
- 'value': string
100
+ '@values': [string]
103
101
  }
104
102
 
105
103
  export type LiteralByteVariant = {
106
104
  '@type': 'struct'
107
105
  '@name': 'regex_syntax::hir::Literal'
108
106
  '@variant': 'Byte'
109
- 'value': number
107
+ '@values': [number]
110
108
  }
111
109
 
112
110
 
@@ -119,14 +117,14 @@ export type ClassUnicodeVariant = {
119
117
  '@type': 'struct'
120
118
  '@name': 'regex_syntax::hir::Class'
121
119
  '@variant': 'Unicode'
122
- 'value': ClassUnicode
120
+ '@values': [ClassUnicode]
123
121
  }
124
122
 
125
123
  export type ClassByteVariant = {
126
124
  '@type': 'struct'
127
125
  '@name': 'regex_syntax::hir::Class'
128
126
  '@variant': 'Bytes'
129
- 'value': ClassBytes
127
+ '@values': [ClassBytes]
130
128
  }
131
129
 
132
130
 
@@ -267,7 +265,7 @@ export type RepetitionKindRangeVariant = {
267
265
  '@type': 'struct'
268
266
  '@name': 'regex_syntax::hir::Repetition'
269
267
  '@variant': 'Range'
270
- value: RepetitionRange
268
+ '@values': [RepetitionRange]
271
269
  }
272
270
 
273
271
 
@@ -281,21 +279,21 @@ export type RepetitionRangeExactlyVariant = {
281
279
  '@type': 'struct'
282
280
  '@name': 'regex_syntax::hir::RepetitionRange'
283
281
  '@variant': 'Exactly'
284
- value: number
282
+ '@values': [number]
285
283
  }
286
284
 
287
285
  export type RepetitionRangeAtLeastVariant = {
288
286
  '@type': 'struct'
289
287
  '@name': 'regex_syntax::hir::RepetitionRange'
290
288
  '@variant': 'AtLeast'
291
- value: number
289
+ '@values': [number]
292
290
  }
293
291
 
294
292
  export type RepetitionRangeBoundedVariant = {
295
293
  '@type': 'struct'
296
294
  '@name': 'regex_syntax::hir::RepetitionRange'
297
295
  '@variant': 'Bounded'
298
- value: [number, number]
296
+ '@values': [number, number]
299
297
  }
300
298
 
301
299
 
@@ -551,6 +549,6 @@ export const metadata: {
551
549
  ],
552
550
  "homepage": "https://2fd.github.io/rregex",
553
551
  "repository": "https://github.com/2fd/rregex",
554
- "regex": "1.1.9",
552
+ "regex": "1.2.1",
555
553
  "regex-syntax": "0.6.25"
556
554
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rregex",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Rust Regex binding for Javascript",
5
5
  "private": false,
6
6
  "main": "./lib/commonjs.js",
@@ -30,7 +30,19 @@
30
30
  "release": {
31
31
  "ci": false,
32
32
  "branches": [
33
- "master"
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
+ }
34
46
  ]
35
47
  },
36
48
  "repository": {
package/babel.config.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- ['@babel/preset-env', { targets: { esmodules: true } }],
4
- '@babel/preset-typescript',
5
- ],
6
- plugins: ['@babel/plugin-proposal-class-properties'],
7
- }
package/jest.transform.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = require('babel-jest').createTransformer(
2
- require('./babel.config.js')
3
- )
@@ -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
- })