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