rregex 1.7.0 → 1.8.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/README.md +154 -47
- package/lib/browser.d.ts +796 -282
- package/lib/browser.js +739 -252
- package/lib/commonjs.d.ts +779 -271
- package/lib/commonjs.js +720 -235
- package/lib/module.d.ts +779 -271
- package/lib/module.js +721 -232
- package/lib/rregex.wasm +0 -0
- package/lib/rregex.wasm.d.ts +15 -11
- package/lib/types.d.ts +796 -282
- package/package.json +18 -2
package/lib/browser.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
|
|
2
1
|
let wasm;
|
|
3
2
|
|
|
4
|
-
const heap = new Array(
|
|
3
|
+
const heap = new Array(128).fill(undefined);
|
|
5
4
|
|
|
6
5
|
heap.push(undefined, null, true, false);
|
|
7
6
|
|
|
8
|
-
function getObject(idx) { return heap[idx]; }
|
|
9
|
-
|
|
10
7
|
let heap_next = heap.length;
|
|
11
8
|
|
|
9
|
+
function addHeapObject(obj) {
|
|
10
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
11
|
+
const idx = heap_next;
|
|
12
|
+
heap_next = heap[idx];
|
|
13
|
+
|
|
14
|
+
heap[idx] = obj;
|
|
15
|
+
return idx;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getObject(idx) { return heap[idx]; }
|
|
19
|
+
|
|
12
20
|
function dropObject(idx) {
|
|
13
|
-
if (idx <
|
|
21
|
+
if (idx < 132) return;
|
|
14
22
|
heap[idx] = heap_next;
|
|
15
23
|
heap_next = idx;
|
|
16
24
|
}
|
|
@@ -21,34 +29,27 @@ function takeObject(idx) {
|
|
|
21
29
|
return ret;
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
32
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
25
33
|
|
|
26
|
-
cachedTextDecoder.decode();
|
|
34
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
35
|
+
|
|
36
|
+
let cachedUint8Memory0 = null;
|
|
27
37
|
|
|
28
|
-
let cachedUint8Memory0;
|
|
29
38
|
function getUint8Memory0() {
|
|
30
|
-
if (cachedUint8Memory0.byteLength === 0) {
|
|
39
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
31
40
|
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
32
41
|
}
|
|
33
42
|
return cachedUint8Memory0;
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
function getStringFromWasm0(ptr, len) {
|
|
46
|
+
ptr = ptr >>> 0;
|
|
37
47
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
function addHeapObject(obj) {
|
|
41
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
42
|
-
const idx = heap_next;
|
|
43
|
-
heap_next = heap[idx];
|
|
44
|
-
|
|
45
|
-
heap[idx] = obj;
|
|
46
|
-
return idx;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
50
|
let WASM_VECTOR_LEN = 0;
|
|
50
51
|
|
|
51
|
-
const cachedTextEncoder = new TextEncoder('utf-8');
|
|
52
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
52
53
|
|
|
53
54
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
54
55
|
? function (arg, view) {
|
|
@@ -67,14 +68,14 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
67
68
|
|
|
68
69
|
if (realloc === undefined) {
|
|
69
70
|
const buf = cachedTextEncoder.encode(arg);
|
|
70
|
-
const ptr = malloc(buf.length);
|
|
71
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
71
72
|
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
72
73
|
WASM_VECTOR_LEN = buf.length;
|
|
73
74
|
return ptr;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
let len = arg.length;
|
|
77
|
-
let ptr = malloc(len);
|
|
78
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
78
79
|
|
|
79
80
|
const mem = getUint8Memory0();
|
|
80
81
|
|
|
@@ -90,7 +91,7 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
90
91
|
if (offset !== 0) {
|
|
91
92
|
arg = arg.slice(offset);
|
|
92
93
|
}
|
|
93
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
94
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
94
95
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
95
96
|
const ret = encodeString(arg, view);
|
|
96
97
|
|
|
@@ -105,83 +106,45 @@ function isLikeNone(x) {
|
|
|
105
106
|
return x === undefined || x === null;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
|
-
let cachedInt32Memory0;
|
|
109
|
+
let cachedInt32Memory0 = null;
|
|
110
|
+
|
|
109
111
|
function getInt32Memory0() {
|
|
110
|
-
if (cachedInt32Memory0.byteLength === 0) {
|
|
112
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
111
113
|
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
112
114
|
}
|
|
113
115
|
return cachedInt32Memory0;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
if (type == 'string') {
|
|
123
|
-
return `"${val}"`;
|
|
124
|
-
}
|
|
125
|
-
if (type == 'symbol') {
|
|
126
|
-
const description = val.description;
|
|
127
|
-
if (description == null) {
|
|
128
|
-
return 'Symbol';
|
|
129
|
-
} else {
|
|
130
|
-
return `Symbol(${description})`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (type == 'function') {
|
|
134
|
-
const name = val.name;
|
|
135
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
136
|
-
return `Function(${name})`;
|
|
137
|
-
} else {
|
|
138
|
-
return 'Function';
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// objects
|
|
142
|
-
if (Array.isArray(val)) {
|
|
143
|
-
const length = val.length;
|
|
144
|
-
let debug = '[';
|
|
145
|
-
if (length > 0) {
|
|
146
|
-
debug += debugString(val[0]);
|
|
147
|
-
}
|
|
148
|
-
for(let i = 1; i < length; i++) {
|
|
149
|
-
debug += ', ' + debugString(val[i]);
|
|
150
|
-
}
|
|
151
|
-
debug += ']';
|
|
152
|
-
return debug;
|
|
153
|
-
}
|
|
154
|
-
// Test for built-in
|
|
155
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
156
|
-
let className;
|
|
157
|
-
if (builtInMatches.length > 1) {
|
|
158
|
-
className = builtInMatches[1];
|
|
159
|
-
} else {
|
|
160
|
-
// Failed to match the standard '[object ClassName]'
|
|
161
|
-
return toString.call(val);
|
|
162
|
-
}
|
|
163
|
-
if (className == 'Object') {
|
|
164
|
-
// we're a user defined class or Object
|
|
165
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
166
|
-
// easier than looping through ownProperties of `val`.
|
|
167
|
-
try {
|
|
168
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
169
|
-
} catch (_) {
|
|
170
|
-
return 'Object';
|
|
171
|
-
}
|
|
118
|
+
let cachedUint32Memory0 = null;
|
|
119
|
+
|
|
120
|
+
function getUint32Memory0() {
|
|
121
|
+
if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
|
|
122
|
+
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
|
172
123
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
124
|
+
return cachedUint32Memory0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
128
|
+
ptr = ptr >>> 0;
|
|
129
|
+
const mem = getUint32Memory0();
|
|
130
|
+
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
|
131
|
+
const result = [];
|
|
132
|
+
for (let i = 0; i < slice.length; i++) {
|
|
133
|
+
result.push(takeObject(slice[i]));
|
|
176
134
|
}
|
|
177
|
-
|
|
178
|
-
return className;
|
|
135
|
+
return result;
|
|
179
136
|
}
|
|
180
137
|
/**
|
|
138
|
+
* Escapes all regular expression meta characters in `text`.
|
|
139
|
+
*
|
|
140
|
+
* The string returned may be safely used as a literal in a regular
|
|
141
|
+
* expression.
|
|
181
142
|
* @param {string} text
|
|
182
143
|
* @returns {string}
|
|
183
144
|
*/
|
|
184
145
|
export function escape(text) {
|
|
146
|
+
let deferred2_0;
|
|
147
|
+
let deferred2_1;
|
|
185
148
|
try {
|
|
186
149
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
187
150
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -189,14 +152,16 @@ export function escape(text) {
|
|
|
189
152
|
wasm.escape(retptr, ptr0, len0);
|
|
190
153
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
191
154
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
155
|
+
deferred2_0 = r0;
|
|
156
|
+
deferred2_1 = r1;
|
|
192
157
|
return getStringFromWasm0(r0, r1);
|
|
193
158
|
} finally {
|
|
194
159
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
195
|
-
wasm.__wbindgen_free(
|
|
160
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
196
161
|
}
|
|
197
162
|
}
|
|
198
163
|
|
|
199
|
-
let stack_pointer =
|
|
164
|
+
let stack_pointer = 128;
|
|
200
165
|
|
|
201
166
|
function addBorrowedObject(obj) {
|
|
202
167
|
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
@@ -217,16 +182,9 @@ function handleError(f, args) {
|
|
|
217
182
|
*/
|
|
218
183
|
export class RRegex {
|
|
219
184
|
|
|
220
|
-
static __wrap(ptr) {
|
|
221
|
-
const obj = Object.create(RRegex.prototype);
|
|
222
|
-
obj.ptr = ptr;
|
|
223
|
-
|
|
224
|
-
return obj;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
185
|
__destroy_into_raw() {
|
|
228
|
-
const ptr = this.
|
|
229
|
-
this.
|
|
186
|
+
const ptr = this.__wbg_ptr;
|
|
187
|
+
this.__wbg_ptr = 0;
|
|
230
188
|
|
|
231
189
|
return ptr;
|
|
232
190
|
}
|
|
@@ -236,7 +194,9 @@ export class RRegex {
|
|
|
236
194
|
wasm.__wbg_rregex_free(ptr);
|
|
237
195
|
}
|
|
238
196
|
/**
|
|
239
|
-
* Compiles a regular expression. Once compiled, it can be used repeatedly
|
|
197
|
+
* Compiles a regular expression. Once compiled, it can be used repeatedly
|
|
198
|
+
* to search, split or replace text in a string.
|
|
199
|
+
*
|
|
240
200
|
* If an invalid expression is given, then an error is returned.
|
|
241
201
|
* @param {string} re
|
|
242
202
|
*/
|
|
@@ -252,191 +212,590 @@ export class RRegex {
|
|
|
252
212
|
if (r2) {
|
|
253
213
|
throw takeObject(r1);
|
|
254
214
|
}
|
|
255
|
-
|
|
215
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
216
|
+
return this;
|
|
256
217
|
} finally {
|
|
257
218
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
258
219
|
}
|
|
259
220
|
}
|
|
260
221
|
/**
|
|
261
|
-
* Returns true if and only if there is a match for the regex in the
|
|
262
|
-
*
|
|
222
|
+
* Returns true if and only if there is a match for the regex in the
|
|
223
|
+
* string given.
|
|
224
|
+
*
|
|
225
|
+
* It is recommended to use this method if all you need to do is test
|
|
226
|
+
* a match, since the underlying matching engine may be able to do less
|
|
227
|
+
* work.
|
|
228
|
+
*
|
|
229
|
+
* # Example
|
|
230
|
+
*
|
|
231
|
+
* Test if some text contains at least one word with exactly 13
|
|
232
|
+
* Unicode word characters:
|
|
233
|
+
*
|
|
234
|
+
* ```typescript
|
|
235
|
+
* const text = "I categorically deny having triskaidekaphobia."
|
|
236
|
+
* expect(new RRegex("\\b\\w{13}\\b").is_match(text)).toBe(true)
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
263
239
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
|
|
264
|
-
* @param {string} text
|
|
265
|
-
* @
|
|
240
|
+
* @param {string} text - The string against which to match the regular expression
|
|
241
|
+
* @return {boolean}
|
|
266
242
|
*/
|
|
267
243
|
isMatch(text) {
|
|
268
244
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
269
245
|
const len0 = WASM_VECTOR_LEN;
|
|
270
|
-
const ret = wasm.rregex_isMatch(this.
|
|
246
|
+
const ret = wasm.rregex_isMatch(this.__wbg_ptr, ptr0, len0);
|
|
271
247
|
return ret !== 0;
|
|
272
248
|
}
|
|
273
249
|
/**
|
|
274
250
|
* Returns the same as is_match, but starts the search at the given offset.
|
|
275
|
-
* The significance of the starting point is that it takes the surrounding
|
|
251
|
+
* The significance of the starting point is that it takes the surrounding
|
|
252
|
+
* context into consideration. For example, the `\A` anchor can only match
|
|
253
|
+
* when `start == 0`.
|
|
254
|
+
*
|
|
276
255
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
|
|
277
|
-
* @param {string} text
|
|
278
|
-
* @param {number} start
|
|
279
|
-
* @
|
|
256
|
+
* @param {string} text - The string against which to match the regular expression
|
|
257
|
+
* @param {number} start - Zero-based index at which to start matching
|
|
258
|
+
* @return {boolean}
|
|
280
259
|
*/
|
|
281
260
|
isMatchAt(text, start) {
|
|
282
261
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
283
262
|
const len0 = WASM_VECTOR_LEN;
|
|
284
|
-
const ret = wasm.rregex_isMatchAt(this.
|
|
263
|
+
const ret = wasm.rregex_isMatchAt(this.__wbg_ptr, ptr0, len0, start);
|
|
285
264
|
return ret !== 0;
|
|
286
265
|
}
|
|
287
266
|
/**
|
|
288
|
-
* Returns the start and end byte range of the leftmost-first match in
|
|
289
|
-
*
|
|
267
|
+
* Returns the start and end byte range of the leftmost-first match in
|
|
268
|
+
* `text`. If no match exists, then `undefined` is returned.
|
|
269
|
+
*
|
|
270
|
+
* Note that this should only be used if you want to discover the position
|
|
271
|
+
* of the match. Testing the existence of a match is faster if you use
|
|
272
|
+
* `isMatch`.
|
|
273
|
+
*
|
|
274
|
+
* # Example
|
|
275
|
+
*
|
|
276
|
+
* Find the start and end location of the first word with exactly 13
|
|
277
|
+
* Unicode word characters:
|
|
278
|
+
*
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const text = "I categorically deny having triskaidekaphobia."
|
|
281
|
+
* const m = new Regex("\\b\\w{13}\\b").find(text)
|
|
282
|
+
* expect(m.start).toBe(2)
|
|
283
|
+
* expect(m.end).toBe(15)
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
290
286
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
|
|
291
|
-
* @param {string} text
|
|
292
|
-
* @
|
|
287
|
+
* @param {string} text - The string against which to match the regular expression
|
|
288
|
+
* @return {Match}
|
|
293
289
|
*/
|
|
294
290
|
find(text) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
291
|
+
try {
|
|
292
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
293
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
294
|
+
const len0 = WASM_VECTOR_LEN;
|
|
295
|
+
wasm.rregex_find(retptr, this.__wbg_ptr, ptr0, len0);
|
|
296
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
297
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
298
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
299
|
+
if (r2) {
|
|
300
|
+
throw takeObject(r1);
|
|
301
|
+
}
|
|
302
|
+
return takeObject(r0);
|
|
303
|
+
} finally {
|
|
304
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
305
|
+
}
|
|
299
306
|
}
|
|
300
307
|
/**
|
|
301
|
-
* Returns the same as find, but starts the search at the given
|
|
302
|
-
*
|
|
308
|
+
* Returns the same as find, but starts the search at the given
|
|
309
|
+
* offset.
|
|
310
|
+
*
|
|
311
|
+
* The significance of the starting point is that it takes the surrounding
|
|
312
|
+
* context into consideration. For example, the `\A` anchor can only
|
|
313
|
+
* match when `start == 0`.
|
|
314
|
+
*
|
|
303
315
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
|
|
304
|
-
* @param {string} text
|
|
305
|
-
* @param {number} start
|
|
306
|
-
* @returns {
|
|
316
|
+
* @param {string} text - The string against which to match the regular expression
|
|
317
|
+
* @param {number} start - Zero-based index at which to start matching
|
|
318
|
+
* @returns {Match}
|
|
307
319
|
*/
|
|
308
320
|
findAt(text, start) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
321
|
+
try {
|
|
322
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
323
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
324
|
+
const len0 = WASM_VECTOR_LEN;
|
|
325
|
+
wasm.rregex_findAt(retptr, this.__wbg_ptr, ptr0, len0, start);
|
|
326
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
327
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
328
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
329
|
+
if (r2) {
|
|
330
|
+
throw takeObject(r1);
|
|
331
|
+
}
|
|
332
|
+
return takeObject(r0);
|
|
333
|
+
} finally {
|
|
334
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
335
|
+
}
|
|
313
336
|
}
|
|
314
337
|
/**
|
|
315
|
-
* Returns an array for each successive non-overlapping match in text
|
|
338
|
+
* Returns an array for each successive non-overlapping match in `text``,
|
|
339
|
+
* returning the start and end byte indices with respect to `text`.
|
|
340
|
+
*
|
|
341
|
+
* # Example
|
|
342
|
+
*
|
|
343
|
+
* Find the start and end location of every word with exactly 13 Unicode
|
|
344
|
+
* word characters:
|
|
345
|
+
*
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const text = "Retroactively relinquishing remunerations is reprehensible."
|
|
348
|
+
* const matches = new Regex("\\b\\w{13}\\b").findAll(text)
|
|
349
|
+
* ```
|
|
350
|
+
*
|
|
316
351
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
|
|
317
|
-
* @param {string} text
|
|
318
|
-
* @returns {
|
|
352
|
+
* @param {string} text - The string against which to match the regular expression
|
|
353
|
+
* @returns {Match}
|
|
319
354
|
*/
|
|
320
355
|
findAll(text) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
356
|
+
try {
|
|
357
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
358
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
wasm.rregex_findAll(retptr, this.__wbg_ptr, ptr0, len0);
|
|
361
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
362
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
363
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
364
|
+
if (r2) {
|
|
365
|
+
throw takeObject(r1);
|
|
366
|
+
}
|
|
367
|
+
return takeObject(r0);
|
|
368
|
+
} finally {
|
|
369
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Returns a list of the capture names in this regex.
|
|
374
|
+
*
|
|
375
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.capture_names
|
|
376
|
+
*/
|
|
377
|
+
captureNames() {
|
|
378
|
+
try {
|
|
379
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
380
|
+
wasm.rregex_captureNames(retptr, this.__wbg_ptr);
|
|
381
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
382
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
383
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
384
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
385
|
+
return v1;
|
|
386
|
+
} finally {
|
|
387
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Returns the capture groups corresponding to the leftmost-first
|
|
392
|
+
* match in `text`. Capture group `0` always corresponds to the entire
|
|
393
|
+
* match. If no match is found, then `undefined` is returned.
|
|
394
|
+
*
|
|
395
|
+
* You should only use `captures` if you need access to the location of
|
|
396
|
+
* capturing group matches. Otherwise, `find` is faster for discovering
|
|
397
|
+
* the location of the overall match.
|
|
398
|
+
*
|
|
399
|
+
* # Examples
|
|
400
|
+
*
|
|
401
|
+
* Say you have some text with movie names and their release years,
|
|
402
|
+
* like "'Citizen Kane' (1941)". It'd be nice if we could search for text
|
|
403
|
+
* looking like that, while also extracting the movie name and its release
|
|
404
|
+
* year separately.
|
|
405
|
+
*
|
|
406
|
+
* ```typescript
|
|
407
|
+
* const re = new Regex("'([^']+)'\\s+\\((\\d{4})\)")
|
|
408
|
+
* const text = "Not my favorite movie: 'Citizen Kane' (1941)."
|
|
409
|
+
* const caps = re.captures(text)
|
|
410
|
+
* expect(caps.get[1].value).toBe("Citizen Kane")
|
|
411
|
+
* expect(caps.get[2].value).toBe("1941")
|
|
412
|
+
* expect(caps.get[0].value).toBe("'Citizen Kane' (1941)")
|
|
413
|
+
* ```
|
|
414
|
+
*
|
|
415
|
+
* Note that the full match is at capture group `0`. Each subsequent
|
|
416
|
+
* capture group is indexed by the order of its opening `(`.
|
|
417
|
+
*
|
|
418
|
+
* We can make this example a bit clearer by using *named* capture groups:
|
|
419
|
+
*
|
|
420
|
+
* ```typescript
|
|
421
|
+
* const re = new Regex("'(?P<title>[^']+)'\\s+\\((?P<year>\\d{4})\)")
|
|
422
|
+
* const text = "Not my favorite movie: 'Citizen Kane' (1941)."
|
|
423
|
+
* const caps = re.captures(text)
|
|
424
|
+
* expect(caps.name["title"].value).toBe("Citizen Kane")
|
|
425
|
+
* expect(caps.name["year"].value).toBe("1941")
|
|
426
|
+
* expect(caps.get[0].value).toBe("'Citizen Kane' (1941)")
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures
|
|
430
|
+
* @param {string} text - The string against which to match the regular expression
|
|
431
|
+
* @returns {Captures|undefined}
|
|
432
|
+
*/
|
|
433
|
+
captures(text) {
|
|
434
|
+
try {
|
|
435
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
436
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
437
|
+
const len0 = WASM_VECTOR_LEN;
|
|
438
|
+
wasm.rregex_captures(retptr, this.__wbg_ptr, ptr0, len0);
|
|
439
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
440
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
441
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
442
|
+
if (r2) {
|
|
443
|
+
throw takeObject(r1);
|
|
444
|
+
}
|
|
445
|
+
return takeObject(r0);
|
|
446
|
+
} finally {
|
|
447
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Returns a list with all the non-overlapping capture groups matched
|
|
452
|
+
* in `text`. This is operationally the same as `findAll`, except it
|
|
453
|
+
* returns information about capturing group matches.
|
|
454
|
+
*
|
|
455
|
+
* # Example
|
|
456
|
+
*
|
|
457
|
+
* We can use this to find all movie titles and their release years in
|
|
458
|
+
* some text, where the movie is formatted like "'Title' (xxxx)":
|
|
459
|
+
*
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const re = new Regex("'(?P<title>[^']+)'\\s+\\((?P<year>\\d{4})\\)")
|
|
462
|
+
* const text = "'Citizen Kane' (1941), 'The Wizard of Oz' (1939), 'M' (1931)."
|
|
463
|
+
* for caps of re.captures_iter(text) {
|
|
464
|
+
* console.log(
|
|
465
|
+
* "Movie:", caps.name["title"].value, ","
|
|
466
|
+
* "Released:", caps.name["year"].value
|
|
467
|
+
* );
|
|
468
|
+
* }
|
|
469
|
+
* // Output:
|
|
470
|
+
* // Movie: Citizen Kane, Released: 1941
|
|
471
|
+
* // Movie: The Wizard of Oz, Released: 1939
|
|
472
|
+
* // Movie: M, Released: 1931
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures_iter
|
|
476
|
+
* @param {string} text - The string against which to match the regular expression
|
|
477
|
+
* @returns {Captures[]}
|
|
478
|
+
*/
|
|
479
|
+
capturesAll(text) {
|
|
480
|
+
try {
|
|
481
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
482
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
483
|
+
const len0 = WASM_VECTOR_LEN;
|
|
484
|
+
wasm.rregex_capturesAll(retptr, this.__wbg_ptr, ptr0, len0);
|
|
485
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
486
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
487
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
488
|
+
if (r2) {
|
|
489
|
+
throw takeObject(r1);
|
|
490
|
+
}
|
|
491
|
+
return takeObject(r0);
|
|
492
|
+
} finally {
|
|
493
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Returns the number of captures.
|
|
498
|
+
*
|
|
499
|
+
* This includes all named and unnamed groups, including the implicit
|
|
500
|
+
* unnamed group that is always present and corresponds to the entire match.
|
|
501
|
+
*
|
|
502
|
+
* Since the implicit unnamed group is always included in this length, the
|
|
503
|
+
* length returned is guaranteed to be greater than zero.
|
|
504
|
+
*
|
|
505
|
+
* ## Example
|
|
506
|
+
*
|
|
507
|
+
* ```typescript
|
|
508
|
+
* const re1 = new RRegex("(?P<y>\\d{4})-(?P<m>\\d{2})-(?P<d>\\d{2})")
|
|
509
|
+
* expect(re1.capturesLength()).toEqual(4)
|
|
510
|
+
*
|
|
511
|
+
* const re2 = new RRegex("foo")
|
|
512
|
+
* expect(re2.capturesLength()).toEqual(1)
|
|
513
|
+
*
|
|
514
|
+
* const re3 = new RRegex("(foo)")
|
|
515
|
+
* expect(re3.capturesLength()).toEqual(2)
|
|
516
|
+
*
|
|
517
|
+
* const re4 = new RRegex("(?<a>.(?<b>.))(.)(?:.)(?<c>.)")
|
|
518
|
+
* expect(re4.capturesLength()).toEqual(5)
|
|
519
|
+
*
|
|
520
|
+
* const re5 = new RRegex("[a&&b]")
|
|
521
|
+
* expect(re5.capturesLength()).toEqual(1)
|
|
522
|
+
* ```
|
|
523
|
+
*
|
|
524
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.captures_len
|
|
525
|
+
* @returns {number}
|
|
526
|
+
*/
|
|
527
|
+
capturesLength() {
|
|
528
|
+
const ret = wasm.rregex_capturesLength(this.__wbg_ptr);
|
|
529
|
+
return ret >>> 0;
|
|
325
530
|
}
|
|
326
531
|
/**
|
|
327
532
|
* Replaces the leftmost-first match with the replacement provided.
|
|
328
|
-
* The replacement can be a regular string (where `$N` and `$name` are
|
|
533
|
+
* The replacement can be a regular string (where `$N` and `$name` are
|
|
534
|
+
* expanded to match capture groups) or a function that takes the matches'
|
|
535
|
+
* `Captures` and returns the replaced string.
|
|
536
|
+
*
|
|
329
537
|
* If no match is found, then a copy of the string is returned unchanged.
|
|
538
|
+
*
|
|
539
|
+
* # Replacement string syntax
|
|
540
|
+
*
|
|
541
|
+
* All instances of `$name` in the replacement text is replaced with the
|
|
542
|
+
* corresponding capture group `name`.
|
|
543
|
+
*
|
|
544
|
+
* `name` may be an integer corresponding to the index of the
|
|
545
|
+
* capture group (counted by order of opening parenthesis where `0` is the
|
|
546
|
+
* entire match) or it can be a name (consisting of letters, digits or
|
|
547
|
+
* underscores) corresponding to a named capture group.
|
|
548
|
+
*
|
|
549
|
+
* If `name` isn't a valid capture group (whether the name doesn't exist
|
|
550
|
+
* or isn't a valid index), then it is replaced with the empty string.
|
|
551
|
+
*
|
|
552
|
+
* The longest possible name is used. e.g., `$1a` looks up the capture
|
|
553
|
+
* group named `1a` and not the capture group at index `1`. To exert more
|
|
554
|
+
* precise control over the name, use braces, e.g., `${1}a`.
|
|
555
|
+
*
|
|
556
|
+
* To write a literal `$` use `$$`.
|
|
557
|
+
*
|
|
558
|
+
* # Examples
|
|
559
|
+
*
|
|
560
|
+
* Note that this function is polymorphic with respect to the replacement.
|
|
561
|
+
* In typical usage, this can just be a normal string:
|
|
562
|
+
*
|
|
563
|
+
* ```typescript
|
|
564
|
+
* const re = new Regex("[^01]+")
|
|
565
|
+
* expect(re.replace("1078910", "").toBe("1010")
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* Here's the example using this expansion technique with named capture
|
|
569
|
+
* groups:
|
|
570
|
+
*
|
|
571
|
+
* ```typescript
|
|
572
|
+
* const re = new Regex("(?P<last>[^,\\s]+),\\s+(?P<first>\\S+)")
|
|
573
|
+
* const result = re.replace("Springsteen, Bruce", "$first $last")
|
|
574
|
+
* expect(result).toBe("Bruce Springsteen")
|
|
575
|
+
* ```
|
|
576
|
+
*
|
|
577
|
+
* Note that using `$2` instead of `$first` or `$1` instead of `$last`
|
|
578
|
+
* would produce the same result. To write a literal `$` use `$$`.
|
|
579
|
+
*
|
|
580
|
+
* Sometimes the replacement string requires use of curly braces to
|
|
581
|
+
* delineate a capture group replacement and surrounding literal text.
|
|
582
|
+
* For example, if we wanted to join two words together with an
|
|
583
|
+
* underscore:
|
|
584
|
+
*
|
|
585
|
+
* ```typescript
|
|
586
|
+
* const re = new Regex("(?P<first>\\w+)\\s+(?P<second>\\w+)")
|
|
587
|
+
* const result = re.replace("deep fried", "${first}_$second")
|
|
588
|
+
* expect(result).toBe("deep_fried")
|
|
589
|
+
* ```
|
|
590
|
+
*
|
|
591
|
+
* Without the curly braces, the capture group name `first_` would be
|
|
592
|
+
* used, and since it doesn't exist, it would be replaced with the empty
|
|
593
|
+
* string.
|
|
594
|
+
*
|
|
330
595
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
|
|
331
|
-
* @param {string} text
|
|
332
|
-
* @param {string} rep
|
|
596
|
+
* @param {string} text - The string against which to match the regular expression
|
|
597
|
+
* @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
|
|
333
598
|
* @returns {string}
|
|
334
599
|
*/
|
|
335
600
|
replace(text, rep) {
|
|
601
|
+
let deferred3_0;
|
|
602
|
+
let deferred3_1;
|
|
336
603
|
try {
|
|
337
604
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
338
605
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
339
606
|
const len0 = WASM_VECTOR_LEN;
|
|
340
607
|
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
341
608
|
const len1 = WASM_VECTOR_LEN;
|
|
342
|
-
wasm.rregex_replace(retptr, this.
|
|
609
|
+
wasm.rregex_replace(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
343
610
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
344
611
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
612
|
+
deferred3_0 = r0;
|
|
613
|
+
deferred3_1 = r1;
|
|
345
614
|
return getStringFromWasm0(r0, r1);
|
|
346
615
|
} finally {
|
|
347
616
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
348
|
-
wasm.__wbindgen_free(
|
|
617
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
349
618
|
}
|
|
350
619
|
}
|
|
351
620
|
/**
|
|
352
|
-
* Replaces at most `limit` non-overlapping matches in `text` with the
|
|
353
|
-
*
|
|
621
|
+
* Replaces at most `limit` non-overlapping matches in `text` with the
|
|
622
|
+
* replacement provided. If `limit` is 0, then all non-overlapping matches
|
|
623
|
+
* are replaced.
|
|
624
|
+
*
|
|
625
|
+
* See the documentation for `replace` for details on how to access
|
|
626
|
+
* capturing group matches in the replacement string.
|
|
627
|
+
*
|
|
354
628
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
|
|
355
|
-
* @param {string} text
|
|
356
|
-
* @param {number} limit
|
|
357
|
-
* @param {string} rep
|
|
629
|
+
* @param {string} text - The string against which to match the regular expression
|
|
630
|
+
* @param {number} limit - Max number of replacement
|
|
631
|
+
* @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
|
|
358
632
|
* @returns {string}
|
|
359
633
|
*/
|
|
360
634
|
replacen(text, limit, rep) {
|
|
635
|
+
let deferred3_0;
|
|
636
|
+
let deferred3_1;
|
|
361
637
|
try {
|
|
362
638
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
363
639
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
364
640
|
const len0 = WASM_VECTOR_LEN;
|
|
365
641
|
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
366
642
|
const len1 = WASM_VECTOR_LEN;
|
|
367
|
-
wasm.rregex_replacen(retptr, this.
|
|
643
|
+
wasm.rregex_replacen(retptr, this.__wbg_ptr, ptr0, len0, limit, ptr1, len1);
|
|
368
644
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
369
645
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
646
|
+
deferred3_0 = r0;
|
|
647
|
+
deferred3_1 = r1;
|
|
370
648
|
return getStringFromWasm0(r0, r1);
|
|
371
649
|
} finally {
|
|
372
650
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
373
|
-
wasm.__wbindgen_free(
|
|
651
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
374
652
|
}
|
|
375
653
|
}
|
|
376
654
|
/**
|
|
377
|
-
* Replaces all non-overlapping matches in `text` with the replacement
|
|
655
|
+
* Replaces all non-overlapping matches in `text` with the replacement
|
|
656
|
+
* provided. This is the same as calling `replacen` with `limit` set to
|
|
657
|
+
* `0`.
|
|
658
|
+
*
|
|
659
|
+
* See the documentation for `replace` for details on how to access
|
|
660
|
+
* capturing group matches in the replacement string.
|
|
661
|
+
*
|
|
378
662
|
* See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
|
|
379
663
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
|
|
380
|
-
* @param {string} text
|
|
381
|
-
* @param {string} rep
|
|
664
|
+
* @param {string} text - The string against which to match the regular expression
|
|
665
|
+
* @param {string} rep - It's a string, it will replace the substring matched by `pattern`.
|
|
382
666
|
* @returns {string}
|
|
383
667
|
*/
|
|
384
668
|
replaceAll(text, rep) {
|
|
669
|
+
let deferred3_0;
|
|
670
|
+
let deferred3_1;
|
|
385
671
|
try {
|
|
386
672
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
387
673
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
388
674
|
const len0 = WASM_VECTOR_LEN;
|
|
389
675
|
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
390
676
|
const len1 = WASM_VECTOR_LEN;
|
|
391
|
-
wasm.rregex_replaceAll(retptr, this.
|
|
677
|
+
wasm.rregex_replaceAll(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
392
678
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
393
679
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
680
|
+
deferred3_0 = r0;
|
|
681
|
+
deferred3_1 = r1;
|
|
394
682
|
return getStringFromWasm0(r0, r1);
|
|
395
683
|
} finally {
|
|
396
684
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
397
|
-
wasm.__wbindgen_free(
|
|
685
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
398
686
|
}
|
|
399
687
|
}
|
|
400
688
|
/**
|
|
401
|
-
* Returns an iterator of substrings of `text` delimited by a match of the
|
|
402
|
-
*
|
|
689
|
+
* Returns an iterator of substrings of `text` delimited by a match of the
|
|
690
|
+
* regular expression. Namely, each element of the iterator corresponds to
|
|
691
|
+
* text that *isn't* matched by the regular expression.
|
|
692
|
+
*
|
|
693
|
+
* This method will *not* copy the text given.
|
|
694
|
+
*
|
|
695
|
+
* # Example
|
|
696
|
+
*
|
|
697
|
+
* To split a string delimited by arbitrary amounts of spaces or tabs:
|
|
698
|
+
*
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const re = new Regex(r"[ \\t]+")
|
|
701
|
+
* const fields = re.split("a b \t c\td e")
|
|
702
|
+
* expect(fields).toEqual(["a", "b", "c", "d", "e"])
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
403
705
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
|
|
404
|
-
* @param {string} text
|
|
405
|
-
* @returns {
|
|
706
|
+
* @param {string} text - The string against which to match the regular expression
|
|
707
|
+
* @returns {string[]}
|
|
406
708
|
*/
|
|
407
709
|
split(text) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
710
|
+
try {
|
|
711
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
712
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
713
|
+
const len0 = WASM_VECTOR_LEN;
|
|
714
|
+
wasm.rregex_split(retptr, this.__wbg_ptr, ptr0, len0);
|
|
715
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
716
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
717
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
718
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
719
|
+
return v2;
|
|
720
|
+
} finally {
|
|
721
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
722
|
+
}
|
|
412
723
|
}
|
|
413
724
|
/**
|
|
414
|
-
* Returns an iterator of at most `limit` substrings of `text` delimited
|
|
415
|
-
*
|
|
725
|
+
* Returns an iterator of at most `limit` substrings of `text` delimited
|
|
726
|
+
* by a match of the regular expression. (A `limit` of `0` will return no
|
|
727
|
+
* substrings.) Namely, each element of the iterator corresponds to text
|
|
728
|
+
* that *isn't* matched by the regular expression. The remainder of the
|
|
729
|
+
* string that is not split will be the last element in the iterator.
|
|
730
|
+
*
|
|
731
|
+
* This method will *not* copy the text given.
|
|
732
|
+
*
|
|
733
|
+
* # Example
|
|
734
|
+
*
|
|
735
|
+
* Get the first two words in some text:
|
|
736
|
+
*
|
|
737
|
+
* ```typescript
|
|
738
|
+
* const re = new Regex(r"\\W+")
|
|
739
|
+
* const fields = re.splitn("Hey! How are you?", 3)
|
|
740
|
+
* expect(fields).toEqual(["Hey", "How", "are you?"])
|
|
741
|
+
* ```
|
|
416
742
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
|
|
417
|
-
* @param {string} text
|
|
418
|
-
* @param {number} limit
|
|
419
|
-
* @returns {
|
|
743
|
+
* @param {string} text - The string against which to match the regular expression
|
|
744
|
+
* @param {number} limit - Max number result elements
|
|
745
|
+
* @returns {string[]}
|
|
420
746
|
*/
|
|
421
747
|
splitn(text, limit) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
748
|
+
try {
|
|
749
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
750
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
751
|
+
const len0 = WASM_VECTOR_LEN;
|
|
752
|
+
wasm.rregex_splitn(retptr, this.__wbg_ptr, ptr0, len0, limit);
|
|
753
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
754
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
755
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
756
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
757
|
+
return v2;
|
|
758
|
+
} finally {
|
|
759
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
760
|
+
}
|
|
426
761
|
}
|
|
427
762
|
/**
|
|
428
763
|
* Returns the end location of a match in the text given.
|
|
429
|
-
*
|
|
764
|
+
*
|
|
765
|
+
* This method may have the same performance characteristics as
|
|
766
|
+
* `isMatch`, except it provides an end location for a match. In
|
|
767
|
+
* particular, the location returned *may be shorter* than the proper end
|
|
768
|
+
* of the leftmost-first match that you would find via `Regex.find`.
|
|
769
|
+
*
|
|
770
|
+
* Note that it is not guaranteed that this routine finds the shortest or
|
|
771
|
+
* "earliest" possible match. Instead, the main idea of this API is that
|
|
772
|
+
* it returns the offset at the point at which the internal regex engine
|
|
773
|
+
* has determined that a match has occurred. This may vary depending on
|
|
774
|
+
* which internal regex engine is used, and thus, the offset itself may
|
|
775
|
+
* change.
|
|
776
|
+
*
|
|
777
|
+
* # Example
|
|
778
|
+
*
|
|
779
|
+
* Typically, `a+` would match the entire first sequence of `a` in some
|
|
780
|
+
* text, but `shortest_match` can give up as soon as it sees the first
|
|
781
|
+
* `a`.
|
|
782
|
+
*
|
|
783
|
+
* ```typescript
|
|
784
|
+
* const text = "aaaaa"
|
|
785
|
+
* const = new Regex("a+").shortest_match(text)
|
|
786
|
+
* expect(pos).toBe(1)
|
|
787
|
+
* ```
|
|
788
|
+
*
|
|
430
789
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
|
|
431
|
-
* @param {string} text
|
|
432
|
-
* @returns {number
|
|
790
|
+
* @param {string} text - The string against which to match the regular expression
|
|
791
|
+
* @returns {number|undefined}
|
|
433
792
|
*/
|
|
434
793
|
shortestMatch(text) {
|
|
435
794
|
try {
|
|
436
795
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
437
796
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
438
797
|
const len0 = WASM_VECTOR_LEN;
|
|
439
|
-
wasm.rregex_shortestMatch(retptr, this.
|
|
798
|
+
wasm.rregex_shortestMatch(retptr, this.__wbg_ptr, ptr0, len0);
|
|
440
799
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
441
800
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
442
801
|
return r0 === 0 ? undefined : r1 >>> 0;
|
|
@@ -445,19 +804,23 @@ export class RRegex {
|
|
|
445
804
|
}
|
|
446
805
|
}
|
|
447
806
|
/**
|
|
448
|
-
* Returns the same as shortest_match
|
|
449
|
-
*
|
|
807
|
+
* Returns the same as `shortest_match`, but starts the search at the
|
|
808
|
+
* given offset.
|
|
809
|
+
*
|
|
810
|
+
* The significance of the starting point is that it takes the surrounding
|
|
811
|
+
* context into consideration. For example, the `\A` anchor can only match
|
|
812
|
+
* when `start == 0`.
|
|
450
813
|
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
|
|
451
|
-
* @param {string} text
|
|
452
|
-
* @param {number}
|
|
453
|
-
* @returns {number
|
|
814
|
+
* @param {string} text - The string against which to match the regular expression
|
|
815
|
+
* @param {number} start - Zero-based index at which to start matching
|
|
816
|
+
* @returns {number|undefined}
|
|
454
817
|
*/
|
|
455
|
-
shortestMatchAt(text,
|
|
818
|
+
shortestMatchAt(text, start) {
|
|
456
819
|
try {
|
|
457
820
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
458
821
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
459
822
|
const len0 = WASM_VECTOR_LEN;
|
|
460
|
-
wasm.rregex_shortestMatchAt(retptr, this.
|
|
823
|
+
wasm.rregex_shortestMatchAt(retptr, this.__wbg_ptr, ptr0, len0, start);
|
|
461
824
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
462
825
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
463
826
|
return r0 === 0 ? undefined : r1 >>> 0;
|
|
@@ -466,47 +829,63 @@ export class RRegex {
|
|
|
466
829
|
}
|
|
467
830
|
}
|
|
468
831
|
/**
|
|
469
|
-
*
|
|
832
|
+
* Returns the regular expression into a high level intermediate
|
|
833
|
+
* representation.
|
|
470
834
|
* @returns {any}
|
|
471
835
|
*/
|
|
472
836
|
syntax() {
|
|
473
|
-
|
|
474
|
-
|
|
837
|
+
try {
|
|
838
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
839
|
+
wasm.rregex_syntax(retptr, this.__wbg_ptr);
|
|
840
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
841
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
842
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
843
|
+
if (r2) {
|
|
844
|
+
throw takeObject(r1);
|
|
845
|
+
}
|
|
846
|
+
return takeObject(r0);
|
|
847
|
+
} finally {
|
|
848
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
849
|
+
}
|
|
475
850
|
}
|
|
476
851
|
/**
|
|
477
852
|
* Returns a string representing the regular expression
|
|
478
853
|
* @returns {string}
|
|
479
854
|
*/
|
|
480
855
|
toString() {
|
|
856
|
+
let deferred1_0;
|
|
857
|
+
let deferred1_1;
|
|
481
858
|
try {
|
|
482
859
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
483
|
-
wasm.rregex_toString(retptr, this.
|
|
860
|
+
wasm.rregex_toString(retptr, this.__wbg_ptr);
|
|
484
861
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
485
862
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
863
|
+
deferred1_0 = r0;
|
|
864
|
+
deferred1_1 = r1;
|
|
486
865
|
return getStringFromWasm0(r0, r1);
|
|
487
866
|
} finally {
|
|
488
867
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
489
|
-
wasm.__wbindgen_free(
|
|
868
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
490
869
|
}
|
|
491
870
|
}
|
|
492
871
|
}
|
|
493
872
|
/**
|
|
494
873
|
* Match multiple (possibly overlapping) regular expressions in a single scan.
|
|
495
|
-
* A regex set corresponds to the union of two or more regular expressions.
|
|
874
|
+
* A regex set corresponds to the union of two or more regular expressions.
|
|
875
|
+
*
|
|
876
|
+
* That is, a regex set will match text where at least one of its constituent
|
|
877
|
+
* regular expressions matches. A regex set as its formulated here provides a
|
|
878
|
+
* touch more power: it will also report which regular expressions in the set match.
|
|
879
|
+
* Indeed, this is the key difference between regex sets and a single `Regex`
|
|
880
|
+
* with many alternates, since only one alternate can match at a time.
|
|
881
|
+
*
|
|
496
882
|
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
|
|
497
883
|
*/
|
|
498
884
|
export class RRegexSet {
|
|
499
885
|
|
|
500
|
-
static __wrap(ptr) {
|
|
501
|
-
const obj = Object.create(RRegexSet.prototype);
|
|
502
|
-
obj.ptr = ptr;
|
|
503
|
-
|
|
504
|
-
return obj;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
886
|
__destroy_into_raw() {
|
|
508
|
-
const ptr = this.
|
|
509
|
-
this.
|
|
887
|
+
const ptr = this.__wbg_ptr;
|
|
888
|
+
this.__wbg_ptr = 0;
|
|
510
889
|
|
|
511
890
|
return ptr;
|
|
512
891
|
}
|
|
@@ -517,6 +896,18 @@ export class RRegexSet {
|
|
|
517
896
|
}
|
|
518
897
|
/**
|
|
519
898
|
* Create a new regex set with the given regular expressions.
|
|
899
|
+
*
|
|
900
|
+
* This takes an of strings, if any item in the list is not a valid regular
|
|
901
|
+
* expressions, then an error is returned.
|
|
902
|
+
*
|
|
903
|
+
* # Example
|
|
904
|
+
*
|
|
905
|
+
* Create a new regex set from an iterator of strings:
|
|
906
|
+
*
|
|
907
|
+
* ```typescript
|
|
908
|
+
* const set = new RegexSet(["\\w+", "\\d+"])
|
|
909
|
+
* expect(set.is_match("foo")).toBe(true)
|
|
910
|
+
* ```
|
|
520
911
|
* @param {Array<any>} list
|
|
521
912
|
*/
|
|
522
913
|
constructor(list) {
|
|
@@ -529,41 +920,102 @@ export class RRegexSet {
|
|
|
529
920
|
if (r2) {
|
|
530
921
|
throw takeObject(r1);
|
|
531
922
|
}
|
|
532
|
-
|
|
923
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
924
|
+
return this;
|
|
533
925
|
} finally {
|
|
534
926
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
535
927
|
heap[stack_pointer++] = undefined;
|
|
536
928
|
}
|
|
537
929
|
}
|
|
538
930
|
/**
|
|
539
|
-
* Returns true if and only if one of the regexes in this set matches
|
|
540
|
-
*
|
|
931
|
+
* Returns true if and only if one of the regexes in this set matches
|
|
932
|
+
* the text given.
|
|
933
|
+
*
|
|
934
|
+
* This method should be preferred if you only need to test whether any
|
|
935
|
+
* of the regexes in the set should match, but don't care about *which*
|
|
936
|
+
* regexes matched. This is because the underlying matching engine will
|
|
937
|
+
* quit immediately after seeing the first match instead of continuing to
|
|
938
|
+
* find all matches.
|
|
939
|
+
*
|
|
940
|
+
* Note that as with searches using `Regex`, the expression is unanchored
|
|
941
|
+
* by default. That is, if the regex does not start with `^` or `\A`, or
|
|
942
|
+
* end with `$` or `\z`, then it is permitted to match anywhere in the
|
|
943
|
+
* text.
|
|
944
|
+
*
|
|
945
|
+
* # Example
|
|
946
|
+
*
|
|
947
|
+
* Tests whether a set matches some text:
|
|
948
|
+
*
|
|
949
|
+
* ```typescript
|
|
950
|
+
* const set = new RegexSet(["\\w+", "\\d+"])
|
|
951
|
+
* expect(set.is_match("foo")).toBe(true)
|
|
952
|
+
* expect(!set.is_match("☃")).toBe(false)
|
|
953
|
+
* ```
|
|
954
|
+
*
|
|
541
955
|
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
|
|
542
|
-
* @param {string} text
|
|
543
|
-
* @
|
|
956
|
+
* @param {string} text - The string against which to match the regular expression
|
|
957
|
+
* @return {boolean}
|
|
544
958
|
*/
|
|
545
959
|
isMatch(text) {
|
|
546
960
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
547
961
|
const len0 = WASM_VECTOR_LEN;
|
|
548
|
-
const ret = wasm.rregexset_isMatch(this.
|
|
962
|
+
const ret = wasm.rregexset_isMatch(this.__wbg_ptr, ptr0, len0);
|
|
549
963
|
return ret !== 0;
|
|
550
964
|
}
|
|
551
965
|
/**
|
|
552
966
|
* Returns the set of regular expressions that match in the given text.
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
967
|
+
*
|
|
968
|
+
* The set returned contains the index of each regular expression that
|
|
969
|
+
* matches in the given text. The index is in correspondence with the
|
|
970
|
+
* order of regular expressions given to `RegexSet`'s constructor.
|
|
971
|
+
*
|
|
972
|
+
* The set can also be used to iterate over the matched indices.
|
|
973
|
+
*
|
|
974
|
+
* Note that as with searches using `Regex`, the expression is unanchored
|
|
975
|
+
* by default. That is, if the regex does not start with `^` or `\A`, or
|
|
976
|
+
* end with `$` or `\z`, then it is permitted to match anywhere in the
|
|
977
|
+
* text.
|
|
978
|
+
*
|
|
979
|
+
* # Example
|
|
980
|
+
*
|
|
981
|
+
* Tests which regular expressions match the given text:
|
|
982
|
+
*
|
|
983
|
+
* ```typescript
|
|
984
|
+
* const set = new RegexSet([
|
|
985
|
+
* "\\w+",
|
|
986
|
+
* "\\d+",
|
|
987
|
+
* "\\pL+",
|
|
988
|
+
* "foo",
|
|
989
|
+
* "bar",
|
|
990
|
+
* "barfoo",
|
|
991
|
+
* "foobar",
|
|
992
|
+
* ])
|
|
993
|
+
* const matches = set.matches("foobar")
|
|
994
|
+
* expect(matches).toBe([0, 2, 3, 4, 6])
|
|
995
|
+
* ```
|
|
996
|
+
*
|
|
997
|
+
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.matches
|
|
998
|
+
* @param {string} text - The string against which to match the regular expression
|
|
999
|
+
* @return {number[]}
|
|
557
1000
|
*/
|
|
558
1001
|
matches(text) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
1002
|
+
try {
|
|
1003
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1004
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1005
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1006
|
+
wasm.rregexset_matches(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1007
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
1008
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
1009
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
1010
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
1011
|
+
return v2;
|
|
1012
|
+
} finally {
|
|
1013
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1014
|
+
}
|
|
563
1015
|
}
|
|
564
1016
|
}
|
|
565
1017
|
|
|
566
|
-
async function
|
|
1018
|
+
async function __wbg_load(module, imports) {
|
|
567
1019
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
568
1020
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
569
1021
|
try {
|
|
@@ -594,9 +1046,13 @@ async function load(module, imports) {
|
|
|
594
1046
|
}
|
|
595
1047
|
}
|
|
596
1048
|
|
|
597
|
-
function
|
|
1049
|
+
function __wbg_get_imports() {
|
|
598
1050
|
const imports = {};
|
|
599
1051
|
imports.wbg = {};
|
|
1052
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
1053
|
+
const ret = arg0;
|
|
1054
|
+
return addHeapObject(ret);
|
|
1055
|
+
};
|
|
600
1056
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
601
1057
|
takeObject(arg0);
|
|
602
1058
|
};
|
|
@@ -604,108 +1060,139 @@ function getImports() {
|
|
|
604
1060
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
605
1061
|
return addHeapObject(ret);
|
|
606
1062
|
};
|
|
607
|
-
imports.wbg.
|
|
608
|
-
const ret = arg0;
|
|
1063
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
1064
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
609
1065
|
return addHeapObject(ret);
|
|
610
1066
|
};
|
|
611
|
-
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
612
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
613
|
-
return ret;
|
|
614
|
-
};
|
|
615
1067
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
616
1068
|
const obj = getObject(arg1);
|
|
617
1069
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
618
|
-
var
|
|
619
|
-
var
|
|
620
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
|
621
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
|
1070
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1071
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1072
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
1073
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
1074
|
+
};
|
|
1075
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
1076
|
+
const ret = getObject(arg0);
|
|
1077
|
+
return addHeapObject(ret);
|
|
1078
|
+
};
|
|
1079
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
1080
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1081
|
+
return addHeapObject(ret);
|
|
1082
|
+
};
|
|
1083
|
+
imports.wbg.__wbg_set_8761474ad72b9bf1 = function(arg0, arg1, arg2) {
|
|
1084
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
622
1085
|
};
|
|
623
|
-
imports.wbg.
|
|
1086
|
+
imports.wbg.__wbg_get_f01601b5a68d10e3 = function(arg0, arg1) {
|
|
624
1087
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
625
1088
|
return addHeapObject(ret);
|
|
626
1089
|
};
|
|
627
|
-
imports.wbg.
|
|
1090
|
+
imports.wbg.__wbg_length_1009b1af0c481d7b = function(arg0) {
|
|
628
1091
|
const ret = getObject(arg0).length;
|
|
629
1092
|
return ret;
|
|
630
1093
|
};
|
|
631
|
-
imports.wbg.
|
|
1094
|
+
imports.wbg.__wbg_new_ffc6d4d085022169 = function() {
|
|
632
1095
|
const ret = new Array();
|
|
633
1096
|
return addHeapObject(ret);
|
|
634
1097
|
};
|
|
635
|
-
imports.wbg.
|
|
1098
|
+
imports.wbg.__wbg_new_9fb8d994e1c0aaac = function() {
|
|
636
1099
|
const ret = new Object();
|
|
637
1100
|
return addHeapObject(ret);
|
|
638
1101
|
};
|
|
639
|
-
imports.wbg.
|
|
1102
|
+
imports.wbg.__wbg_set_f2740edb12e318cd = function(arg0, arg1, arg2) {
|
|
1103
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
1104
|
+
};
|
|
1105
|
+
imports.wbg.__wbg_from_71add2e723d1f1b2 = function(arg0) {
|
|
1106
|
+
const ret = Array.from(getObject(arg0));
|
|
1107
|
+
return addHeapObject(ret);
|
|
1108
|
+
};
|
|
1109
|
+
imports.wbg.__wbg_push_901f3914205d44de = function(arg0, arg1) {
|
|
640
1110
|
const ret = getObject(arg0).push(getObject(arg1));
|
|
641
1111
|
return ret;
|
|
642
1112
|
};
|
|
643
|
-
imports.wbg.
|
|
644
|
-
const ret =
|
|
1113
|
+
imports.wbg.__wbg_fromCodePoint_fd9383eff8873c75 = function() { return handleError(function (arg0) {
|
|
1114
|
+
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
1115
|
+
return addHeapObject(ret);
|
|
1116
|
+
}, arguments) };
|
|
1117
|
+
imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
|
|
1118
|
+
const ret = getObject(arg0).buffer;
|
|
1119
|
+
return addHeapObject(ret);
|
|
1120
|
+
};
|
|
1121
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d0482f893617af71 = function(arg0, arg1, arg2) {
|
|
1122
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
645
1123
|
return addHeapObject(ret);
|
|
646
1124
|
};
|
|
647
|
-
imports.wbg.
|
|
1125
|
+
imports.wbg.__wbg_new_8f67e318f15d7254 = function(arg0) {
|
|
1126
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
1127
|
+
return addHeapObject(ret);
|
|
1128
|
+
};
|
|
1129
|
+
imports.wbg.__wbg_set_759f75cd92b612d2 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
648
1130
|
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
649
1131
|
return ret;
|
|
650
1132
|
}, arguments) };
|
|
651
|
-
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
652
|
-
const ret = debugString(getObject(arg1));
|
|
653
|
-
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
654
|
-
const len0 = WASM_VECTOR_LEN;
|
|
655
|
-
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
656
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
657
|
-
};
|
|
658
1133
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
659
1134
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
660
1135
|
};
|
|
1136
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
1137
|
+
const ret = wasm.memory;
|
|
1138
|
+
return addHeapObject(ret);
|
|
1139
|
+
};
|
|
661
1140
|
|
|
662
1141
|
return imports;
|
|
663
1142
|
}
|
|
664
1143
|
|
|
665
|
-
function
|
|
1144
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
666
1145
|
|
|
667
1146
|
}
|
|
668
1147
|
|
|
669
|
-
function
|
|
1148
|
+
function __wbg_finalize_init(instance, module) {
|
|
670
1149
|
wasm = instance.exports;
|
|
671
|
-
|
|
672
|
-
cachedInt32Memory0 =
|
|
673
|
-
|
|
1150
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
1151
|
+
cachedInt32Memory0 = null;
|
|
1152
|
+
cachedUint32Memory0 = null;
|
|
1153
|
+
cachedUint8Memory0 = null;
|
|
674
1154
|
|
|
675
1155
|
|
|
676
1156
|
return wasm;
|
|
677
1157
|
}
|
|
678
1158
|
|
|
679
|
-
function initSync(
|
|
680
|
-
|
|
1159
|
+
function initSync(module) {
|
|
1160
|
+
if (wasm !== undefined) return wasm;
|
|
1161
|
+
|
|
1162
|
+
const imports = __wbg_get_imports();
|
|
681
1163
|
|
|
682
|
-
|
|
1164
|
+
__wbg_init_memory(imports);
|
|
1165
|
+
|
|
1166
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1167
|
+
module = new WebAssembly.Module(module);
|
|
1168
|
+
}
|
|
683
1169
|
|
|
684
|
-
const module = new WebAssembly.Module(bytes);
|
|
685
1170
|
const instance = new WebAssembly.Instance(module, imports);
|
|
686
1171
|
|
|
687
|
-
return
|
|
1172
|
+
return __wbg_finalize_init(instance, module);
|
|
688
1173
|
}
|
|
689
1174
|
|
|
690
|
-
async function
|
|
1175
|
+
async function __wbg_init(input) {
|
|
1176
|
+
if (wasm !== undefined) return wasm;
|
|
1177
|
+
|
|
691
1178
|
if (typeof input === 'undefined') {
|
|
692
1179
|
input = new URL('rregex.wasm', import.meta.url);
|
|
693
1180
|
}
|
|
694
|
-
const imports =
|
|
1181
|
+
const imports = __wbg_get_imports();
|
|
695
1182
|
|
|
696
1183
|
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
697
1184
|
input = fetch(input);
|
|
698
1185
|
}
|
|
699
1186
|
|
|
700
|
-
|
|
1187
|
+
__wbg_init_memory(imports);
|
|
701
1188
|
|
|
702
|
-
const { instance, module } = await
|
|
1189
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
703
1190
|
|
|
704
|
-
return
|
|
1191
|
+
return __wbg_finalize_init(instance, module);
|
|
705
1192
|
}
|
|
706
1193
|
|
|
707
1194
|
export { initSync }
|
|
708
|
-
export default
|
|
1195
|
+
export default __wbg_init;
|
|
709
1196
|
|
|
710
1197
|
export const metadata = {
|
|
711
1198
|
"name": "rregex",
|
|
@@ -713,8 +1200,8 @@ export const metadata = {
|
|
|
713
1200
|
"authors": [
|
|
714
1201
|
"Fede Ramirez <i@2fd.me>"
|
|
715
1202
|
],
|
|
716
|
-
"homepage": "
|
|
1203
|
+
"homepage": "http://rregex.dev",
|
|
717
1204
|
"repository": "https://github.com/2fd/rregex",
|
|
718
|
-
"regex": "1.
|
|
719
|
-
"regex-syntax": "0.
|
|
1205
|
+
"regex": "1.8.4",
|
|
1206
|
+
"regex-syntax": "0.7.5"
|
|
720
1207
|
}
|