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