rregex 1.7.1 → 1.7.2
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/README.md +79 -190
- package/jsr.json +17 -0
- package/lib/{browser.d.ts → cf.d.ts} +205 -245
- package/lib/cf.mjs +20 -0
- package/lib/commonjs.cjs +609 -0
- package/lib/{commonjs.d.ts → commonjs.d.cts} +177 -220
- package/lib/{module.d.ts → esm.d.ts} +175 -231
- package/lib/esm.mjs +611 -0
- package/lib/rregex.wasm +0 -0
- package/lib/rregex.wasm.d.ts +29 -26
- package/lib/standalone.d.ts +517 -0
- package/lib/standalone.js +697 -0
- package/lib/types.d.ts +205 -245
- package/lib/web.d.ts +525 -0
- package/lib/web.js +700 -0
- package/package.json +107 -18
- package/lib/browser.js +0 -737
- package/lib/commonjs.js +0 -675
- package/lib/module.js +0 -658
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
let wasm_bindgen;
|
|
2
|
+
(function() {
|
|
3
|
+
const __exports = {};
|
|
4
|
+
let script_src;
|
|
5
|
+
if (typeof document !== 'undefined' && document.currentScript !== null) {
|
|
6
|
+
script_src = new URL(document.currentScript.src, location.href).toString();
|
|
7
|
+
}
|
|
8
|
+
let wasm = undefined;
|
|
9
|
+
|
|
10
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
11
|
+
|
|
12
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
13
|
+
|
|
14
|
+
let cachedUint8ArrayMemory0 = null;
|
|
15
|
+
|
|
16
|
+
function getUint8ArrayMemory0() {
|
|
17
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
18
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
19
|
+
}
|
|
20
|
+
return cachedUint8ArrayMemory0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getStringFromWasm0(ptr, len) {
|
|
24
|
+
ptr = ptr >>> 0;
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function addToExternrefTable0(obj) {
|
|
29
|
+
const idx = wasm.__externref_table_alloc();
|
|
30
|
+
wasm.__wbindgen_export_2.set(idx, obj);
|
|
31
|
+
return idx;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleError(f, args) {
|
|
35
|
+
try {
|
|
36
|
+
return f.apply(this, args);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
const idx = addToExternrefTable0(e);
|
|
39
|
+
wasm.__wbindgen_exn_store(idx);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function debugString(val) {
|
|
44
|
+
// primitive types
|
|
45
|
+
const type = typeof val;
|
|
46
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
47
|
+
return `${val}`;
|
|
48
|
+
}
|
|
49
|
+
if (type == 'string') {
|
|
50
|
+
return `"${val}"`;
|
|
51
|
+
}
|
|
52
|
+
if (type == 'symbol') {
|
|
53
|
+
const description = val.description;
|
|
54
|
+
if (description == null) {
|
|
55
|
+
return 'Symbol';
|
|
56
|
+
} else {
|
|
57
|
+
return `Symbol(${description})`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (type == 'function') {
|
|
61
|
+
const name = val.name;
|
|
62
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
63
|
+
return `Function(${name})`;
|
|
64
|
+
} else {
|
|
65
|
+
return 'Function';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// objects
|
|
69
|
+
if (Array.isArray(val)) {
|
|
70
|
+
const length = val.length;
|
|
71
|
+
let debug = '[';
|
|
72
|
+
if (length > 0) {
|
|
73
|
+
debug += debugString(val[0]);
|
|
74
|
+
}
|
|
75
|
+
for(let i = 1; i < length; i++) {
|
|
76
|
+
debug += ', ' + debugString(val[i]);
|
|
77
|
+
}
|
|
78
|
+
debug += ']';
|
|
79
|
+
return debug;
|
|
80
|
+
}
|
|
81
|
+
// Test for built-in
|
|
82
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
83
|
+
let className;
|
|
84
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
85
|
+
className = builtInMatches[1];
|
|
86
|
+
} else {
|
|
87
|
+
// Failed to match the standard '[object ClassName]'
|
|
88
|
+
return toString.call(val);
|
|
89
|
+
}
|
|
90
|
+
if (className == 'Object') {
|
|
91
|
+
// we're a user defined class or Object
|
|
92
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
93
|
+
// easier than looping through ownProperties of `val`.
|
|
94
|
+
try {
|
|
95
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
96
|
+
} catch (_) {
|
|
97
|
+
return 'Object';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// errors
|
|
101
|
+
if (val instanceof Error) {
|
|
102
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
103
|
+
}
|
|
104
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
105
|
+
return className;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let WASM_VECTOR_LEN = 0;
|
|
109
|
+
|
|
110
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
111
|
+
|
|
112
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
113
|
+
? function (arg, view) {
|
|
114
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
115
|
+
}
|
|
116
|
+
: function (arg, view) {
|
|
117
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
118
|
+
view.set(buf);
|
|
119
|
+
return {
|
|
120
|
+
read: arg.length,
|
|
121
|
+
written: buf.length
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
126
|
+
|
|
127
|
+
if (realloc === undefined) {
|
|
128
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
129
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
130
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
131
|
+
WASM_VECTOR_LEN = buf.length;
|
|
132
|
+
return ptr;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let len = arg.length;
|
|
136
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
137
|
+
|
|
138
|
+
const mem = getUint8ArrayMemory0();
|
|
139
|
+
|
|
140
|
+
let offset = 0;
|
|
141
|
+
|
|
142
|
+
for (; offset < len; offset++) {
|
|
143
|
+
const code = arg.charCodeAt(offset);
|
|
144
|
+
if (code > 0x7F) break;
|
|
145
|
+
mem[ptr + offset] = code;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (offset !== len) {
|
|
149
|
+
if (offset !== 0) {
|
|
150
|
+
arg = arg.slice(offset);
|
|
151
|
+
}
|
|
152
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
153
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
154
|
+
const ret = encodeString(arg, view);
|
|
155
|
+
|
|
156
|
+
offset += ret.written;
|
|
157
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
WASM_VECTOR_LEN = offset;
|
|
161
|
+
return ptr;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
let cachedDataViewMemory0 = null;
|
|
165
|
+
|
|
166
|
+
function getDataViewMemory0() {
|
|
167
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
168
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
169
|
+
}
|
|
170
|
+
return cachedDataViewMemory0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function isLikeNone(x) {
|
|
174
|
+
return x === undefined || x === null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function takeFromExternrefTable0(idx) {
|
|
178
|
+
const value = wasm.__wbindgen_export_2.get(idx);
|
|
179
|
+
wasm.__externref_table_dealloc(idx);
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @param {string} text
|
|
184
|
+
* @returns {string}
|
|
185
|
+
*/
|
|
186
|
+
__exports.escape = function(text) {
|
|
187
|
+
let deferred2_0;
|
|
188
|
+
let deferred2_1;
|
|
189
|
+
try {
|
|
190
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
191
|
+
const len0 = WASM_VECTOR_LEN;
|
|
192
|
+
const ret = wasm.escape(ptr0, len0);
|
|
193
|
+
deferred2_0 = ret[0];
|
|
194
|
+
deferred2_1 = ret[1];
|
|
195
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
196
|
+
} finally {
|
|
197
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const RRegexFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
202
|
+
? { register: () => {}, unregister: () => {} }
|
|
203
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rregex_free(ptr >>> 0, 1));
|
|
204
|
+
/**
|
|
205
|
+
* A compiled regular expression for matching Unicode strings.
|
|
206
|
+
* @see https://docs.rs/regex/latest/regex/
|
|
207
|
+
*/
|
|
208
|
+
class RRegex {
|
|
209
|
+
|
|
210
|
+
__destroy_into_raw() {
|
|
211
|
+
const ptr = this.__wbg_ptr;
|
|
212
|
+
this.__wbg_ptr = 0;
|
|
213
|
+
RRegexFinalization.unregister(this);
|
|
214
|
+
return ptr;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
free() {
|
|
218
|
+
const ptr = this.__destroy_into_raw();
|
|
219
|
+
wasm.__wbg_rregex_free(ptr, 0);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Returns the same as is_match, but starts the search at the given offset.
|
|
223
|
+
* The significance of the starting point is that it takes the surrounding context into consideration. For example, the `\A` anchor can only match when `start == 0`.
|
|
224
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
|
|
225
|
+
* @param {string} text
|
|
226
|
+
* @param {number} start
|
|
227
|
+
* @returns {boolean}
|
|
228
|
+
*/
|
|
229
|
+
isMatchAt(text, start) {
|
|
230
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
231
|
+
const len0 = WASM_VECTOR_LEN;
|
|
232
|
+
const ret = wasm.rregex_isMatchAt(this.__wbg_ptr, ptr0, len0, start);
|
|
233
|
+
return ret !== 0;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Replaces all non-overlapping matches in `text` with the replacement provided. This is the same as calling `replacen` with `limit` set to `0`.
|
|
237
|
+
* See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
|
|
238
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
|
|
239
|
+
* @param {string} text
|
|
240
|
+
* @param {string} rep
|
|
241
|
+
* @returns {string}
|
|
242
|
+
*/
|
|
243
|
+
replaceAll(text, rep) {
|
|
244
|
+
let deferred3_0;
|
|
245
|
+
let deferred3_1;
|
|
246
|
+
try {
|
|
247
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
248
|
+
const len0 = WASM_VECTOR_LEN;
|
|
249
|
+
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
250
|
+
const len1 = WASM_VECTOR_LEN;
|
|
251
|
+
const ret = wasm.rregex_replaceAll(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
252
|
+
deferred3_0 = ret[0];
|
|
253
|
+
deferred3_1 = ret[1];
|
|
254
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
255
|
+
} finally {
|
|
256
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Returns the end location of a match in the text given.
|
|
261
|
+
* This method may have the same performance characteristics as `is_match`, except it provides an end location for a match. In particular, the location returned may be shorter than the proper end of the leftmost-first match.
|
|
262
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
|
|
263
|
+
* @param {string} text
|
|
264
|
+
* @returns {number | undefined}
|
|
265
|
+
*/
|
|
266
|
+
shortestMatch(text) {
|
|
267
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
268
|
+
const len0 = WASM_VECTOR_LEN;
|
|
269
|
+
const ret = wasm.rregex_shortestMatch(this.__wbg_ptr, ptr0, len0);
|
|
270
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Returns the same as shortest_match, but starts the search at the given offset.
|
|
274
|
+
* The significance of the starting point is that it takes the surrounding context into consideration. For example, the \A anchor can only match when `start == 0`.
|
|
275
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
|
|
276
|
+
* @param {string} text
|
|
277
|
+
* @param {number} limit
|
|
278
|
+
* @returns {number | undefined}
|
|
279
|
+
*/
|
|
280
|
+
shortestMatchAt(text, limit) {
|
|
281
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
283
|
+
const ret = wasm.rregex_shortestMatchAt(this.__wbg_ptr, ptr0, len0, limit);
|
|
284
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Compiles a regular expression. Once compiled, it can be used repeatedly to search, split or replace text in a string.
|
|
288
|
+
* If an invalid expression is given, then an error is returned.
|
|
289
|
+
* @param {string} re
|
|
290
|
+
*/
|
|
291
|
+
constructor(re) {
|
|
292
|
+
const ptr0 = passStringToWasm0(re, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
const ret = wasm.rregex_new(ptr0, len0);
|
|
295
|
+
if (ret[2]) {
|
|
296
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
297
|
+
}
|
|
298
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
299
|
+
RRegexFinalization.register(this, this.__wbg_ptr, this);
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Returns the start and end byte range of the leftmost-first match in `text`. If no match exists, then `undefined` is returned.
|
|
304
|
+
* Note that this should only be used if you want to discover the position of the match. Testing the existence of a match is faster if you use `is_match`.
|
|
305
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
|
|
306
|
+
* @param {string} text
|
|
307
|
+
* @returns {any}
|
|
308
|
+
*/
|
|
309
|
+
find(text) {
|
|
310
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
311
|
+
const len0 = WASM_VECTOR_LEN;
|
|
312
|
+
const ret = wasm.rregex_find(this.__wbg_ptr, ptr0, len0);
|
|
313
|
+
return ret;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Returns an iterator of substrings of `text` delimited by a match of the regular expression. Namely, each element of the iterator corresponds to text that isn’t matched by the regular expression.
|
|
317
|
+
* This method will not copy the text given.
|
|
318
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
|
|
319
|
+
* @param {string} text
|
|
320
|
+
* @returns {any}
|
|
321
|
+
*/
|
|
322
|
+
split(text) {
|
|
323
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
324
|
+
const len0 = WASM_VECTOR_LEN;
|
|
325
|
+
const ret = wasm.rregex_split(this.__wbg_ptr, ptr0, len0);
|
|
326
|
+
return ret;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Returns an iterator of at most `limit` substrings of `text` delimited by a match of the regular expression. (A limit of 0 will return no substrings.) Namely, each element of the iterator corresponds to text that isn’t matched by the regular expression. The remainder of the string that is not split will be the last element in the iterator.
|
|
330
|
+
* This method will not copy the text given.
|
|
331
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
|
|
332
|
+
* @param {string} text
|
|
333
|
+
* @param {number} limit
|
|
334
|
+
* @returns {any}
|
|
335
|
+
*/
|
|
336
|
+
splitn(text, limit) {
|
|
337
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
338
|
+
const len0 = WASM_VECTOR_LEN;
|
|
339
|
+
const ret = wasm.rregex_splitn(this.__wbg_ptr, ptr0, len0, limit);
|
|
340
|
+
return ret;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Return the Regex syntax object
|
|
344
|
+
* @returns {any}
|
|
345
|
+
*/
|
|
346
|
+
syntax() {
|
|
347
|
+
const ret = wasm.rregex_syntax(this.__wbg_ptr);
|
|
348
|
+
return ret;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Returns the same as find, but starts the search at the given offset.
|
|
352
|
+
* The significance of the starting point is that it takes the surrounding context into consideration. For example, the \A anchor can only match when `start == 0`.
|
|
353
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
|
|
354
|
+
* @param {string} text
|
|
355
|
+
* @param {number} start
|
|
356
|
+
* @returns {any}
|
|
357
|
+
*/
|
|
358
|
+
findAt(text, start) {
|
|
359
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
360
|
+
const len0 = WASM_VECTOR_LEN;
|
|
361
|
+
const ret = wasm.rregex_findAt(this.__wbg_ptr, ptr0, len0, start);
|
|
362
|
+
return ret;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Replaces the leftmost-first match with the replacement provided.
|
|
366
|
+
* The replacement can be a regular string (where `$N` and `$name` are expanded to match capture groups) or a function that takes the matches’ `Captures` and returns the replaced string.
|
|
367
|
+
* If no match is found, then a copy of the string is returned unchanged.
|
|
368
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
|
|
369
|
+
* @param {string} text
|
|
370
|
+
* @param {string} rep
|
|
371
|
+
* @returns {string}
|
|
372
|
+
*/
|
|
373
|
+
replace(text, rep) {
|
|
374
|
+
let deferred3_0;
|
|
375
|
+
let deferred3_1;
|
|
376
|
+
try {
|
|
377
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
380
|
+
const len1 = WASM_VECTOR_LEN;
|
|
381
|
+
const ret = wasm.rregex_replace(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
382
|
+
deferred3_0 = ret[0];
|
|
383
|
+
deferred3_1 = ret[1];
|
|
384
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
385
|
+
} finally {
|
|
386
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Returns an array for each successive non-overlapping match in text, returning the start and end byte indices with respect to text.
|
|
391
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
|
|
392
|
+
* @param {string} text
|
|
393
|
+
* @returns {any}
|
|
394
|
+
*/
|
|
395
|
+
findAll(text) {
|
|
396
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
397
|
+
const len0 = WASM_VECTOR_LEN;
|
|
398
|
+
const ret = wasm.rregex_findAll(this.__wbg_ptr, ptr0, len0);
|
|
399
|
+
return ret;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Returns true if and only if there is a match for the regex in the string given.
|
|
403
|
+
* It is recommended to use this method if all you need to do is test a match, since the underlying matching engine may be able to do less work.
|
|
404
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
|
|
405
|
+
* @param {string} text
|
|
406
|
+
* @returns {boolean}
|
|
407
|
+
*/
|
|
408
|
+
isMatch(text) {
|
|
409
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
410
|
+
const len0 = WASM_VECTOR_LEN;
|
|
411
|
+
const ret = wasm.rregex_isMatch(this.__wbg_ptr, ptr0, len0);
|
|
412
|
+
return ret !== 0;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Replaces at most `limit` non-overlapping matches in `text` with the replacement provided. If `limit` is 0, then all non-overlapping matches are replaced.
|
|
416
|
+
* See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
|
|
417
|
+
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
|
|
418
|
+
* @param {string} text
|
|
419
|
+
* @param {number} limit
|
|
420
|
+
* @param {string} rep
|
|
421
|
+
* @returns {string}
|
|
422
|
+
*/
|
|
423
|
+
replacen(text, limit, rep) {
|
|
424
|
+
let deferred3_0;
|
|
425
|
+
let deferred3_1;
|
|
426
|
+
try {
|
|
427
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
428
|
+
const len0 = WASM_VECTOR_LEN;
|
|
429
|
+
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
430
|
+
const len1 = WASM_VECTOR_LEN;
|
|
431
|
+
const ret = wasm.rregex_replacen(this.__wbg_ptr, ptr0, len0, limit, ptr1, len1);
|
|
432
|
+
deferred3_0 = ret[0];
|
|
433
|
+
deferred3_1 = ret[1];
|
|
434
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
435
|
+
} finally {
|
|
436
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Returns a string representing the regular expression
|
|
441
|
+
* @returns {string}
|
|
442
|
+
*/
|
|
443
|
+
toString() {
|
|
444
|
+
let deferred1_0;
|
|
445
|
+
let deferred1_1;
|
|
446
|
+
try {
|
|
447
|
+
const ret = wasm.rregex_toString(this.__wbg_ptr);
|
|
448
|
+
deferred1_0 = ret[0];
|
|
449
|
+
deferred1_1 = ret[1];
|
|
450
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
451
|
+
} finally {
|
|
452
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
__exports.RRegex = RRegex;
|
|
457
|
+
|
|
458
|
+
const RRegexSetFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
459
|
+
? { register: () => {}, unregister: () => {} }
|
|
460
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rregexset_free(ptr >>> 0, 1));
|
|
461
|
+
/**
|
|
462
|
+
* Match multiple (possibly overlapping) regular expressions in a single scan.
|
|
463
|
+
* A regex set corresponds to the union of two or more regular expressions. That is, a regex set will match text where at least one of its constituent regular expressions matches. A regex set as its formulated here provides a touch more power: it will also report which regular expressions in the set match. Indeed, this is the key difference between regex sets and a single `Regex` with many alternates, since only one alternate can match at a time.
|
|
464
|
+
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
|
|
465
|
+
*/
|
|
466
|
+
class RRegexSet {
|
|
467
|
+
|
|
468
|
+
__destroy_into_raw() {
|
|
469
|
+
const ptr = this.__wbg_ptr;
|
|
470
|
+
this.__wbg_ptr = 0;
|
|
471
|
+
RRegexSetFinalization.unregister(this);
|
|
472
|
+
return ptr;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
free() {
|
|
476
|
+
const ptr = this.__destroy_into_raw();
|
|
477
|
+
wasm.__wbg_rregexset_free(ptr, 0);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Create a new regex set with the given regular expressions.
|
|
481
|
+
* @param {Array<any>} list
|
|
482
|
+
*/
|
|
483
|
+
constructor(list) {
|
|
484
|
+
const ret = wasm.rregexset_new(list);
|
|
485
|
+
if (ret[2]) {
|
|
486
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
487
|
+
}
|
|
488
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
489
|
+
RRegexSetFinalization.register(this, this.__wbg_ptr, this);
|
|
490
|
+
return this;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Returns the set of regular expressions that match in the given text.
|
|
494
|
+
* The set returned contains the index of each regular expression that matches in the given text. The index is in correspondence with the order of regular expressions given to RegexSet’s constructor.
|
|
495
|
+
* the set can also be used to iterate over the matched indices.
|
|
496
|
+
* @param {string} text
|
|
497
|
+
* @returns {any}
|
|
498
|
+
*/
|
|
499
|
+
matches(text) {
|
|
500
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
501
|
+
const len0 = WASM_VECTOR_LEN;
|
|
502
|
+
const ret = wasm.rregexset_matches(this.__wbg_ptr, ptr0, len0);
|
|
503
|
+
return ret;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Returns true if and only if one of the regexes in this set matches the text given.
|
|
507
|
+
* This method should be preferred if you only need to test whether any of the regexes in the set should match, but don’t care about which regexes matched. This is because the underlying matching engine will quit immediately after seeing the first match instead of continuing to find all matches.
|
|
508
|
+
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
|
|
509
|
+
* @param {string} text
|
|
510
|
+
* @returns {boolean}
|
|
511
|
+
*/
|
|
512
|
+
isMatch(text) {
|
|
513
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
514
|
+
const len0 = WASM_VECTOR_LEN;
|
|
515
|
+
const ret = wasm.rregexset_isMatch(this.__wbg_ptr, ptr0, len0);
|
|
516
|
+
return ret !== 0;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
__exports.RRegexSet = RRegexSet;
|
|
520
|
+
|
|
521
|
+
async function __wbg_load(module, imports) {
|
|
522
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
523
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
524
|
+
try {
|
|
525
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
526
|
+
|
|
527
|
+
} catch (e) {
|
|
528
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
529
|
+
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);
|
|
530
|
+
|
|
531
|
+
} else {
|
|
532
|
+
throw e;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const bytes = await module.arrayBuffer();
|
|
538
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
539
|
+
|
|
540
|
+
} else {
|
|
541
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
542
|
+
|
|
543
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
544
|
+
return { instance, module };
|
|
545
|
+
|
|
546
|
+
} else {
|
|
547
|
+
return instance;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function __wbg_get_imports() {
|
|
553
|
+
const imports = {};
|
|
554
|
+
imports.wbg = {};
|
|
555
|
+
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
556
|
+
const ret = arg0[arg1 >>> 0];
|
|
557
|
+
return ret;
|
|
558
|
+
};
|
|
559
|
+
imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
560
|
+
const ret = arg0.length;
|
|
561
|
+
return ret;
|
|
562
|
+
};
|
|
563
|
+
imports.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
564
|
+
const ret = new Object();
|
|
565
|
+
return ret;
|
|
566
|
+
};
|
|
567
|
+
imports.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
568
|
+
const ret = new Array();
|
|
569
|
+
return ret;
|
|
570
|
+
};
|
|
571
|
+
imports.wbg.__wbg_new_c68d7209be747379 = function(arg0, arg1) {
|
|
572
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
573
|
+
return ret;
|
|
574
|
+
};
|
|
575
|
+
imports.wbg.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
|
|
576
|
+
const ret = arg0.push(arg1);
|
|
577
|
+
return ret;
|
|
578
|
+
};
|
|
579
|
+
imports.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
580
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
581
|
+
return ret;
|
|
582
|
+
}, arguments) };
|
|
583
|
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
584
|
+
const ret = debugString(arg1);
|
|
585
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
586
|
+
const len1 = WASM_VECTOR_LEN;
|
|
587
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
588
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
589
|
+
};
|
|
590
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
591
|
+
const table = wasm.__wbindgen_export_2;
|
|
592
|
+
const offset = table.grow(4);
|
|
593
|
+
table.set(0, undefined);
|
|
594
|
+
table.set(offset + 0, undefined);
|
|
595
|
+
table.set(offset + 1, null);
|
|
596
|
+
table.set(offset + 2, true);
|
|
597
|
+
table.set(offset + 3, false);
|
|
598
|
+
;
|
|
599
|
+
};
|
|
600
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
601
|
+
const ret = typeof(arg0) === 'string';
|
|
602
|
+
return ret;
|
|
603
|
+
};
|
|
604
|
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
605
|
+
const ret = arg0;
|
|
606
|
+
return ret;
|
|
607
|
+
};
|
|
608
|
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
609
|
+
const obj = arg1;
|
|
610
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
611
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
612
|
+
var len1 = WASM_VECTOR_LEN;
|
|
613
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
614
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
615
|
+
};
|
|
616
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
617
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
618
|
+
return ret;
|
|
619
|
+
};
|
|
620
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
621
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
return imports;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function __wbg_init_memory(imports, memory) {
|
|
628
|
+
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function __wbg_finalize_init(instance, module) {
|
|
632
|
+
wasm = instance.exports;
|
|
633
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
634
|
+
cachedDataViewMemory0 = null;
|
|
635
|
+
cachedUint8ArrayMemory0 = null;
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
wasm.__wbindgen_start();
|
|
639
|
+
return wasm;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function initSync(module) {
|
|
643
|
+
if (wasm !== undefined) return wasm;
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
if (typeof module !== 'undefined') {
|
|
647
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
648
|
+
({module} = module)
|
|
649
|
+
} else {
|
|
650
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const imports = __wbg_get_imports();
|
|
655
|
+
|
|
656
|
+
__wbg_init_memory(imports);
|
|
657
|
+
|
|
658
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
659
|
+
module = new WebAssembly.Module(module);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
663
|
+
|
|
664
|
+
return __wbg_finalize_init(instance, module);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
async function __wbg_init(module_or_path) {
|
|
668
|
+
if (wasm !== undefined) return wasm;
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
if (typeof module_or_path !== 'undefined') {
|
|
672
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
673
|
+
({module_or_path} = module_or_path)
|
|
674
|
+
} else {
|
|
675
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (typeof module_or_path === 'undefined' && typeof script_src !== 'undefined') {
|
|
680
|
+
module_or_path = script_src.replace(/standalone\.js$/, 'rregex.wasm');
|
|
681
|
+
}
|
|
682
|
+
const imports = __wbg_get_imports();
|
|
683
|
+
|
|
684
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
685
|
+
module_or_path = fetch(module_or_path);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
__wbg_init_memory(imports);
|
|
689
|
+
|
|
690
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
691
|
+
|
|
692
|
+
return __wbg_finalize_init(instance, module);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
wasm_bindgen = Object.assign(__wbg_init, { initSync }, __exports);
|
|
696
|
+
|
|
697
|
+
})();
|