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