rregex 1.5.0 → 1.5.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 CHANGED
@@ -1,25 +1,21 @@
1
1
  # rregex
2
2
 
3
- A WebAssembly build of [Rust Regex](https://docs.rs/regex/latest/regex/) for Javascript
4
-
5
- > Note: this project is not intended to be used in production jet
6
-
7
- * [Why Rust Regex](#why-rust-regex)
8
- * [Install](#install)
9
- * [API](#api)
10
- * [`isMatch(text: string): boolean`](#ismatchtext-string-boolean)
11
- * [`isMatchAt(text: string, limit: number): boolean`](#ismatchattext-string-limit-number-boolean)
12
- * [`find(text: string): Match | undefined;`](#findtext-string-match--undefined)
13
- * [`findAt(text: string): Match | undefined;`](#findattext-string-match--undefined)
14
- * [`findAll(text: string): Match[];`](#findalltext-string-match)
15
- * [`replace(text: string, rep: string): string;`](#replacetext-string-rep-string-string)
16
- * [`replaceAll(text: string, rep: string): string;`](#replacealltext-string-rep-string-string)
17
- * [`replacen(text: string, limit: number, rep: string): string;`](#replacentext-string-limit-number-rep-string-string)
18
- * [`split(text: string): string[];`](#splittext-string-string)
19
- * [`splitn(text: string, limit: number): string[];`](#splitntext-string-limit-number-string)
20
- * [`shortestMatch(text: string): number | undefined;`](#shortestmatchtext-string-number--undefined)
21
- * [`shortestMatchAt(text: string, limit: number): number | undefined;`](#shortestmatchattext-string-limit-number-number--undefined)
22
- * [Known Issues](#known-issues)
3
+ A dependency-free WebAssembly build of [Rust Regex](https://docs.rs/regex/latest/regex/) for Javascript
4
+
5
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/2fd/rregex/release.yml?branch=master) ![GitHub Release](https://img.shields.io/github/v/release/2fd/rregex) ![NPM Version](https://img.shields.io/npm/v/rregex)
6
+ [![JSR](https://jsr.io/badges/@rregex/rregex)](https://jsr.io/@rregex/rregex)
7
+
8
+ - [Why Rust Regex](#why-rust-regex)
9
+ - [Install](#install)
10
+ - [Supported Runtimes](#supported-runtimes)
11
+ - [API](https://tsdocs.dev/docs/rregex/latest)
12
+ - [`RRegex`](https://tsdocs.dev/docs/rregex/latest/classes/RRegex.html)
13
+ - [`RRegexSet`](https://tsdocs.dev/docs/rregex/latest/classes/RRegexSet.html)
14
+ - [`Match`](https://tsdocs.dev/docs/rregex/latest/types/Match.html)
15
+ - [`Captures`](https://tsdocs.dev/docs/rregex/latest/types/Captures.html)
16
+ - [`escape`](https://tsdocs.dev/docs/rregex/latest/functions/escape.html)
17
+ - [Benchmarks](#benchmarks)
18
+ - [Known Issues](#known-issues)
23
19
 
24
20
  ## Why Rust Regex
25
21
 
@@ -30,202 +26,95 @@ Rust has a powerful Regex library with a lot of features that don't exists en th
30
26
  ## Install
31
27
 
32
28
  ```bash
33
- npm install rregex
34
- ```
35
-
36
- ## API
37
-
38
- Similar to the native `Regex` object you can create a new `RRegex` instance using a string.
39
-
40
- ```typescript
41
- import { RRegex } from "rregex";
42
- const re = new RRegex("^d{4}-d{2}-d{2}$");
43
- assert.equal(re.isMatch("2014-01-01"), true);
44
- ```
29
+ # NPM
30
+ npm install rregex
45
31
 
46
- > Note: It doesn't take a second parameter because fags are part of the syntax ([See Documentation](https://docs.rs/regex/latest/regex/#grouping-and-flags))
32
+ # Yarn
33
+ yarn add rregex
47
34
 
48
- ### `isMatch(text: string): boolean;`
35
+ # PNPM
36
+ pnpm add rregex
49
37
 
50
- Returns true if and only if there is a match for the regex in the string given. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match))
38
+ # Deno
39
+ deno add @rregex/rregex
51
40
 
52
- ```typescript
53
- const text = "I categorically deny having triskaidekaphobia.";
54
- const re = new RRegex("\\b\\w{13}\\b");
55
- expect(re.isMatch(text)).toEqual(true);
41
+ # JSR
42
+ npx jsr add @rregex/rregex
56
43
  ```
57
44
 
58
- ### `isMatchAt(text: string, limit: number): boolean;`
45
+ ## Supported Runtimes
59
46
 
60
- Returns the same as is_match, but starts the search at the given offset. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.is_match_at))
47
+ This package includes builds for multiple runtimes
61
48
 
62
- ```typescript
63
- const text = "I categorically deny having triskaidekaphobia.";
64
- const re = new RRegex("\\b\\w{13}\\b");
65
- expect(re.isMatchAt(text, 1)).toBe(true);
66
- expect(re.isMatchAt(text, 5)).toBe(false);
67
- ```
49
+ | Runtime | Import | version |
50
+ | ------------------ | ------------------------------------------------------- | ---------- |
51
+ | Node.js (esm) | `import { RRegex, RRegexSet } from 'rregex'` | `*` |
52
+ | Node.js (commonjs) | `const { RRegex, RRegexSet } = require('rregex')` | `*` |
53
+ | Deno | `import { RRegex, RRegexSet } from '@rregex/rregex'` | `>=1.10.8` |
54
+ | Bun | `import { RRegex, RRegexSet } from '@rregex/rregex'` | `>=1.10.8` |
55
+ | Cloudflare Workers | `import { RRegex, RRegexSet } from 'rregex/lib/cf.mjs'` | `>=1.10.8` |
56
+ | Browser | TODO | |
57
+ | Standalone | TODO | |
68
58
 
69
- ### `find(text: string): Match | undefined;`
59
+ ## Benchmarks
70
60
 
71
- Returns the start and end byte range of the leftmost-first match in `text`. If no match exists, then `undefined` is returned. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.find))
61
+ In general terms `rregex` is at least 1 order of magnitud slower than the native `RegExp` object, but still have a good performance. **Unless you required some of the features that `rregex` provides, you should always consider using the native `RegExp` object**
72
62
 
73
- ```typescript
74
- const text = "I categorically deny having triskaidekaphobia.";
75
- const re = new RRegex("\\b\\w{13}\\b");
76
- expect(re.find(text)).toEqual({
77
- value: "categorically",
78
- start: 2,
79
- end: 15,
80
- });
81
- ```
63
+ > Benchmarks are executed using [test/deno.bench.mjs](./test/deno.bench.mjs), and [test/node.bench.mjs](./test/node.bench.mjs)
82
64
 
83
- ### `findAt(text: string): Match | undefined;`
65
+ ### Email
84
66
 
85
- Returns the same as find, but starts the search at the given offset. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_at))
67
+ | benchmark | time (avg) | iter/s |
68
+ | --------- | -------------: | ------: |
69
+ | RegExp | 254.8 µs/iter | 3,925.0 |
70
+ | RRegex | 1.7 ms/iter | 589.9 |
86
71
 
87
- ```typescript
88
- const text = "I categorically deny having triskaidekaphobia.";
89
- const re = new RRegex("\\b\\w{13}\\b");
90
- expect(re.findAt(text, 1)).toEqual({
91
- value: "categorically",
92
- start: 2,
93
- end: 15,
94
- });
72
+ > summary: `RegExp` is 6.65x faster than `RRegex`
95
73
 
96
- expect(re.findAt(text, 5)).toEqual(undefined);
97
- ```
98
-
99
- ### `findAll(text: string): Match[];`
100
-
101
- Returns an array for each successive non-overlapping match in text, returning the start and end byte indices with respect to text ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.find_iter))
102
-
103
- ```typescript
104
- const text = 'Retroactively relinquishing remunerations is reprehensible.'
105
- const re = new RRegex('\\b\\w{13}\\b')
106
- expect(re.findAll(text)).toEqual([
107
- {
108
- "end": 13,
109
- "start": 0,
110
- "value": "Retroactively",
111
- },
112
- {
113
- "end": 27,
114
- "start": 14,
115
- "value": "relinquishing",
116
- },
117
- {
118
- "end": 41,
119
- "start": 28,
120
- "value": "remunerations",
121
- },
122
- {
123
- "end": 58,
124
- "start": 45,
125
- "value": "reprehensible",
126
- },
127
- ])
128
- })
129
- ```
74
+ ### IP
130
75
 
131
- ### `replace(text: string, rep: string): string;`
76
+ | benchmark | time (avg) | iter/s |
77
+ | --------- | ------------: | --------: |
78
+ | RegExp | 39.1 µs/iter | 25,600.0 |
79
+ | RRegex | 1.4 ms/iter | 698.1 |
132
80
 
133
- Replaces the leftmost-first match with the replacement provided.
81
+ > summary: `RegExp` is 36.67x faster than `RRegex`
134
82
 
135
- If no match is found, then a copy of the string is returned unchanged. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace))
83
+ ### URI
136
84
 
137
- Note that this function is polymorphic with respect to the replacement. In typical usage, this can just be a normal string:
138
-
139
- ```typescript
140
- const re = new RRegex("[^01]+");
141
- expect(re.replace("1078910", "")).toBe("1010");
142
- ```
143
-
144
- But this is a bit cumbersome to use all the time. Instead, a simple syntax is supported that expands `$name` into the corresponding capture group. Here’s the last example, but using this expansion technique with named capture groups:
145
-
146
- ```typescript
147
- const re = new RRegex("(?P<last>[^,\\s]+),\\s+(?P<first>\\S+)");
148
- const result = re.replace("Springsteen, Bruce", "$first $last");
149
- expect(result).toEqual("Bruce Springsteen");
150
- ```
151
-
152
- Note that using `$2` instead of `$first` or `$1` instead of `$last` would produce the same result. To write a literal `$` use `$$`.
153
-
154
- Sometimes the replacement string requires use of curly braces to delineate a capture group replacement and surrounding literal text. For example, if we wanted to join two words together with an underscore:
155
-
156
- ```typescript
157
- const re = new RRegex("(?P<first>\\w+)\\s+(?P<second>\\w+)");
158
- const result = re.replace("deep fried", "${first}_$second");
159
- expect(result).toEqual("deep_fried");
160
- ```
85
+ | benchmark | time (avg) | iter/s |
86
+ | --------- | -------------: | ----------: |
87
+ | RegExp | 422.7 ns/iter | 2,366,000.0 |
88
+ | RRegex | 1.5 ms/iter | 652.6 |
161
89
 
162
- Without the curly braces, the capture group name `first_` would be used, and since it doesn’t exist, it would be replaced with the empty string.
163
-
164
- ### `replaceAll(text: string, rep: string): string;`
165
-
166
- Replaces all non-overlapping matches in `text` with the replacement provided. This is the same as calling `replacen` with `limit` set to `0`.
167
-
168
- See the documentation for `replace` for details on how to access capturing group matches in the replacement string. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.replace_all))
169
-
170
- ### `replacen(text: string, limit: number, rep: string): string;`
171
-
172
- Replaces at most `limit` non-overlapping matches in `text` with the replacement provided. If `limit` is 0, then all non-overlapping matches are replaced. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.replacen))
173
-
174
- ### `split(text: string): string[];`
175
-
176
- 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. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.split))
177
-
178
- ```typescript
179
- const re = new RRegex("[ \\t]+");
180
- const fields = re.split("a b \t c\td e");
181
- expect(fields).toEqual(["a", "b", "c", "d", "e"]);
182
- ```
183
-
184
- ### `splitn(text: string, limit: number): string[];`
185
-
186
- 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.([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.splitn))
187
-
188
- ```typescript
189
- const re = new RRegex("\\W+");
190
- const fields = re.splitn("Hey! How are you?", 3);
191
- expect(fields).toEqual(["Hey", "How", "are you?"]);
192
- ```
193
-
194
- ### `shortestMatch(text: string): number | undefined;`
195
-
196
- Returns the end location of a match in the text given.
197
-
198
- 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. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match))
199
-
200
- ```typescript
201
- const text = 'aaaaa'
202
- const pos = new RRegex('a+')
203
- expect(pos.shortestMatch(text)).toBe(1)
204
- ```
90
+ > summary: `RegExp` is 3625x faster than `RRegex`
205
91
 
206
- ### `shortestMatchAt(text: string, limit: number): number | undefined;`
92
+ | benckmarks | benckmarks |
93
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
94
+ | [![Simple IP](./img/rregex-vs-native_-simple-ip.png)](https://jsbenchmark.com/#eyJjYXNlcyI6W3siaWQiOiJlZl9VbGJvYThpRGNYeGM3VUl4YnMiLCJjb2RlIjoiREFUQS5tYXRjaCgnKD86KD86MjVbMC01XXwyWzAtNF1bMC05XXxbMDFdP1swLTldWzAtOV0pXFxcXC4pezN9KD86MjVbMC01XXwyWzAtNF1bMC05XXxbMDFdP1swLTldWzAtOV0pJykiLCJkZXBlbmRlbmNpZXMiOltdLCJuYW1lIjoiUmVnRXhwOiBJUCJ9LHsiaWQiOiI0QkxuZmtPd0p4ZTZhQ0NSVmpIOVUiLCJjb2RlIjoibmV3IHJyZWdleC5SUmVnZXgoXCIoPzooPzoyNVswLTVdfDJbMC00XVswLTldfFswMV0_WzAtOV1bMC05XSlcXFxcLil7M30oPzoyNVswLTVdfDJbMC00XVswLTldfFswMV0_WzAtOV1bMC05XSlcIikuZmluZChEQVRBKSIsImRlcGVuZGVuY2llcyI6W10sIm5hbWUiOiJSUmVnZXg6IElQIn1dLCJjb25maWciOnsibmFtZSI6IlJSZWdleCB2cyBOYXRpdmU6IElQIiwicGFyYWxsZWwiOnRydWUsImdsb2JhbFRlc3RDb25maWciOnsiZGVwZW5kZW5jaWVzIjpbeyJ1cmwiOiJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL3JyZWdleEAxLjEwLjEwL2xpYi93ZWIubWluLmpzIiwibmFtZSI6InJyZWdleCIsImVzbSI6dHJ1ZX1dfSwiZGF0YUNvZGUiOiJjb25zdCB3cmVzID0gYXdhaXQgZmV0Y2goJ2h0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vcnJlZ2V4QDEuMT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
- Returns the same as shortest_match, but starts the search at the given offset. ([See Documentation](https://docs.rs/regex/latest/regex/struct.Regex.html#method.shortest_match_at))
97
+ > **Note:** In order to compare with native regex these benchmarks follow the [`mariomka/regex-benchmark`](https://github.com/mariomka/regex-benchmark) structure
209
98
 
210
99
  ## Known Issues
211
100
 
212
101
  If you call `splitn(text, limit)` and the expected result length is equal to `limit - 1` the result will include an extra item `""`, this behavior does not happen if `limit` es greater. **`fixed at >=1.3`**
213
102
 
214
103
  ```ts
215
- const regex = new RRegex(',')
216
- expect(regex.splitn('a,b,c', 0)).toEqual([])
217
- expect(regex.splitn('a,b,c', 1)).toEqual(['a,b,c'])
218
- expect(regex.splitn('a,b,c', 2)).toEqual(['a', 'b,c'])
219
- expect(regex.splitn('a,b,c', 3)).toEqual(['a', 'b', 'c'])
220
-
221
- // This result includes an unexpected extra item
222
- expect(regex.splitn('a,b,c', 4)).toEqual(['a', 'b', 'c', ''])
223
- expect(regex.splitn('a,b,c', 5)).toEqual(['a', 'b', 'c'])
224
-
225
- expect(regex.splitn('abc', 0)).toEqual([])
226
- expect(regex.splitn('abc', 1)).toEqual(['abc'])
227
-
228
- // This result includes an unexpected extra item
229
- expect(regex.splitn('abc', 2)).toEqual(['abc', ''])
230
- expect(regex.splitn('abc', 3)).toEqual(['abc'])
104
+ const regex = new RRegex(",");
105
+ expect(regex.splitn("a,b,c", 0)).toEqual([]);
106
+ expect(regex.splitn("a,b,c", 1)).toEqual(["a,b,c"]);
107
+ expect(regex.splitn("a,b,c", 2)).toEqual(["a", "b,c"]);
108
+ expect(regex.splitn("a,b,c", 3)).toEqual(["a", "b", "c"]);
109
+
110
+ // This result includes an unexpected extra item
111
+ expect(regex.splitn("a,b,c", 4)).toEqual(["a", "b", "c", ""]);
112
+ expect(regex.splitn("a,b,c", 5)).toEqual(["a", "b", "c"]);
113
+
114
+ expect(regex.splitn("abc", 0)).toEqual([]);
115
+ expect(regex.splitn("abc", 1)).toEqual(["abc"]);
116
+
117
+ // This result includes an unexpected extra item
118
+ expect(regex.splitn("abc", 2)).toEqual(["abc", ""]);
119
+ expect(regex.splitn("abc", 3)).toEqual(["abc"]);
231
120
  ```
package/jsr.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@rregex/rregex",
3
+ "version": "0.0.0-development",
4
+ "description": "A dependency-free WebAssembly build of Rust Regex for Javascript",
5
+ "exports": "./lib/esm.mjs",
6
+ "publish": {
7
+ "include": [
8
+ "LICENSE",
9
+ "README.md",
10
+ "jsr.json",
11
+ "lib/rregex.wasm",
12
+ "lib/rregex.wasm.d.ts",
13
+ "lib/esm.mjs",
14
+ "lib/esm.d.ts"
15
+ ]
16
+ }
17
+ }