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