@regex-designer/js 0.1.0 → 0.2.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/README.md +134 -128
- package/dist/index.d.ts +37 -65
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -81
- package/dist/index.js.map +1 -1
- package/package.json +7 -15
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,243 +1,249 @@
|
|
|
1
|
-
# Regular Expression Designer
|
|
1
|
+
# Regular Expression Designer | JavaScript
|
|
2
2
|
|
|
3
|
-
A small TypeScript library for composing JavaScript regular expressions in a readable, reusable way.
|
|
3
|
+
A small TypeScript library for composing native JavaScript regular expressions in a readable, reusable way.
|
|
4
4
|
|
|
5
5
|
## API
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- [default](#default)
|
|
8
|
+
- [set / var](#set--var)
|
|
9
|
+
- [tpl](#tpl)
|
|
10
|
+
- [raw](#raw)
|
|
11
|
+
- [start / end / whole](#start--end--whole)
|
|
12
|
+
- [group](#group)
|
|
13
|
+
- [named](#named)
|
|
14
|
+
- [ref](#ref)
|
|
15
|
+
- [opt](#opt)
|
|
16
|
+
- [qty](#qty)
|
|
17
|
+
- [or](#or)
|
|
18
|
+
- [ahead / ahead_pos / ahead_neg](#ahead--ahead_pos--ahead_neg)
|
|
19
|
+
- [behind / behind_pos / behind_neg](#behind--behind_pos--behind_neg)
|
|
20
|
+
|
|
21
|
+
The JavaScript package exposes a default factory and a `JSRegexDesigner` class. It extends the abstract `RegexDesigner` contract from `@regex-designer/core`. Templates are compiled to a native `RegExp`.
|
|
8
22
|
|
|
9
23
|
```ts
|
|
10
|
-
import createDesigner from
|
|
24
|
+
import createDesigner from "@regex-designer/js";
|
|
25
|
+
|
|
26
|
+
const r$ = createDesigner();
|
|
11
27
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.set('identifier', r$.qty([1, Infinity], /[a-z0-9-]/));
|
|
28
|
+
r$.set("number", r$.qty([1, Infinity], "[0-9]"));
|
|
29
|
+
r$.set("identifier", r$.qty([1, Infinity], "[a-z0-9-]"));
|
|
15
30
|
|
|
31
|
+
// (?<version>(?:[0-9]){1,}\.(?:[0-9]){1,}\.(?:[0-9]){1,}(?:-(?<prerelease>(?:[a-z0-9-]){1,}))?)
|
|
16
32
|
const template = r$.named(
|
|
17
|
-
|
|
18
|
-
r$.var(
|
|
19
|
-
r$.opt(
|
|
33
|
+
"version",
|
|
34
|
+
r$.var("number"), "\\.", r$.var("number"), "\\.", r$.var("number"),
|
|
35
|
+
r$.opt("-", r$.named("prerelease", r$.var("identifier"))),
|
|
20
36
|
);
|
|
21
|
-
const regex = template(
|
|
22
|
-
regex.test('12.3.4-beta-1'); // true
|
|
23
|
-
regex.exec('12.3.4-beta-1')?.groups; // { version: '12.3.4-beta-1', prerelease: 'beta-1' }
|
|
24
|
-
```
|
|
37
|
+
const regex = template("i"); // Compile the template to a native RegExp
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
tpl(...patterns: RegexValue[]): RegexTemplate
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Concatenates pattern parts as-is, without adding grouping, alternation, or escaping:
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
r$.tpl('A', r$.raw('B.C')); // AB\\.C
|
|
39
|
+
regex.test("12.3.4-beta-1"); // true
|
|
40
|
+
regex.exec("12.3.4-beta-1")?.groups; // { version: "12.3.4-beta-1", prerelease: "beta-1" }
|
|
36
41
|
```
|
|
37
42
|
|
|
38
43
|
### default
|
|
39
44
|
|
|
40
45
|
```ts
|
|
41
|
-
default function():
|
|
46
|
+
default function(): JSRegexDesigner
|
|
42
47
|
```
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
Create a new JavaScript regex designer with its own variable scope.
|
|
45
50
|
|
|
46
51
|
```ts
|
|
47
|
-
import createDesigner from
|
|
52
|
+
import createDesigner from "@regex-designer/js";
|
|
48
53
|
|
|
49
|
-
const r
|
|
50
|
-
r$.named('user', /[^@]+/, '@', /[a-z]+/); // (?<user>[^@]+@[a-z]+)
|
|
54
|
+
const r$: JSRegexDesigner = createDesigner();
|
|
51
55
|
```
|
|
52
56
|
|
|
53
|
-
###
|
|
57
|
+
### set / var
|
|
54
58
|
|
|
55
59
|
```ts
|
|
56
|
-
|
|
60
|
+
set(name: string, ...patterns: RegexValue[]): this
|
|
61
|
+
var(name: string): RegexTemplate
|
|
57
62
|
```
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
Define a reusable lazy variable on a designer, then reference it when composing
|
|
65
|
+
a pattern. The variable resolves when the template is rendered. Rendering an unset variable or circular dependencies between variables throws an error.
|
|
60
66
|
|
|
61
67
|
```ts
|
|
62
|
-
r$.or(
|
|
63
|
-
r$.
|
|
68
|
+
r$.set("word", r$.or("cat", "dog"));
|
|
69
|
+
r$.var("word"); // cat|dog
|
|
64
70
|
```
|
|
65
71
|
|
|
66
|
-
###
|
|
72
|
+
### tpl
|
|
67
73
|
|
|
68
74
|
```ts
|
|
69
|
-
|
|
75
|
+
tpl(...patterns: RegexValue[]): RegexTemplate
|
|
70
76
|
```
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
Concatenate patterns without adding groups or escaping.
|
|
73
79
|
|
|
74
80
|
```ts
|
|
75
|
-
r$.
|
|
76
|
-
r$.named('word', r$.or('cat', 'dog')); // (?<word>cat|dog)
|
|
81
|
+
r$.tpl("A", "B"); // AB
|
|
77
82
|
```
|
|
78
83
|
|
|
79
|
-
###
|
|
84
|
+
### raw
|
|
80
85
|
|
|
81
86
|
```ts
|
|
82
|
-
|
|
83
|
-
type GroupOptions = boolean | { name: string } | { capture: boolean };
|
|
87
|
+
raw(...patterns: string[]): RegexTemplate
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
Escape literal text for use in a regex pattern.
|
|
87
91
|
|
|
88
92
|
```ts
|
|
89
|
-
r$.
|
|
90
|
-
r$.
|
|
91
|
-
r$.group({ capture: false }, 'A', 'B'); // (?:AB)
|
|
93
|
+
r$.raw("a.b", "*"); // \x61\.b\*
|
|
94
|
+
r$.raw("https://example.com"); // \x68ttps\x3a\/\/example\.com
|
|
92
95
|
```
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- `options` can be a boolean or an object.
|
|
97
|
-
- `true` creates a normal capturing group.
|
|
98
|
-
- `false` creates a non-capturing group.
|
|
99
|
-
- `group({ name: 'x' })` creates a named capturing group.
|
|
100
|
-
- `name` and `capture` are mutually exclusive; passing both throws a `TypeError`.
|
|
101
|
-
|
|
102
|
-
### opt(...patterns)
|
|
97
|
+
### start / end / whole
|
|
103
98
|
|
|
104
99
|
```ts
|
|
105
|
-
|
|
100
|
+
start(...patterns: RegexValue[]): RegexTemplate
|
|
101
|
+
end(...patterns: RegexValue[]): RegexTemplate
|
|
102
|
+
whole(...patterns: RegexValue[]): RegexTemplate
|
|
106
103
|
```
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
Choose whether the concatenated patterns must match at the [start, end, or across the whole input](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Input_boundary_assertion).
|
|
109
106
|
|
|
110
107
|
```ts
|
|
111
|
-
r$.
|
|
112
|
-
r$.
|
|
108
|
+
r$.start("foo"); // ^(?:foo)
|
|
109
|
+
r$.end("bar"); // (?:bar)$
|
|
110
|
+
r$.whole("baz"); // ^(?:baz)$
|
|
113
111
|
```
|
|
114
112
|
|
|
115
|
-
###
|
|
113
|
+
### group
|
|
116
114
|
|
|
117
115
|
```ts
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
group(options: boolean, ...patterns: RegexValue[]): RegexTemplate
|
|
117
|
+
group(options: { name: string }, ...patterns: RegexValue[]): RegexTemplate
|
|
118
|
+
group(options: { capture?: boolean }, ...patterns: RegexValue[]): RegexTemplate
|
|
121
119
|
```
|
|
122
120
|
|
|
123
|
-
|
|
121
|
+
Group patterns using [capturing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Capturing_group)
|
|
122
|
+
or [non-capturing groups](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Non-capturing_group),
|
|
123
|
+
optionally assigning a [capture name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group).
|
|
124
124
|
|
|
125
125
|
```ts
|
|
126
|
-
r$.
|
|
127
|
-
r$.
|
|
128
|
-
r$.
|
|
129
|
-
r$.
|
|
126
|
+
r$.group(true, "A"); // (A)
|
|
127
|
+
r$.group(false, "A", "B"); // (?:AB)
|
|
128
|
+
r$.group({ name: "part" }, "A", "B"); // (?<part>AB)
|
|
129
|
+
r$.group({ capture: true }, "A"); // (A)
|
|
130
|
+
r$.group({ capture: false }, "A", "B"); // (?:AB)
|
|
130
131
|
```
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
- `number` means an exact repetition count.
|
|
135
|
-
- `[min, max?]` means a range, with `max` omitted for open-ended repetition.
|
|
136
|
-
- `{ exact }` is a shorthand for exact repetition.
|
|
137
|
-
- `{ min, max? }` creates a bounded repetition.
|
|
138
|
-
- `max` can be `Infinity` for open-ended repetition.
|
|
139
|
-
- `{ greedy?: boolean }` for lazy quantifiers.
|
|
140
|
-
- Quantifiers are greedy by default.
|
|
141
|
-
|
|
142
|
-
### raw(...strings)
|
|
133
|
+
### named
|
|
143
134
|
|
|
144
135
|
```ts
|
|
145
|
-
|
|
136
|
+
named(name: string, ...patterns: RegexValue[]): RegexTemplate
|
|
146
137
|
```
|
|
147
138
|
|
|
148
|
-
|
|
139
|
+
Create a [named capturing group](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_capturing_group)
|
|
140
|
+
around the concatenated patterns.
|
|
149
141
|
|
|
150
142
|
```ts
|
|
151
|
-
r$.
|
|
152
|
-
r$.
|
|
143
|
+
r$.named("value", "A", "B"); // (?<value>AB)
|
|
144
|
+
r$.named("word", r$.or("cat", "dog")); // (?<word>cat|dog)
|
|
153
145
|
```
|
|
154
146
|
|
|
155
|
-
### ref
|
|
147
|
+
### ref
|
|
156
148
|
|
|
157
149
|
```ts
|
|
158
150
|
ref(reference: number | string): RegexTemplate
|
|
159
151
|
```
|
|
160
152
|
|
|
161
|
-
|
|
153
|
+
Create a [numeric](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Backreference) or [named](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Named_backreference) backreference.
|
|
162
154
|
|
|
163
155
|
```ts
|
|
164
|
-
// (B)\1
|
|
165
156
|
r$.tpl(
|
|
166
|
-
r$.group(true,
|
|
157
|
+
r$.group(true, "B"),
|
|
167
158
|
r$.ref(1),
|
|
168
|
-
);
|
|
159
|
+
); // (B)\1
|
|
169
160
|
|
|
170
|
-
// (?<name>B)\k<name>
|
|
171
161
|
r$.tpl(
|
|
172
|
-
r$.named(
|
|
173
|
-
r$.ref(
|
|
174
|
-
);
|
|
162
|
+
r$.named("name", "B"),
|
|
163
|
+
r$.ref("name"),
|
|
164
|
+
); // (?<name>B)\k<name>
|
|
175
165
|
```
|
|
176
166
|
|
|
177
|
-
###
|
|
167
|
+
### opt
|
|
178
168
|
|
|
179
169
|
```ts
|
|
180
|
-
|
|
181
|
-
ahead_pos(...patterns: RegexValue[]): RegexTemplate
|
|
182
|
-
ahead_neg(...patterns: RegexValue[]): RegexTemplate
|
|
170
|
+
opt(...patterns: RegexValue[]): RegexTemplate
|
|
183
171
|
```
|
|
184
172
|
|
|
185
|
-
|
|
173
|
+
Make the concatenated patterns [optional](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Quantifier) using a non-capturing group.
|
|
186
174
|
|
|
187
175
|
```ts
|
|
188
|
-
r$.
|
|
189
|
-
r$.
|
|
176
|
+
r$.opt("C"); // (?:C)?
|
|
177
|
+
r$.opt(r$.named("value", "A", "B")); // (?:(?<value>AB))?
|
|
190
178
|
```
|
|
191
179
|
|
|
192
|
-
###
|
|
180
|
+
### qty
|
|
193
181
|
|
|
194
182
|
```ts
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
183
|
+
qty(quantity: number, ...patterns: RegexValue[]): RegexTemplate
|
|
184
|
+
qty(quantity: [min: number, max?: number], ...patterns: RegexValue[]): RegexTemplate
|
|
185
|
+
qty(quantity: { exact: number; greedy?: boolean }, ...patterns: RegexValue[]): RegexTemplate
|
|
186
|
+
qty(quantity: { min: number; max?: number; greedy?: boolean }, ...patterns: RegexValue[]): RegexTemplate
|
|
198
187
|
```
|
|
199
188
|
|
|
200
|
-
|
|
189
|
+
[Repeat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Quantifier) the concatenated patterns according to the supplied bounds.
|
|
201
190
|
|
|
202
191
|
```ts
|
|
203
|
-
r$.
|
|
204
|
-
r$.
|
|
192
|
+
r$.qty(3, "A", "B"); // (?:AB){3}
|
|
193
|
+
r$.qty([3, 3], "A", "B"); // (?:AB){3}
|
|
194
|
+
r$.qty([1, 3], "A", "B"); // (?:AB){1,3}
|
|
195
|
+
r$.qty([1, Infinity], "A", "B"); // (?:AB){1,}
|
|
196
|
+
r$.qty({ exact: 3 }, "A", "B"); // (?:AB){3}
|
|
197
|
+
r$.qty({ exact: 3, greedy: false }, "A", "B"); // (?:AB){3}?
|
|
198
|
+
r$.qty({ min: 2 }, "A", "B"); // (?:AB){2,}
|
|
199
|
+
r$.qty({ min: 2, max: 5 }, "A", "B"); // (?:AB){2,5}
|
|
200
|
+
r$.qty({ min: 2, max: 5, greedy: false }, "A", "B"); // (?:AB){2,5}?
|
|
205
201
|
```
|
|
206
202
|
|
|
207
|
-
###
|
|
203
|
+
### or
|
|
208
204
|
|
|
209
205
|
```ts
|
|
210
|
-
|
|
211
|
-
var(name: string): RegexTemplate
|
|
206
|
+
or(...patterns: RegexValue[]): RegexTemplate
|
|
212
207
|
```
|
|
213
208
|
|
|
214
|
-
|
|
209
|
+
Join patterns with [disjunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Disjunction)
|
|
210
|
+
without adding groups.
|
|
215
211
|
|
|
216
212
|
```ts
|
|
217
|
-
r$.
|
|
218
|
-
r$.
|
|
213
|
+
r$.or("cat", "dog"); // cat|dog
|
|
214
|
+
r$.or("foo", "bar", r$.raw("baz")); // foo|bar|\x62az
|
|
219
215
|
```
|
|
220
216
|
|
|
221
|
-
|
|
217
|
+
### ahead / ahead_pos / ahead_neg
|
|
222
218
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
219
|
+
```ts
|
|
220
|
+
ahead(positive: boolean, ...patterns: RegexValue[]): RegexTemplate
|
|
221
|
+
ahead_pos(...patterns: RegexValue[]): RegexTemplate
|
|
222
|
+
ahead_neg(...patterns: RegexValue[]): RegexTemplate
|
|
223
|
+
```
|
|
228
224
|
|
|
229
|
-
|
|
225
|
+
Create a positive or negative [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion).
|
|
230
226
|
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
```ts
|
|
228
|
+
r$.ahead(true, "foo"); // (?=foo)
|
|
229
|
+
r$.ahead(false, "foo"); // (?!foo)
|
|
230
|
+
r$.ahead_pos("foo"); // (?=foo)
|
|
231
|
+
r$.ahead_neg("bar"); // (?!bar)
|
|
232
|
+
```
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
### behind / behind_pos / behind_neg
|
|
235
235
|
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
```ts
|
|
237
|
+
behind(positive: boolean, ...patterns: RegexValue[]): RegexTemplate
|
|
238
|
+
behind_pos(...patterns: RegexValue[]): RegexTemplate
|
|
239
|
+
behind_neg(...patterns: RegexValue[]): RegexTemplate
|
|
239
240
|
```
|
|
240
241
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
Create a positive or negative [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion).
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
r$.behind(true, "foo"); // (?<=foo)
|
|
246
|
+
r$.behind(false, "foo"); // (?<!foo)
|
|
247
|
+
r$.behind_pos("foo"); // (?<=foo)
|
|
248
|
+
r$.behind_neg("bar"); // (?<!bar)
|
|
249
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,83 +1,55 @@
|
|
|
1
|
-
/** A lazy regex template that can render pattern text or compile to a native RegExp. */
|
|
2
|
-
export interface RegexTemplate {
|
|
3
|
-
/** Compile the rendered pattern with the supplied flags. */
|
|
4
|
-
(flags?: string): RegExp;
|
|
5
|
-
/** Render the pattern; when compiling, validates embedded Unicode flags. */
|
|
6
|
-
render(flags?: string, compiling?: boolean): string;
|
|
7
|
-
/** Render the pattern text without compiling it. */
|
|
8
|
-
toString(): string;
|
|
9
|
-
}
|
|
10
|
-
/** Check whether a value is a regex template. */
|
|
11
|
-
export declare function isRegexTemplate(value: unknown): value is RegexTemplate;
|
|
12
1
|
/**
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
* The JavaScript package exposes a default factory and a `JSRegexDesigner` class. It extends the abstract `RegexDesigner` contract from `@regex-designer/core`. Templates are compiled to a native `RegExp`.
|
|
3
|
+
*/
|
|
4
|
+
import type { GroupOptions, QuantityOptions, RegexDesignerWithBackreferences, RegexDesignerWithLookarounds, RegexTemplate as CoreRegexTemplate, RegexValue as CoreRegexValue } from "@regex-designer/core";
|
|
5
|
+
import { RegexDesigner } from "@regex-designer/core";
|
|
6
|
+
export type { GroupNamedOptions, GroupOptions, QuantityNamedOptions, QuantityOptions, RegexDesignerWithBackreferences, RegexDesignerWithLookarounds, } from "@regex-designer/core";
|
|
7
|
+
export type RegexTemplate = CoreRegexTemplate<RegExp>;
|
|
8
|
+
export type RegexValue = CoreRegexValue<RegExp>;
|
|
9
|
+
export { isRegexTemplate } from "@regex-designer/core";
|
|
10
|
+
/**
|
|
11
|
+
* Create a new JavaScript regex designer with its own variable scope.
|
|
12
|
+
* @readme default
|
|
17
13
|
*/
|
|
18
|
-
export
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
name?: never;
|
|
25
|
-
capture?: boolean;
|
|
26
|
-
};
|
|
27
|
-
/** Configure a group with a capture boolean or named-group options. */
|
|
28
|
-
export type GroupOptions = GroupNamedOptions | boolean;
|
|
29
|
-
/** Repetition bounds; specify either an exact count or a minimum and optional maximum. */
|
|
30
|
-
export type QuantityNamedOptions = ({
|
|
31
|
-
exact: number;
|
|
32
|
-
min?: never;
|
|
33
|
-
max?: never;
|
|
34
|
-
} | {
|
|
35
|
-
exact?: never;
|
|
36
|
-
min: number;
|
|
37
|
-
max?: number;
|
|
38
|
-
}) & {
|
|
39
|
-
greedy?: boolean;
|
|
40
|
-
};
|
|
41
|
-
/** Repetition count, [minimum, maximum] tuple, or named bounds. */
|
|
42
|
-
export type QuantityOptions = number | [min: number, max?: number] | QuantityNamedOptions;
|
|
43
|
-
/** Compose lazy regex templates and resolve reusable variables in an isolated scope. */
|
|
44
|
-
export declare class RegexDesigner {
|
|
45
|
-
private readonly variables;
|
|
46
|
-
private readonly resolvingVariables;
|
|
14
|
+
export default function create(): JSRegexDesigner;
|
|
15
|
+
/**
|
|
16
|
+
* Templates are compiled to a native `RegExp`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class JSRegexDesigner extends RegexDesigner<RegExp> implements RegexDesignerWithBackreferences<RegExp>, RegexDesignerWithLookarounds<RegExp> {
|
|
19
|
+
protected createTemplate(render: (flags: string | undefined, compiling: boolean) => string): RegexTemplate;
|
|
47
20
|
/** Concatenate patterns without adding groups or escaping. */
|
|
48
21
|
tpl(...patterns: RegexValue[]): RegexTemplate;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
|
|
22
|
+
/** Escape literal text for use in a regex pattern. */
|
|
23
|
+
raw(...patterns: string[]): RegexTemplate;
|
|
24
|
+
/** Match the concatenated patterns at the start of the input. */
|
|
25
|
+
start(...patterns: RegexValue[]): RegexTemplate;
|
|
26
|
+
/** Match the concatenated patterns at the end of the input. */
|
|
27
|
+
end(...patterns: RegexValue[]): RegexTemplate;
|
|
28
|
+
/** Match the concatenated patterns across the whole input. */
|
|
29
|
+
whole(...patterns: RegexValue[]): RegexTemplate;
|
|
53
30
|
/** Group patterns, optionally capturing them or assigning a capture name. */
|
|
54
31
|
group(options: GroupOptions, ...patterns: RegexValue[]): RegexTemplate;
|
|
32
|
+
/** Create a named capturing group around the concatenated patterns. */
|
|
33
|
+
named(name: string, ...patterns: RegexValue[]): RegexTemplate;
|
|
34
|
+
/** Create a numeric or named backreference. */
|
|
35
|
+
ref(reference: number | string): RegexTemplate;
|
|
55
36
|
/** Make the concatenated patterns optional using a non-capturing group. */
|
|
56
37
|
opt(...patterns: RegexValue[]): RegexTemplate;
|
|
57
38
|
/** Repeat the concatenated patterns according to the supplied bounds. */
|
|
58
39
|
qty(quantity: QuantityOptions, ...patterns: RegexValue[]): RegexTemplate;
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
/** Create a positive or negative lookahead assertion. */
|
|
40
|
+
/** Join patterns with alternation without adding groups. */
|
|
41
|
+
or(...patterns: RegexValue[]): RegexTemplate;
|
|
42
|
+
/** Create a positive or negative [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion). */
|
|
62
43
|
ahead(positive: boolean, ...patterns: RegexValue[]): RegexTemplate;
|
|
63
|
-
/** Create a positive lookahead assertion. */
|
|
44
|
+
/** Create a positive [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion). */
|
|
64
45
|
ahead_pos(...patterns: RegexValue[]): RegexTemplate;
|
|
65
|
-
/** Create a negative lookahead assertion. */
|
|
46
|
+
/** Create a negative [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion). */
|
|
66
47
|
ahead_neg(...patterns: RegexValue[]): RegexTemplate;
|
|
67
|
-
/** Create a positive or negative lookbehind assertion. */
|
|
48
|
+
/** Create a positive or negative [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). */
|
|
68
49
|
behind(positive: boolean, ...patterns: RegexValue[]): RegexTemplate;
|
|
69
|
-
/** Create a positive lookbehind assertion. */
|
|
50
|
+
/** Create a positive [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). */
|
|
70
51
|
behind_pos(...patterns: RegexValue[]): RegexTemplate;
|
|
71
|
-
/** Create a negative lookbehind assertion. */
|
|
52
|
+
/** Create a negative [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). */
|
|
72
53
|
behind_neg(...patterns: RegexValue[]): RegexTemplate;
|
|
73
|
-
/** Create a numeric or named backreference. */
|
|
74
|
-
ref(reference: number | string): RegexTemplate;
|
|
75
|
-
/** Define or replace a lazy pattern variable on this designer. */
|
|
76
|
-
set(name: string, ...patterns: RegexValue[]): this;
|
|
77
|
-
private resolveVariable;
|
|
78
|
-
/** Reference a variable, resolving it when this template is rendered. */
|
|
79
|
-
var(name: string): RegexTemplate;
|
|
80
54
|
}
|
|
81
|
-
/** Create a new regex designer with its own variable scope. */
|
|
82
|
-
export default function create(): RegexDesigner;
|
|
83
55
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
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
* The JavaScript package exposes a default factory and a `JSRegexDesigner` class. It extends the abstract `RegexDesigner` contract from `@regex-designer/core`. Templates are compiled to a native `RegExp`.
|
|
3
|
+
*/
|
|
4
|
+
import { RegexDesigner, isRegexTemplate, } from "@regex-designer/core";
|
|
5
|
+
export { isRegexTemplate } from "@regex-designer/core";
|
|
5
6
|
function patternString(pattern, flags, compiling) {
|
|
6
7
|
if (pattern instanceof RegExp) {
|
|
7
|
-
const unicodeFlag = pattern.flags.includes(
|
|
8
|
+
const unicodeFlag = pattern.flags.includes("v") ? "v" : pattern.flags.includes("u") ? "u" : undefined;
|
|
8
9
|
if (compiling && unicodeFlag !== undefined && !flags?.includes(unicodeFlag)) {
|
|
9
10
|
throw new TypeError(`RegExp flag "${unicodeFlag}" must be passed when compiling the composed pattern`);
|
|
10
11
|
}
|
|
11
|
-
const scopedFlags = pattern.flags.replace(/[dgyuv]/g,
|
|
12
|
-
return scopedFlags ===
|
|
12
|
+
const scopedFlags = pattern.flags.replace(/[dgyuv]/g, "");
|
|
13
|
+
return scopedFlags === "" ? pattern.source : `(?${scopedFlags}:${pattern.source})`;
|
|
13
14
|
}
|
|
14
15
|
if (isRegexTemplate(pattern)) {
|
|
15
16
|
return pattern.render(flags, compiling);
|
|
@@ -23,22 +24,25 @@ function template(render) {
|
|
|
23
24
|
return regex;
|
|
24
25
|
}
|
|
25
26
|
function tpl(...patterns) {
|
|
26
|
-
return template((flags, compiling) => patterns.map(pattern => patternString(pattern, flags, compiling)).join(
|
|
27
|
+
return template((flags, compiling) => patterns.map(pattern => patternString(pattern, flags, compiling)).join(""));
|
|
27
28
|
}
|
|
28
29
|
function or(...patterns) {
|
|
29
|
-
return template((flags, compiling) => patterns.map(pattern => patternString(pattern, flags, compiling)).join(
|
|
30
|
+
return template((flags, compiling) => patterns.map(pattern => patternString(pattern, flags, compiling)).join("|"));
|
|
30
31
|
}
|
|
31
32
|
function group(options, ...patterns) {
|
|
32
|
-
if (typeof options !==
|
|
33
|
-
throw new TypeError(
|
|
33
|
+
if (typeof options !== "boolean" && options.name !== undefined && options.capture !== undefined) {
|
|
34
|
+
throw new TypeError("Group options \"name\" and \"capture\" are mutually exclusive");
|
|
34
35
|
}
|
|
35
36
|
return template((flags, compiling) => {
|
|
36
|
-
const name = typeof options ===
|
|
37
|
-
const capture = typeof options ===
|
|
38
|
-
const prefix = name !== undefined ? `?<${name}>` : capture ?
|
|
39
|
-
return `(${prefix}${patterns.map(pattern => patternString(pattern, flags, compiling)).join(
|
|
37
|
+
const name = typeof options === "boolean" ? undefined : options.name;
|
|
38
|
+
const capture = typeof options === "boolean" ? options : options.capture ?? true;
|
|
39
|
+
const prefix = name !== undefined ? `?<${name}>` : capture ? "" : "?:";
|
|
40
|
+
return `(${prefix}${patterns.map(pattern => patternString(pattern, flags, compiling)).join("")})`;
|
|
40
41
|
});
|
|
41
42
|
}
|
|
43
|
+
function anchor(start, end, patterns) {
|
|
44
|
+
return template((flags, compiling) => `${start ? "^" : ""}${patternString(group(false, ...patterns), flags, compiling)}${end ? "$" : ""}`);
|
|
45
|
+
}
|
|
42
46
|
function named(name, ...patterns) {
|
|
43
47
|
return group({ name }, ...patterns);
|
|
44
48
|
}
|
|
@@ -49,14 +53,14 @@ function qty(quantity, ...patterns) {
|
|
|
49
53
|
let min;
|
|
50
54
|
let max;
|
|
51
55
|
let greedy = true;
|
|
52
|
-
if (typeof quantity ===
|
|
56
|
+
if (typeof quantity === "number") {
|
|
53
57
|
min = quantity;
|
|
54
58
|
max = quantity;
|
|
55
59
|
}
|
|
56
60
|
else if (Array.isArray(quantity)) {
|
|
57
61
|
[min, max] = quantity;
|
|
58
62
|
}
|
|
59
|
-
else if (
|
|
63
|
+
else if ("exact" in quantity) {
|
|
60
64
|
min = quantity.exact;
|
|
61
65
|
max = quantity.exact;
|
|
62
66
|
greedy = quantity.greedy ?? true;
|
|
@@ -67,36 +71,62 @@ function qty(quantity, ...patterns) {
|
|
|
67
71
|
greedy = quantity.greedy ?? true;
|
|
68
72
|
}
|
|
69
73
|
if (!Number.isInteger(min) || min < 0 || (max !== undefined && max !== Infinity && (!Number.isInteger(max) || max < min))) {
|
|
70
|
-
throw new RangeError(
|
|
74
|
+
throw new RangeError("Quantity bounds must be non-negative integers with max >= min");
|
|
71
75
|
}
|
|
72
|
-
return template((flags, compiling) => `${patternString(group(false, ...patterns), flags, compiling)}{${min}${max === undefined || max === Infinity ?
|
|
76
|
+
return template((flags, compiling) => `${patternString(group(false, ...patterns), flags, compiling)}{${min}${max === undefined || max === Infinity ? "," : max === min ? "" : `,${max}`}}${greedy ? "" : "?"}`);
|
|
73
77
|
}
|
|
74
78
|
function look(prefix, positive, patterns) {
|
|
75
|
-
return template((flags, compiling) => `(${prefix}${positive ?
|
|
79
|
+
return template((flags, compiling) => `(${prefix}${positive ? "=" : "!"}${patterns.map(pattern => patternString(pattern, flags, compiling)).join("")})`);
|
|
76
80
|
}
|
|
77
81
|
function raw(...patterns) {
|
|
78
|
-
return template(() => patterns.map(p => RegExp.escape(p)).join(
|
|
82
|
+
return template(() => patterns.map(p => RegExp.escape(p)).join(""));
|
|
79
83
|
}
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Create a new JavaScript regex designer with its own variable scope.
|
|
86
|
+
* @readme default
|
|
87
|
+
*/
|
|
88
|
+
export default function create() {
|
|
89
|
+
return new JSRegexDesigner();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Templates are compiled to a native `RegExp`.
|
|
93
|
+
*/
|
|
94
|
+
export class JSRegexDesigner extends RegexDesigner {
|
|
95
|
+
createTemplate(render) {
|
|
96
|
+
return template(render);
|
|
97
|
+
}
|
|
84
98
|
/** Concatenate patterns without adding groups or escaping. */
|
|
85
99
|
tpl(...patterns) {
|
|
86
100
|
return tpl(...patterns);
|
|
87
101
|
}
|
|
88
|
-
/**
|
|
89
|
-
|
|
90
|
-
return
|
|
102
|
+
/** Escape literal text for use in a regex pattern. */
|
|
103
|
+
raw(...patterns) {
|
|
104
|
+
return raw(...patterns);
|
|
91
105
|
}
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
return
|
|
106
|
+
/** Match the concatenated patterns at the start of the input. */
|
|
107
|
+
start(...patterns) {
|
|
108
|
+
return anchor(true, false, patterns);
|
|
109
|
+
}
|
|
110
|
+
/** Match the concatenated patterns at the end of the input. */
|
|
111
|
+
end(...patterns) {
|
|
112
|
+
return anchor(false, true, patterns);
|
|
113
|
+
}
|
|
114
|
+
/** Match the concatenated patterns across the whole input. */
|
|
115
|
+
whole(...patterns) {
|
|
116
|
+
return anchor(true, true, patterns);
|
|
95
117
|
}
|
|
96
118
|
/** Group patterns, optionally capturing them or assigning a capture name. */
|
|
97
119
|
group(options, ...patterns) {
|
|
98
120
|
return group(options, ...patterns);
|
|
99
121
|
}
|
|
122
|
+
/** Create a named capturing group around the concatenated patterns. */
|
|
123
|
+
named(name, ...patterns) {
|
|
124
|
+
return named(name, ...patterns);
|
|
125
|
+
}
|
|
126
|
+
/** Create a numeric or named backreference. */
|
|
127
|
+
ref(reference) {
|
|
128
|
+
return template(() => typeof reference === "number" ? `\\${reference}` : `\\k<${reference}>`);
|
|
129
|
+
}
|
|
100
130
|
/** Make the concatenated patterns optional using a non-capturing group. */
|
|
101
131
|
opt(...patterns) {
|
|
102
132
|
return opt(...patterns);
|
|
@@ -105,68 +135,33 @@ export class RegexDesigner {
|
|
|
105
135
|
qty(quantity, ...patterns) {
|
|
106
136
|
return qty(quantity, ...patterns);
|
|
107
137
|
}
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
return
|
|
138
|
+
/** Join patterns with alternation without adding groups. */
|
|
139
|
+
or(...patterns) {
|
|
140
|
+
return or(...patterns);
|
|
111
141
|
}
|
|
112
|
-
/** Create a positive or negative lookahead assertion. */
|
|
142
|
+
/** Create a positive or negative [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion). */
|
|
113
143
|
ahead(positive, ...patterns) {
|
|
114
|
-
return look(
|
|
144
|
+
return look("?", positive, patterns);
|
|
115
145
|
}
|
|
116
|
-
/** Create a positive lookahead assertion. */
|
|
146
|
+
/** Create a positive [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion). */
|
|
117
147
|
ahead_pos(...patterns) {
|
|
118
|
-
return look(
|
|
148
|
+
return look("?", true, patterns);
|
|
119
149
|
}
|
|
120
|
-
/** Create a negative lookahead assertion. */
|
|
150
|
+
/** Create a negative [lookahead assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookahead_assertion). */
|
|
121
151
|
ahead_neg(...patterns) {
|
|
122
|
-
return look(
|
|
152
|
+
return look("?", false, patterns);
|
|
123
153
|
}
|
|
124
|
-
/** Create a positive or negative lookbehind assertion. */
|
|
154
|
+
/** Create a positive or negative [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). */
|
|
125
155
|
behind(positive, ...patterns) {
|
|
126
|
-
return look(
|
|
156
|
+
return look("?<", positive, patterns);
|
|
127
157
|
}
|
|
128
|
-
/** Create a positive lookbehind assertion. */
|
|
158
|
+
/** Create a positive [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). */
|
|
129
159
|
behind_pos(...patterns) {
|
|
130
|
-
return look(
|
|
160
|
+
return look("?<", true, patterns);
|
|
131
161
|
}
|
|
132
|
-
/** Create a negative lookbehind assertion. */
|
|
162
|
+
/** Create a negative [lookbehind assertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion). */
|
|
133
163
|
behind_neg(...patterns) {
|
|
134
|
-
return look(
|
|
164
|
+
return look("?<", false, patterns);
|
|
135
165
|
}
|
|
136
|
-
/** Create a numeric or named backreference. */
|
|
137
|
-
ref(reference) {
|
|
138
|
-
return template(() => typeof reference === 'number' ? `\\${reference}` : `\\k<${reference}>`);
|
|
139
|
-
}
|
|
140
|
-
/** Define or replace a lazy pattern variable on this designer. */
|
|
141
|
-
set(name, ...patterns) {
|
|
142
|
-
this.variables.set(name, tpl(...patterns));
|
|
143
|
-
return this;
|
|
144
|
-
}
|
|
145
|
-
resolveVariable(name, flags, compiling) {
|
|
146
|
-
const cycleStart = this.resolvingVariables.indexOf(name);
|
|
147
|
-
if (cycleStart !== -1) {
|
|
148
|
-
const cycle = [...this.resolvingVariables.slice(cycleStart), name];
|
|
149
|
-
throw new Error(`Circular variable dependency: ${cycle.join(' -> ')}`);
|
|
150
|
-
}
|
|
151
|
-
const pattern = this.variables.get(name);
|
|
152
|
-
if (pattern === undefined) {
|
|
153
|
-
throw new Error(`Variable "${name}" is not set`);
|
|
154
|
-
}
|
|
155
|
-
this.resolvingVariables.push(name);
|
|
156
|
-
try {
|
|
157
|
-
return patternString(pattern, flags, compiling);
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
this.resolvingVariables.pop();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
/** Reference a variable, resolving it when this template is rendered. */
|
|
164
|
-
var(name) {
|
|
165
|
-
return template((flags, compiling) => this.resolveVariable(name, flags, compiling));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/** Create a new regex designer with its own variable scope. */
|
|
169
|
-
export default function create() {
|
|
170
|
-
return new RegexDesigner();
|
|
171
166
|
}
|
|
172
167
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EACL,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAY9B,OAAO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,SAAS,CAAC,GAAG,QAAsB;QAC1C,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,0JAA0J;IACjJ,SAAS,CAAC,GAAG,QAAsB;QAC1C,OAAO,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,wKAAwK;IAC/J,MAAM,CAAC,QAAiB,EAAE,GAAG,QAAsB;QAC1D,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,4JAA4J;IACnJ,UAAU,CAAC,GAAG,QAAsB;QAC3C,OAAO,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,4JAA4J;IACnJ,UAAU,CAAC,GAAG,QAAsB;QAC3C,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;CAEF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regex-designer/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A small TypeScript library for composing JavaScript regular expressions in a readable, reusable way.",
|
|
5
|
-
"private": false,
|
|
6
5
|
"type": "module",
|
|
7
6
|
"license": "MIT",
|
|
8
7
|
"keywords": [
|
|
@@ -15,8 +14,7 @@
|
|
|
15
14
|
"node": ">=24.0.0"
|
|
16
15
|
},
|
|
17
16
|
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
"LICENSE"
|
|
17
|
+
"dist"
|
|
20
18
|
],
|
|
21
19
|
"types": "./dist/index.d.ts",
|
|
22
20
|
"exports": {
|
|
@@ -26,19 +24,13 @@
|
|
|
26
24
|
}
|
|
27
25
|
},
|
|
28
26
|
"sideEffects": false,
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@regex-designer/core": "0.2.0"
|
|
29
|
+
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "tsc -p tsconfig.json",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"test": "npm run typecheck && node --test test/*.test.ts",
|
|
32
|
+
"lint": "eslint --config ../../eslint.config.* .",
|
|
33
|
+
"test": "npm run build && tsc -p tsconfig.test.json && node --test test/*.test.ts",
|
|
34
34
|
"check": "npm run lint && npm run test"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@eslint/js": "10.0.1",
|
|
38
|
-
"@types/node": "24.19.2",
|
|
39
|
-
"eslint": "10.12.0",
|
|
40
|
-
"globals": "17.13.0",
|
|
41
|
-
"typescript": "6.0.3",
|
|
42
|
-
"typescript-eslint": "8.71.1"
|
|
43
35
|
}
|
|
44
36
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 loganmzz
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|