rregex 1.10.3 → 1.10.5

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