File tree 7 files changed +23
-19
lines changed
7 files changed +23
-19
lines changed Original file line number Diff line number Diff line change 1
1
import type { EncodeOutput } from '../encoder/types' ;
2
- import type { RegexEncodable } from '../types' ;
2
+ import type { RegexComponentResult } from '../types' ;
3
3
4
- export interface Anchor extends RegexEncodable {
4
+ export interface Anchor extends RegexComponentResult {
5
5
type : 'anchor' ;
6
6
symbol : string ;
7
7
}
Original file line number Diff line number Diff line change 1
1
import { encodeSequence } from '../encoder/encoder' ;
2
2
import type { EncodeOutput } from '../encoder/types' ;
3
3
import { asNodeArray } from '../utils/nodes' ;
4
- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4
+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
5
5
6
- export interface Capture extends RegexEncodable {
6
+ export interface Capture extends RegexComponentResult {
7
7
type : 'capture' ;
8
8
children : RegexElement [ ] ;
9
9
}
Original file line number Diff line number Diff line change 1
1
import { encodeSequence } from '../encoder/encoder' ;
2
2
import type { EncodeOutput } from '../encoder/types' ;
3
3
import { asNodeArray } from '../utils/nodes' ;
4
- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4
+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
5
5
6
- export interface ChoiceOf extends RegexEncodable {
6
+ export interface ChoiceOf extends RegexComponentResult {
7
7
type : 'choiceOf' ;
8
8
alternatives : RegexElement [ ] [ ] ;
9
9
}
Original file line number Diff line number Diff line change 1
1
import { encodeAtom } from '../encoder/encoder' ;
2
2
import type { EncodeOutput } from '../encoder/types' ;
3
3
import { asNodeArray } from '../utils/nodes' ;
4
- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4
+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
5
5
6
- export interface OneOrMore extends RegexEncodable {
6
+ export interface OneOrMore extends RegexComponentResult {
7
7
type : 'oneOrMore' ;
8
8
children : RegexElement [ ] ;
9
9
}
10
10
11
- export interface Optionally extends RegexEncodable {
11
+ export interface Optionally extends RegexComponentResult {
12
12
type : 'optionally' ;
13
13
children : RegexElement [ ] ;
14
14
}
15
15
16
- export interface ZeroOrMore extends RegexEncodable {
16
+ export interface ZeroOrMore extends RegexComponentResult {
17
17
type : 'zeroOrMore' ;
18
18
children : RegexElement [ ] ;
19
19
}
Original file line number Diff line number Diff line change 1
1
import { encodeAtom } from '../encoder/encoder' ;
2
2
import type { EncodeOutput } from '../encoder/types' ;
3
3
import { asNodeArray } from '../utils/nodes' ;
4
- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4
+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
5
5
6
- export interface Repeat extends RegexEncodable {
6
+ export interface Repeat extends RegexComponentResult {
7
7
type : 'repeat' ;
8
8
options : RepeatOptions ;
9
9
children : RegexElement [ ] ;
Original file line number Diff line number Diff line change 1
1
import type { EncodeOutput } from './encoder/types' ;
2
2
3
3
/**
4
- * Sequence of `RegexElements` that can be encoded into a regular expression.
4
+ * Sequence of regex elements that can be encoded into a regular expression.
5
+ *
6
+ * Typically passed as an array of elements but can be a single element to
7
+ * improve readability.
5
8
*/
6
9
export type RegexSequence = RegexElement [ ] | RegexElement ;
7
10
8
11
/**
9
- * Represents a result of calling a regex component (`RegexEncodable`) or a string to be matched literally.
12
+ * Represents a result of calling a regex component or a string to be matched
13
+ * literally.
10
14
*/
11
- export type RegexElement = RegexEncodable | string ;
15
+ export type RegexElement = RegexComponentResult | string ;
12
16
13
17
/**
14
18
* Represents result of calling a regex componen.
15
19
*/
16
- export interface RegexEncodable {
20
+ export interface RegexComponentResult {
17
21
type : string ;
18
22
encode ( ) : EncodeOutput ;
19
23
}
Original file line number Diff line number Diff line change 1
1
import { buildRegex } from '../src/builders' ;
2
- import type { RegexElement , RegexEncodable } from '../src/types' ;
2
+ import type { RegexComponentResult , RegexElement } from '../src/types' ;
3
3
4
4
export function isRegexElement ( node : unknown ) : node is RegexElement {
5
- return typeof node === 'string' || isRegexEncodable ( node ) ;
5
+ return typeof node === 'string' || isRegexComponentResult ( node ) ;
6
6
}
7
7
8
- export function isRegexEncodable ( element : unknown ) : element is RegexEncodable {
8
+ export function isRegexComponentResult ( element : unknown ) : element is RegexComponentResult {
9
9
return (
10
10
typeof element === 'object' &&
11
11
element !== null &&
You can’t perform that action at this time.
0 commit comments