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