rregex 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +2 -0
- package/lib/browser.d.ts +111 -0
- package/lib/browser.js +465 -0
- package/lib/commonjs.d.ts +76 -0
- package/lib/commonjs.js +433 -0
- package/lib/module.d.ts +76 -0
- package/lib/module.js +425 -0
- package/lib/rregex.wasm +0 -0
- package/lib/rregex.wasm.d.ts +22 -0
- package/lib/types.d.ts +111 -0
- package/package.json +35 -0
package/lib/module.js
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import * as wasm from './module_bg.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
|
+
function debugString(val) {
|
|
51
|
+
// primitive types
|
|
52
|
+
const type = typeof val;
|
|
53
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
54
|
+
return `${val}`;
|
|
55
|
+
}
|
|
56
|
+
if (type == 'string') {
|
|
57
|
+
return `"${val}"`;
|
|
58
|
+
}
|
|
59
|
+
if (type == 'symbol') {
|
|
60
|
+
const description = val.description;
|
|
61
|
+
if (description == null) {
|
|
62
|
+
return 'Symbol';
|
|
63
|
+
} else {
|
|
64
|
+
return `Symbol(${description})`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (type == 'function') {
|
|
68
|
+
const name = val.name;
|
|
69
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
70
|
+
return `Function(${name})`;
|
|
71
|
+
} else {
|
|
72
|
+
return 'Function';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// objects
|
|
76
|
+
if (Array.isArray(val)) {
|
|
77
|
+
const length = val.length;
|
|
78
|
+
let debug = '[';
|
|
79
|
+
if (length > 0) {
|
|
80
|
+
debug += debugString(val[0]);
|
|
81
|
+
}
|
|
82
|
+
for(let i = 1; i < length; i++) {
|
|
83
|
+
debug += ', ' + debugString(val[i]);
|
|
84
|
+
}
|
|
85
|
+
debug += ']';
|
|
86
|
+
return debug;
|
|
87
|
+
}
|
|
88
|
+
// Test for built-in
|
|
89
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
90
|
+
let className;
|
|
91
|
+
if (builtInMatches.length > 1) {
|
|
92
|
+
className = builtInMatches[1];
|
|
93
|
+
} else {
|
|
94
|
+
// Failed to match the standard '[object ClassName]'
|
|
95
|
+
return toString.call(val);
|
|
96
|
+
}
|
|
97
|
+
if (className == 'Object') {
|
|
98
|
+
// we're a user defined class or Object
|
|
99
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
100
|
+
// easier than looping through ownProperties of `val`.
|
|
101
|
+
try {
|
|
102
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
103
|
+
} catch (_) {
|
|
104
|
+
return 'Object';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// errors
|
|
108
|
+
if (val instanceof Error) {
|
|
109
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
110
|
+
}
|
|
111
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
112
|
+
return className;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let WASM_VECTOR_LEN = 0;
|
|
116
|
+
|
|
117
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
118
|
+
|
|
119
|
+
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
120
|
+
|
|
121
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
122
|
+
? function (arg, view) {
|
|
123
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
124
|
+
}
|
|
125
|
+
: function (arg, view) {
|
|
126
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
127
|
+
view.set(buf);
|
|
128
|
+
return {
|
|
129
|
+
read: arg.length,
|
|
130
|
+
written: buf.length
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
135
|
+
|
|
136
|
+
if (realloc === undefined) {
|
|
137
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
138
|
+
const ptr = malloc(buf.length);
|
|
139
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
140
|
+
WASM_VECTOR_LEN = buf.length;
|
|
141
|
+
return ptr;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let len = arg.length;
|
|
145
|
+
let ptr = malloc(len);
|
|
146
|
+
|
|
147
|
+
const mem = getUint8Memory0();
|
|
148
|
+
|
|
149
|
+
let offset = 0;
|
|
150
|
+
|
|
151
|
+
for (; offset < len; offset++) {
|
|
152
|
+
const code = arg.charCodeAt(offset);
|
|
153
|
+
if (code > 0x7F) break;
|
|
154
|
+
mem[ptr + offset] = code;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (offset !== len) {
|
|
158
|
+
if (offset !== 0) {
|
|
159
|
+
arg = arg.slice(offset);
|
|
160
|
+
}
|
|
161
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
162
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
163
|
+
const ret = encodeString(arg, view);
|
|
164
|
+
|
|
165
|
+
offset += ret.written;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
WASM_VECTOR_LEN = offset;
|
|
169
|
+
return ptr;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
let cachegetInt32Memory0 = null;
|
|
173
|
+
function getInt32Memory0() {
|
|
174
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
175
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
176
|
+
}
|
|
177
|
+
return cachegetInt32Memory0;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* @returns {any}
|
|
181
|
+
*/
|
|
182
|
+
export function get_metadata() {
|
|
183
|
+
var ret = wasm.get_metadata();
|
|
184
|
+
return takeObject(ret);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function handleError(f, args) {
|
|
188
|
+
try {
|
|
189
|
+
return f.apply(this, args);
|
|
190
|
+
} catch (e) {
|
|
191
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
*/
|
|
196
|
+
export class RRegExp {
|
|
197
|
+
|
|
198
|
+
static __wrap(ptr) {
|
|
199
|
+
const obj = Object.create(RRegExp.prototype);
|
|
200
|
+
obj.ptr = ptr;
|
|
201
|
+
|
|
202
|
+
return obj;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
__destroy_into_raw() {
|
|
206
|
+
const ptr = this.ptr;
|
|
207
|
+
this.ptr = 0;
|
|
208
|
+
|
|
209
|
+
return ptr;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
free() {
|
|
213
|
+
const ptr = this.__destroy_into_raw();
|
|
214
|
+
wasm.__wbg_rregexp_free(ptr);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* @param {string} re
|
|
218
|
+
*/
|
|
219
|
+
constructor(re) {
|
|
220
|
+
var ptr0 = passStringToWasm0(re, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
221
|
+
var len0 = WASM_VECTOR_LEN;
|
|
222
|
+
var ret = wasm.rregexp_new(ptr0, len0);
|
|
223
|
+
return RRegExp.__wrap(ret);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @param {string} text
|
|
227
|
+
* @returns {boolean}
|
|
228
|
+
*/
|
|
229
|
+
is_match(text) {
|
|
230
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
231
|
+
var len0 = WASM_VECTOR_LEN;
|
|
232
|
+
var ret = wasm.rregexp_is_match(this.ptr, ptr0, len0);
|
|
233
|
+
return ret !== 0;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* @param {string} text
|
|
237
|
+
* @param {number} start
|
|
238
|
+
* @returns {boolean}
|
|
239
|
+
*/
|
|
240
|
+
is_match_at(text, start) {
|
|
241
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
242
|
+
var len0 = WASM_VECTOR_LEN;
|
|
243
|
+
var ret = wasm.rregexp_is_match_at(this.ptr, ptr0, len0, start);
|
|
244
|
+
return ret !== 0;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @param {string} text
|
|
248
|
+
* @returns {any}
|
|
249
|
+
*/
|
|
250
|
+
find(text) {
|
|
251
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
252
|
+
var len0 = WASM_VECTOR_LEN;
|
|
253
|
+
var ret = wasm.rregexp_find(this.ptr, ptr0, len0);
|
|
254
|
+
return takeObject(ret);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* @param {string} text
|
|
258
|
+
* @param {number} start
|
|
259
|
+
* @returns {any}
|
|
260
|
+
*/
|
|
261
|
+
find_at(text, start) {
|
|
262
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
263
|
+
var len0 = WASM_VECTOR_LEN;
|
|
264
|
+
var ret = wasm.rregexp_find_at(this.ptr, ptr0, len0, start);
|
|
265
|
+
return takeObject(ret);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* @param {string} text
|
|
269
|
+
* @returns {any}
|
|
270
|
+
*/
|
|
271
|
+
find_all(text) {
|
|
272
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
273
|
+
var len0 = WASM_VECTOR_LEN;
|
|
274
|
+
var ret = wasm.rregexp_find_all(this.ptr, ptr0, len0);
|
|
275
|
+
return takeObject(ret);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* @param {string} text
|
|
279
|
+
* @param {string} rep
|
|
280
|
+
* @returns {string}
|
|
281
|
+
*/
|
|
282
|
+
replace(text, rep) {
|
|
283
|
+
try {
|
|
284
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
285
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
286
|
+
var len0 = WASM_VECTOR_LEN;
|
|
287
|
+
var ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
288
|
+
var len1 = WASM_VECTOR_LEN;
|
|
289
|
+
wasm.rregexp_replace(retptr, this.ptr, ptr0, len0, ptr1, len1);
|
|
290
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
291
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
292
|
+
return getStringFromWasm0(r0, r1);
|
|
293
|
+
} finally {
|
|
294
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
295
|
+
wasm.__wbindgen_free(r0, r1);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* @param {string} text
|
|
300
|
+
* @param {number} limit
|
|
301
|
+
* @param {string} rep
|
|
302
|
+
* @returns {string}
|
|
303
|
+
*/
|
|
304
|
+
replacen(text, limit, rep) {
|
|
305
|
+
try {
|
|
306
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
307
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
308
|
+
var len0 = WASM_VECTOR_LEN;
|
|
309
|
+
var ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
310
|
+
var len1 = WASM_VECTOR_LEN;
|
|
311
|
+
wasm.rregexp_replacen(retptr, this.ptr, ptr0, len0, limit, ptr1, len1);
|
|
312
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
313
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
314
|
+
return getStringFromWasm0(r0, r1);
|
|
315
|
+
} finally {
|
|
316
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
317
|
+
wasm.__wbindgen_free(r0, r1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @param {string} text
|
|
322
|
+
* @param {string} rep
|
|
323
|
+
* @returns {string}
|
|
324
|
+
*/
|
|
325
|
+
replace_all(text, rep) {
|
|
326
|
+
try {
|
|
327
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
328
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
329
|
+
var len0 = WASM_VECTOR_LEN;
|
|
330
|
+
var ptr1 = passStringToWasm0(rep, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
331
|
+
var len1 = WASM_VECTOR_LEN;
|
|
332
|
+
wasm.rregexp_replace_all(retptr, this.ptr, ptr0, len0, ptr1, len1);
|
|
333
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
334
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
335
|
+
return getStringFromWasm0(r0, r1);
|
|
336
|
+
} finally {
|
|
337
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
|
+
wasm.__wbindgen_free(r0, r1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* @param {string} text
|
|
343
|
+
* @returns {any}
|
|
344
|
+
*/
|
|
345
|
+
split(text) {
|
|
346
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
347
|
+
var len0 = WASM_VECTOR_LEN;
|
|
348
|
+
var ret = wasm.rregexp_split(this.ptr, ptr0, len0);
|
|
349
|
+
return takeObject(ret);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* @param {string} text
|
|
353
|
+
* @param {number} limit
|
|
354
|
+
* @returns {any}
|
|
355
|
+
*/
|
|
356
|
+
splitn(text, limit) {
|
|
357
|
+
var ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
358
|
+
var len0 = WASM_VECTOR_LEN;
|
|
359
|
+
var ret = wasm.rregexp_splitn(this.ptr, ptr0, len0, limit);
|
|
360
|
+
return takeObject(ret);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* @returns {any}
|
|
364
|
+
*/
|
|
365
|
+
syntax() {
|
|
366
|
+
var ret = wasm.rregexp_syntax(this.ptr);
|
|
367
|
+
return takeObject(ret);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
372
|
+
takeObject(arg0);
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export function __wbindgen_string_new(arg0, arg1) {
|
|
376
|
+
var ret = getStringFromWasm0(arg0, arg1);
|
|
377
|
+
return addHeapObject(ret);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
export function __wbindgen_number_new(arg0) {
|
|
381
|
+
var ret = arg0;
|
|
382
|
+
return addHeapObject(ret);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export function __wbg_new_949bbc1147195c4e() {
|
|
386
|
+
var ret = new Array();
|
|
387
|
+
return addHeapObject(ret);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export function __wbg_new_0b83d3df67ecb33e() {
|
|
391
|
+
var ret = new Object();
|
|
392
|
+
return addHeapObject(ret);
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
export function __wbg_push_284486ca27c6aa8b(arg0, arg1) {
|
|
396
|
+
var ret = getObject(arg0).push(getObject(arg1));
|
|
397
|
+
return ret;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export function __wbg_new_342a24ca698edd87(arg0, arg1) {
|
|
401
|
+
var ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
402
|
+
return addHeapObject(ret);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
export function __wbg_set_82a4e8a85e31ac42() { return handleError(function (arg0, arg1, arg2) {
|
|
406
|
+
var ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
407
|
+
return ret;
|
|
408
|
+
}, arguments) };
|
|
409
|
+
|
|
410
|
+
export function __wbindgen_debug_string(arg0, arg1) {
|
|
411
|
+
var ret = debugString(getObject(arg1));
|
|
412
|
+
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
413
|
+
var len0 = WASM_VECTOR_LEN;
|
|
414
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
415
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
export function __wbindgen_throw(arg0, arg1) {
|
|
419
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
export function __wbindgen_rethrow(arg0) {
|
|
423
|
+
throw takeObject(arg0);
|
|
424
|
+
};
|
|
425
|
+
|
package/lib/rregex.wasm
ADDED
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export function __wbg_rregexp_free(a: number): void;
|
|
5
|
+
export function rregexp_new(a: number, b: number): number;
|
|
6
|
+
export function rregexp_is_match(a: number, b: number, c: number): number;
|
|
7
|
+
export function rregexp_is_match_at(a: number, b: number, c: number, d: number): number;
|
|
8
|
+
export function rregexp_find(a: number, b: number, c: number): number;
|
|
9
|
+
export function rregexp_find_at(a: number, b: number, c: number, d: number): number;
|
|
10
|
+
export function rregexp_find_all(a: number, b: number, c: number): number;
|
|
11
|
+
export function rregexp_replace(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
12
|
+
export function rregexp_replacen(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
|
|
13
|
+
export function rregexp_replace_all(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
14
|
+
export function rregexp_split(a: number, b: number, c: number): number;
|
|
15
|
+
export function rregexp_splitn(a: number, b: number, c: number, d: number): number;
|
|
16
|
+
export function rregexp_syntax(a: number): number;
|
|
17
|
+
export function get_metadata(): number;
|
|
18
|
+
export function __wbindgen_malloc(a: number): number;
|
|
19
|
+
export function __wbindgen_realloc(a: number, b: number, c: number): number;
|
|
20
|
+
export function __wbindgen_add_to_stack_pointer(a: number): number;
|
|
21
|
+
export function __wbindgen_free(a: number, b: number): void;
|
|
22
|
+
export function __wbindgen_exn_store(a: number): void;
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @returns {any}
|
|
5
|
+
*/
|
|
6
|
+
export function get_metadata(): any;
|
|
7
|
+
/**
|
|
8
|
+
*/
|
|
9
|
+
export class RRegExp {
|
|
10
|
+
free(): void;
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} re
|
|
13
|
+
*/
|
|
14
|
+
constructor(re: string);
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} text
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
is_match(text: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} text
|
|
22
|
+
* @param {number} start
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
is_match_at(text: string, start: number): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} text
|
|
28
|
+
* @returns {any}
|
|
29
|
+
*/
|
|
30
|
+
find(text: string): any;
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} text
|
|
33
|
+
* @param {number} start
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
find_at(text: string, start: number): any;
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} text
|
|
39
|
+
* @returns {any}
|
|
40
|
+
*/
|
|
41
|
+
find_all(text: string): any;
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} text
|
|
44
|
+
* @param {string} rep
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
replace(text: string, rep: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* @param {string} text
|
|
50
|
+
* @param {number} limit
|
|
51
|
+
* @param {string} rep
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
replacen(text: string, limit: number, rep: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} text
|
|
57
|
+
* @param {string} rep
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
replace_all(text: string, rep: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} text
|
|
63
|
+
* @returns {any}
|
|
64
|
+
*/
|
|
65
|
+
split(text: string): any;
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} text
|
|
68
|
+
* @param {number} limit
|
|
69
|
+
* @returns {any}
|
|
70
|
+
*/
|
|
71
|
+
splitn(text: string, limit: number): any;
|
|
72
|
+
/**
|
|
73
|
+
* @returns {any}
|
|
74
|
+
*/
|
|
75
|
+
syntax(): any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
79
|
+
|
|
80
|
+
export interface InitOutput {
|
|
81
|
+
readonly memory: WebAssembly.Memory;
|
|
82
|
+
readonly __wbg_rregexp_free: (a: number) => void;
|
|
83
|
+
readonly rregexp_new: (a: number, b: number) => number;
|
|
84
|
+
readonly rregexp_is_match: (a: number, b: number, c: number) => number;
|
|
85
|
+
readonly rregexp_is_match_at: (a: number, b: number, c: number, d: number) => number;
|
|
86
|
+
readonly rregexp_find: (a: number, b: number, c: number) => number;
|
|
87
|
+
readonly rregexp_find_at: (a: number, b: number, c: number, d: number) => number;
|
|
88
|
+
readonly rregexp_find_all: (a: number, b: number, c: number) => number;
|
|
89
|
+
readonly rregexp_replace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
90
|
+
readonly rregexp_replacen: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
91
|
+
readonly rregexp_replace_all: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
92
|
+
readonly rregexp_split: (a: number, b: number, c: number) => number;
|
|
93
|
+
readonly rregexp_splitn: (a: number, b: number, c: number, d: number) => number;
|
|
94
|
+
readonly rregexp_syntax: (a: number) => number;
|
|
95
|
+
readonly get_metadata: () => number;
|
|
96
|
+
readonly __wbindgen_malloc: (a: number) => number;
|
|
97
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
|
|
98
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
99
|
+
readonly __wbindgen_free: (a: number, b: number) => void;
|
|
100
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
105
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
106
|
+
*
|
|
107
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
108
|
+
*
|
|
109
|
+
* @returns {Promise<InitOutput>}
|
|
110
|
+
*/
|
|
111
|
+
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rregex",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Rust Regex binding for Javascript",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "./lib/commonjs.js",
|
|
7
|
+
"browser": "./lib/browser.js",
|
|
8
|
+
"module": "./lib/module.js",
|
|
9
|
+
"types": "./lib/types.d.ts",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"semantic-release": "^18.0.1"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"setup": "./bin/install.sh",
|
|
15
|
+
"build": "./bin/build.sh",
|
|
16
|
+
"test": "wasm-pack test",
|
|
17
|
+
"semantic-release": "semantic-release"
|
|
18
|
+
},
|
|
19
|
+
"release": {
|
|
20
|
+
"ci": false,
|
|
21
|
+
"branches": [
|
|
22
|
+
"master"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/2fd/rregex.git"
|
|
28
|
+
},
|
|
29
|
+
"author": "Fede Ramirez <i@2fd.me>",
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/2fd/rregex/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/2fd/rregex#readme"
|
|
35
|
+
}
|