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
package/lib/module.js
DELETED
|
@@ -1,658 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const heap = new Array(128).fill(undefined);
|
|
8
|
-
|
|
9
|
-
heap.push(undefined, null, true, false);
|
|
10
|
-
|
|
11
|
-
function getObject(idx) { return heap[idx]; }
|
|
12
|
-
|
|
13
|
-
let heap_next = heap.length;
|
|
14
|
-
|
|
15
|
-
function dropObject(idx) {
|
|
16
|
-
if (idx < 132) return;
|
|
17
|
-
heap[idx] = heap_next;
|
|
18
|
-
heap_next = idx;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function takeObject(idx) {
|
|
22
|
-
const ret = getObject(idx);
|
|
23
|
-
dropObject(idx);
|
|
24
|
-
return ret;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
28
|
-
|
|
29
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
30
|
-
|
|
31
|
-
cachedTextDecoder.decode();
|
|
32
|
-
|
|
33
|
-
let cachedUint8Memory0 = null;
|
|
34
|
-
|
|
35
|
-
function getUint8Memory0() {
|
|
36
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
37
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
38
|
-
}
|
|
39
|
-
return cachedUint8Memory0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getStringFromWasm0(ptr, len) {
|
|
43
|
-
ptr = ptr >>> 0;
|
|
44
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function addHeapObject(obj) {
|
|
48
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
49
|
-
const idx = heap_next;
|
|
50
|
-
heap_next = heap[idx];
|
|
51
|
-
|
|
52
|
-
heap[idx] = obj;
|
|
53
|
-
return idx;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let WASM_VECTOR_LEN = 0;
|
|
57
|
-
|
|
58
|
-
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
59
|
-
|
|
60
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
61
|
-
|
|
62
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
63
|
-
? function (arg, view) {
|
|
64
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
65
|
-
}
|
|
66
|
-
: function (arg, view) {
|
|
67
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
68
|
-
view.set(buf);
|
|
69
|
-
return {
|
|
70
|
-
read: arg.length,
|
|
71
|
-
written: buf.length
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
76
|
-
|
|
77
|
-
if (realloc === undefined) {
|
|
78
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
79
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
80
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
81
|
-
WASM_VECTOR_LEN = buf.length;
|
|
82
|
-
return ptr;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
let len = arg.length;
|
|
86
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
87
|
-
|
|
88
|
-
const mem = getUint8Memory0();
|
|
89
|
-
|
|
90
|
-
let offset = 0;
|
|
91
|
-
|
|
92
|
-
for (; offset < len; offset++) {
|
|
93
|
-
const code = arg.charCodeAt(offset);
|
|
94
|
-
if (code > 0x7F) break;
|
|
95
|
-
mem[ptr + offset] = code;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (offset !== len) {
|
|
99
|
-
if (offset !== 0) {
|
|
100
|
-
arg = arg.slice(offset);
|
|
101
|
-
}
|
|
102
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
103
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
104
|
-
const ret = encodeString(arg, view);
|
|
105
|
-
|
|
106
|
-
offset += ret.written;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
WASM_VECTOR_LEN = offset;
|
|
110
|
-
return ptr;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function isLikeNone(x) {
|
|
114
|
-
return x === undefined || x === null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
let cachedInt32Memory0 = null;
|
|
118
|
-
|
|
119
|
-
function getInt32Memory0() {
|
|
120
|
-
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
121
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
122
|
-
}
|
|
123
|
-
return cachedInt32Memory0;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function debugString(val) {
|
|
127
|
-
// primitive types
|
|
128
|
-
const type = typeof val;
|
|
129
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
130
|
-
return `${val}`;
|
|
131
|
-
}
|
|
132
|
-
if (type == 'string') {
|
|
133
|
-
return `"${val}"`;
|
|
134
|
-
}
|
|
135
|
-
if (type == 'symbol') {
|
|
136
|
-
const description = val.description;
|
|
137
|
-
if (description == null) {
|
|
138
|
-
return 'Symbol';
|
|
139
|
-
} else {
|
|
140
|
-
return `Symbol(${description})`;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (type == 'function') {
|
|
144
|
-
const name = val.name;
|
|
145
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
146
|
-
return `Function(${name})`;
|
|
147
|
-
} else {
|
|
148
|
-
return 'Function';
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// objects
|
|
152
|
-
if (Array.isArray(val)) {
|
|
153
|
-
const length = val.length;
|
|
154
|
-
let debug = '[';
|
|
155
|
-
if (length > 0) {
|
|
156
|
-
debug += debugString(val[0]);
|
|
157
|
-
}
|
|
158
|
-
for(let i = 1; i < length; i++) {
|
|
159
|
-
debug += ', ' + debugString(val[i]);
|
|
160
|
-
}
|
|
161
|
-
debug += ']';
|
|
162
|
-
return debug;
|
|
163
|
-
}
|
|
164
|
-
// Test for built-in
|
|
165
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
166
|
-
let className;
|
|
167
|
-
if (builtInMatches.length > 1) {
|
|
168
|
-
className = builtInMatches[1];
|
|
169
|
-
} else {
|
|
170
|
-
// Failed to match the standard '[object ClassName]'
|
|
171
|
-
return toString.call(val);
|
|
172
|
-
}
|
|
173
|
-
if (className == 'Object') {
|
|
174
|
-
// we're a user defined class or Object
|
|
175
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
176
|
-
// easier than looping through ownProperties of `val`.
|
|
177
|
-
try {
|
|
178
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
179
|
-
} catch (_) {
|
|
180
|
-
return 'Object';
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// errors
|
|
184
|
-
if (val instanceof Error) {
|
|
185
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
186
|
-
}
|
|
187
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
188
|
-
return className;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
let stack_pointer = 128;
|
|
192
|
-
|
|
193
|
-
function addBorrowedObject(obj) {
|
|
194
|
-
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
195
|
-
heap[--stack_pointer] = obj;
|
|
196
|
-
return stack_pointer;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* @param {string} text
|
|
200
|
-
* @returns {string}
|
|
201
|
-
*/
|
|
202
|
-
export function escape(text) {
|
|
203
|
-
let deferred2_0;
|
|
204
|
-
let deferred2_1;
|
|
205
|
-
try {
|
|
206
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
207
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
208
|
-
const len0 = WASM_VECTOR_LEN;
|
|
209
|
-
wasm.escape(retptr, ptr0, len0);
|
|
210
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
211
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
212
|
-
deferred2_0 = r0;
|
|
213
|
-
deferred2_1 = r1;
|
|
214
|
-
return getStringFromWasm0(r0, r1);
|
|
215
|
-
} finally {
|
|
216
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
217
|
-
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function handleError(f, args) {
|
|
222
|
-
try {
|
|
223
|
-
return f.apply(this, args);
|
|
224
|
-
} catch (e) {
|
|
225
|
-
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* A compiled regular expression for matching Unicode strings.
|
|
230
|
-
* @see https://docs.rs/regex/latest/regex/
|
|
231
|
-
*/
|
|
232
|
-
export class RRegex {
|
|
233
|
-
|
|
234
|
-
__destroy_into_raw() {
|
|
235
|
-
const ptr = this.__wbg_ptr;
|
|
236
|
-
this.__wbg_ptr = 0;
|
|
237
|
-
|
|
238
|
-
return ptr;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
free() {
|
|
242
|
-
const ptr = this.__destroy_into_raw();
|
|
243
|
-
wasm.__wbg_rregex_free(ptr);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Compiles a regular expression. Once compiled, it can be used repeatedly to search, split or replace text in a string.
|
|
247
|
-
* If an invalid expression is given, then an error is returned.
|
|
248
|
-
* @param {string} re
|
|
249
|
-
*/
|
|
250
|
-
constructor(re) {
|
|
251
|
-
try {
|
|
252
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
253
|
-
const ptr0 = passStringToWasm0(re, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
254
|
-
const len0 = WASM_VECTOR_LEN;
|
|
255
|
-
wasm.rregex_new(retptr, ptr0, len0);
|
|
256
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
257
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
258
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
259
|
-
if (r2) {
|
|
260
|
-
throw takeObject(r1);
|
|
261
|
-
}
|
|
262
|
-
this.__wbg_ptr = r0 >>> 0;
|
|
263
|
-
return this;
|
|
264
|
-
} finally {
|
|
265
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Returns true if and only if there is a match for the regex in the string given.
|
|
270
|
-
* 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.
|
|
271
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match
|
|
272
|
-
* @param {string} text
|
|
273
|
-
* @returns {boolean}
|
|
274
|
-
*/
|
|
275
|
-
isMatch(text) {
|
|
276
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
277
|
-
const len0 = WASM_VECTOR_LEN;
|
|
278
|
-
const ret = wasm.rregex_isMatch(this.__wbg_ptr, ptr0, len0);
|
|
279
|
-
return ret !== 0;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Returns the same as is_match, but starts the search at the given offset.
|
|
283
|
-
* 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`.
|
|
284
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at
|
|
285
|
-
* @param {string} text
|
|
286
|
-
* @param {number} start
|
|
287
|
-
* @returns {boolean}
|
|
288
|
-
*/
|
|
289
|
-
isMatchAt(text, start) {
|
|
290
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
-
const len0 = WASM_VECTOR_LEN;
|
|
292
|
-
const ret = wasm.rregex_isMatchAt(this.__wbg_ptr, ptr0, len0, start);
|
|
293
|
-
return ret !== 0;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Returns the start and end byte range of the leftmost-first match in `text`. If no match exists, then `undefined` is returned.
|
|
297
|
-
* 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`.
|
|
298
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find
|
|
299
|
-
* @param {string} text
|
|
300
|
-
* @returns {any}
|
|
301
|
-
*/
|
|
302
|
-
find(text) {
|
|
303
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
304
|
-
const len0 = WASM_VECTOR_LEN;
|
|
305
|
-
const ret = wasm.rregex_find(this.__wbg_ptr, ptr0, len0);
|
|
306
|
-
return takeObject(ret);
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Returns the same as find, but starts the search at the given offset.
|
|
310
|
-
* The significance of the starting point is that it takes the surrounding context into consideration. For example, the \A anchor can only match when `start == 0`.
|
|
311
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at
|
|
312
|
-
* @param {string} text
|
|
313
|
-
* @param {number} start
|
|
314
|
-
* @returns {any}
|
|
315
|
-
*/
|
|
316
|
-
findAt(text, start) {
|
|
317
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
-
const len0 = WASM_VECTOR_LEN;
|
|
319
|
-
const ret = wasm.rregex_findAt(this.__wbg_ptr, ptr0, len0, start);
|
|
320
|
-
return takeObject(ret);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Returns an array for each successive non-overlapping match in text, returning the start and end byte indices with respect to text.
|
|
324
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter
|
|
325
|
-
* @param {string} text
|
|
326
|
-
* @returns {any}
|
|
327
|
-
*/
|
|
328
|
-
findAll(text) {
|
|
329
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
330
|
-
const len0 = WASM_VECTOR_LEN;
|
|
331
|
-
const ret = wasm.rregex_findAll(this.__wbg_ptr, ptr0, len0);
|
|
332
|
-
return takeObject(ret);
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Replaces the leftmost-first match with the replacement provided.
|
|
336
|
-
* 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.
|
|
337
|
-
* If no match is found, then a copy of the string is returned unchanged.
|
|
338
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace
|
|
339
|
-
* @param {string} text
|
|
340
|
-
* @param {string} rep
|
|
341
|
-
* @returns {string}
|
|
342
|
-
*/
|
|
343
|
-
replace(text, rep) {
|
|
344
|
-
let deferred3_0;
|
|
345
|
-
let deferred3_1;
|
|
346
|
-
try {
|
|
347
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
348
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
349
|
-
const len0 = WASM_VECTOR_LEN;
|
|
350
|
-
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
351
|
-
const len1 = WASM_VECTOR_LEN;
|
|
352
|
-
wasm.rregex_replace(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
353
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
354
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
355
|
-
deferred3_0 = r0;
|
|
356
|
-
deferred3_1 = r1;
|
|
357
|
-
return getStringFromWasm0(r0, r1);
|
|
358
|
-
} finally {
|
|
359
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
360
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Replaces at most `limit` non-overlapping matches in `text` with the replacement provided. If `limit` is 0, then all non-overlapping matches are replaced.
|
|
365
|
-
* See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
|
|
366
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen
|
|
367
|
-
* @param {string} text
|
|
368
|
-
* @param {number} limit
|
|
369
|
-
* @param {string} rep
|
|
370
|
-
* @returns {string}
|
|
371
|
-
*/
|
|
372
|
-
replacen(text, limit, rep) {
|
|
373
|
-
let deferred3_0;
|
|
374
|
-
let deferred3_1;
|
|
375
|
-
try {
|
|
376
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
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
|
-
wasm.rregex_replacen(retptr, this.__wbg_ptr, ptr0, len0, limit, ptr1, len1);
|
|
382
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
383
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
384
|
-
deferred3_0 = r0;
|
|
385
|
-
deferred3_1 = r1;
|
|
386
|
-
return getStringFromWasm0(r0, r1);
|
|
387
|
-
} finally {
|
|
388
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
389
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Replaces all non-overlapping matches in `text` with the replacement provided. This is the same as calling `replacen` with `limit` set to `0`.
|
|
394
|
-
* See the documentation for `replace` for details on how to access capturing group matches in the replacement string.
|
|
395
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all
|
|
396
|
-
* @param {string} text
|
|
397
|
-
* @param {string} rep
|
|
398
|
-
* @returns {string}
|
|
399
|
-
*/
|
|
400
|
-
replaceAll(text, rep) {
|
|
401
|
-
let deferred3_0;
|
|
402
|
-
let deferred3_1;
|
|
403
|
-
try {
|
|
404
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
405
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
406
|
-
const len0 = WASM_VECTOR_LEN;
|
|
407
|
-
const ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
|
-
const len1 = WASM_VECTOR_LEN;
|
|
409
|
-
wasm.rregex_replaceAll(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
410
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
411
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
412
|
-
deferred3_0 = r0;
|
|
413
|
-
deferred3_1 = r1;
|
|
414
|
-
return getStringFromWasm0(r0, r1);
|
|
415
|
-
} finally {
|
|
416
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
417
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* 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.
|
|
422
|
-
* This method will not copy the text given.
|
|
423
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.split
|
|
424
|
-
* @param {string} text
|
|
425
|
-
* @returns {any}
|
|
426
|
-
*/
|
|
427
|
-
split(text) {
|
|
428
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
429
|
-
const len0 = WASM_VECTOR_LEN;
|
|
430
|
-
const ret = wasm.rregex_split(this.__wbg_ptr, ptr0, len0);
|
|
431
|
-
return takeObject(ret);
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* 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.
|
|
435
|
-
* This method will not copy the text given.
|
|
436
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn
|
|
437
|
-
* @param {string} text
|
|
438
|
-
* @param {number} limit
|
|
439
|
-
* @returns {any}
|
|
440
|
-
*/
|
|
441
|
-
splitn(text, limit) {
|
|
442
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
443
|
-
const len0 = WASM_VECTOR_LEN;
|
|
444
|
-
const ret = wasm.rregex_splitn(this.__wbg_ptr, ptr0, len0, limit);
|
|
445
|
-
return takeObject(ret);
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Returns the end location of a match in the text given.
|
|
449
|
-
* 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.
|
|
450
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match
|
|
451
|
-
* @param {string} text
|
|
452
|
-
* @returns {number | undefined}
|
|
453
|
-
*/
|
|
454
|
-
shortestMatch(text) {
|
|
455
|
-
try {
|
|
456
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
457
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
458
|
-
const len0 = WASM_VECTOR_LEN;
|
|
459
|
-
wasm.rregex_shortestMatch(retptr, this.__wbg_ptr, ptr0, len0);
|
|
460
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
461
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
462
|
-
return r0 === 0 ? undefined : r1 >>> 0;
|
|
463
|
-
} finally {
|
|
464
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Returns the same as shortest_match, but starts the search at the given offset.
|
|
469
|
-
* 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`.
|
|
470
|
-
* @see https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at
|
|
471
|
-
* @param {string} text
|
|
472
|
-
* @param {number} limit
|
|
473
|
-
* @returns {number | undefined}
|
|
474
|
-
*/
|
|
475
|
-
shortestMatchAt(text, limit) {
|
|
476
|
-
try {
|
|
477
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
478
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
479
|
-
const len0 = WASM_VECTOR_LEN;
|
|
480
|
-
wasm.rregex_shortestMatchAt(retptr, this.__wbg_ptr, ptr0, len0, limit);
|
|
481
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
482
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
483
|
-
return r0 === 0 ? undefined : r1 >>> 0;
|
|
484
|
-
} finally {
|
|
485
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Return the Regex syntax object
|
|
490
|
-
* @returns {any}
|
|
491
|
-
*/
|
|
492
|
-
syntax() {
|
|
493
|
-
const ret = wasm.rregex_syntax(this.__wbg_ptr);
|
|
494
|
-
return takeObject(ret);
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Returns a string representing the regular expression
|
|
498
|
-
* @returns {string}
|
|
499
|
-
*/
|
|
500
|
-
toString() {
|
|
501
|
-
let deferred1_0;
|
|
502
|
-
let deferred1_1;
|
|
503
|
-
try {
|
|
504
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
505
|
-
wasm.rregex_toString(retptr, this.__wbg_ptr);
|
|
506
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
507
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
508
|
-
deferred1_0 = r0;
|
|
509
|
-
deferred1_1 = r1;
|
|
510
|
-
return getStringFromWasm0(r0, r1);
|
|
511
|
-
} finally {
|
|
512
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
513
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Match multiple (possibly overlapping) regular expressions in a single scan.
|
|
519
|
-
* 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.
|
|
520
|
-
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.empty
|
|
521
|
-
*/
|
|
522
|
-
export class RRegexSet {
|
|
523
|
-
|
|
524
|
-
__destroy_into_raw() {
|
|
525
|
-
const ptr = this.__wbg_ptr;
|
|
526
|
-
this.__wbg_ptr = 0;
|
|
527
|
-
|
|
528
|
-
return ptr;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
free() {
|
|
532
|
-
const ptr = this.__destroy_into_raw();
|
|
533
|
-
wasm.__wbg_rregexset_free(ptr);
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Create a new regex set with the given regular expressions.
|
|
537
|
-
* @param {Array<any>} list
|
|
538
|
-
*/
|
|
539
|
-
constructor(list) {
|
|
540
|
-
try {
|
|
541
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
542
|
-
wasm.rregexset_new(retptr, addBorrowedObject(list));
|
|
543
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
544
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
545
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
546
|
-
if (r2) {
|
|
547
|
-
throw takeObject(r1);
|
|
548
|
-
}
|
|
549
|
-
this.__wbg_ptr = r0 >>> 0;
|
|
550
|
-
return this;
|
|
551
|
-
} finally {
|
|
552
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
553
|
-
heap[stack_pointer++] = undefined;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Returns true if and only if one of the regexes in this set matches the text given.
|
|
558
|
-
* 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.
|
|
559
|
-
* @see https://docs.rs/regex/latest/regex/struct.RegexSet.html#method.is_match
|
|
560
|
-
* @param {string} text
|
|
561
|
-
* @returns {boolean}
|
|
562
|
-
*/
|
|
563
|
-
isMatch(text) {
|
|
564
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
565
|
-
const len0 = WASM_VECTOR_LEN;
|
|
566
|
-
const ret = wasm.rregexset_isMatch(this.__wbg_ptr, ptr0, len0);
|
|
567
|
-
return ret !== 0;
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Returns the set of regular expressions that match in the given text.
|
|
571
|
-
* 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.
|
|
572
|
-
* the set can also be used to iterate over the matched indices.
|
|
573
|
-
* @param {string} text
|
|
574
|
-
* @returns {any}
|
|
575
|
-
*/
|
|
576
|
-
matches(text) {
|
|
577
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
578
|
-
const len0 = WASM_VECTOR_LEN;
|
|
579
|
-
const ret = wasm.rregexset_matches(this.__wbg_ptr, ptr0, len0);
|
|
580
|
-
return takeObject(ret);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
export function __wbindgen_object_drop_ref(arg0) {
|
|
585
|
-
takeObject(arg0);
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
export function __wbindgen_string_new(arg0, arg1) {
|
|
589
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
590
|
-
return addHeapObject(ret);
|
|
591
|
-
};
|
|
592
|
-
|
|
593
|
-
export function __wbindgen_number_new(arg0) {
|
|
594
|
-
const ret = arg0;
|
|
595
|
-
return addHeapObject(ret);
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
export function __wbindgen_is_string(arg0) {
|
|
599
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
600
|
-
return ret;
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
export function __wbindgen_string_get(arg0, arg1) {
|
|
604
|
-
const obj = getObject(arg1);
|
|
605
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
606
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
607
|
-
var len1 = WASM_VECTOR_LEN;
|
|
608
|
-
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
609
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
export function __wbg_get_f01601b5a68d10e3(arg0, arg1) {
|
|
613
|
-
const ret = getObject(arg0)[arg1 >>> 0];
|
|
614
|
-
return addHeapObject(ret);
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
export function __wbg_length_1009b1af0c481d7b(arg0) {
|
|
618
|
-
const ret = getObject(arg0).length;
|
|
619
|
-
return ret;
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
export function __wbg_new_ffc6d4d085022169() {
|
|
623
|
-
const ret = new Array();
|
|
624
|
-
return addHeapObject(ret);
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
export function __wbg_new_9fb8d994e1c0aaac() {
|
|
628
|
-
const ret = new Object();
|
|
629
|
-
return addHeapObject(ret);
|
|
630
|
-
};
|
|
631
|
-
|
|
632
|
-
export function __wbg_push_901f3914205d44de(arg0, arg1) {
|
|
633
|
-
const ret = getObject(arg0).push(getObject(arg1));
|
|
634
|
-
return ret;
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
export function __wbg_new_a64e3f2afc2cf2f8(arg0, arg1) {
|
|
638
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
639
|
-
return addHeapObject(ret);
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
export function __wbg_set_759f75cd92b612d2() { return handleError(function (arg0, arg1, arg2) {
|
|
643
|
-
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
644
|
-
return ret;
|
|
645
|
-
}, arguments) };
|
|
646
|
-
|
|
647
|
-
export function __wbindgen_debug_string(arg0, arg1) {
|
|
648
|
-
const ret = debugString(getObject(arg1));
|
|
649
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
650
|
-
const len1 = WASM_VECTOR_LEN;
|
|
651
|
-
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
652
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
export function __wbindgen_throw(arg0, arg1) {
|
|
656
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
657
|
-
};
|
|
658
|
-
|