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