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