rregex 1.0.2 → 1.1.2
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 +12 -5
- package/lib/browser.js +12 -8
- package/lib/commonjs.d.ts +12 -4
- package/lib/commonjs.js +12 -8
- package/lib/module.d.ts +12 -4
- 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 +12 -5
- 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,10 +5,6 @@
|
|
|
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'
|
|
@@ -526,7 +522,6 @@ export interface InitOutput {
|
|
|
526
522
|
readonly rregex_shortestMatchAt: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
527
523
|
readonly rregex_syntax: (a: number) => number;
|
|
528
524
|
readonly rregex_toString: (a: number, b: number) => void;
|
|
529
|
-
readonly get_metadata: () => number;
|
|
530
525
|
readonly __wbg_rregexset_free: (a: number) => void;
|
|
531
526
|
readonly rregexset_new: (a: number) => number;
|
|
532
527
|
readonly rregexset_isMatch: (a: number, b: number, c: number) => number;
|
|
@@ -547,3 +542,15 @@ export interface InitOutput {
|
|
|
547
542
|
* @returns {Promise<InitOutput>}
|
|
548
543
|
*/
|
|
549
544
|
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
545
|
+
|
|
546
|
+
export const metadata: {
|
|
547
|
+
"name": "rregex",
|
|
548
|
+
"description": "Rust Regex binding for Javascript",
|
|
549
|
+
"authors": [
|
|
550
|
+
"Fede Ramirez <i@2fd.me>"
|
|
551
|
+
],
|
|
552
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
553
|
+
"repository": "https://github.com/2fd/rregex",
|
|
554
|
+
"regex": "1.1.9",
|
|
555
|
+
"regex-syntax": "0.6.25"
|
|
556
|
+
}
|
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,10 +5,6 @@
|
|
|
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'
|
|
@@ -504,3 +500,15 @@ export class RRegexSet {
|
|
|
504
500
|
*/
|
|
505
501
|
matches(text: string): any;
|
|
506
502
|
}
|
|
503
|
+
|
|
504
|
+
export const metadata: {
|
|
505
|
+
"name": "rregex",
|
|
506
|
+
"description": "Rust Regex binding for Javascript",
|
|
507
|
+
"authors": [
|
|
508
|
+
"Fede Ramirez <i@2fd.me>"
|
|
509
|
+
],
|
|
510
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
511
|
+
"repository": "https://github.com/2fd/rregex",
|
|
512
|
+
"regex": "1.1.9",
|
|
513
|
+
"regex-syntax": "0.6.25"
|
|
514
|
+
}
|
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,10 +5,6 @@
|
|
|
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'
|
|
@@ -504,3 +500,15 @@ export class RRegexSet {
|
|
|
504
500
|
*/
|
|
505
501
|
matches(text: string): any;
|
|
506
502
|
}
|
|
503
|
+
|
|
504
|
+
export const metadata: {
|
|
505
|
+
"name": "rregex",
|
|
506
|
+
"description": "Rust Regex binding for Javascript",
|
|
507
|
+
"authors": [
|
|
508
|
+
"Fede Ramirez <i@2fd.me>"
|
|
509
|
+
],
|
|
510
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
511
|
+
"repository": "https://github.com/2fd/rregex",
|
|
512
|
+
"regex": "1.1.9",
|
|
513
|
+
"regex-syntax": "0.6.25"
|
|
514
|
+
}
|
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,10 +5,6 @@
|
|
|
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'
|
|
@@ -526,7 +522,6 @@ export interface InitOutput {
|
|
|
526
522
|
readonly rregex_shortestMatchAt: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
527
523
|
readonly rregex_syntax: (a: number) => number;
|
|
528
524
|
readonly rregex_toString: (a: number, b: number) => void;
|
|
529
|
-
readonly get_metadata: () => number;
|
|
530
525
|
readonly __wbg_rregexset_free: (a: number) => void;
|
|
531
526
|
readonly rregexset_new: (a: number) => number;
|
|
532
527
|
readonly rregexset_isMatch: (a: number, b: number, c: number) => number;
|
|
@@ -547,3 +542,15 @@ export interface InitOutput {
|
|
|
547
542
|
* @returns {Promise<InitOutput>}
|
|
548
543
|
*/
|
|
549
544
|
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
545
|
+
|
|
546
|
+
export const metadata: {
|
|
547
|
+
"name": "rregex",
|
|
548
|
+
"description": "Rust Regex binding for Javascript",
|
|
549
|
+
"authors": [
|
|
550
|
+
"Fede Ramirez <i@2fd.me>"
|
|
551
|
+
],
|
|
552
|
+
"homepage": "https://2fd.github.io/rregex",
|
|
553
|
+
"repository": "https://github.com/2fd/rregex",
|
|
554
|
+
"regex": "1.1.9",
|
|
555
|
+
"regex-syntax": "0.6.25"
|
|
556
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rregex",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
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
|
-
})
|