File tree Expand file tree Collapse file tree 7 files changed +23
-19
lines changed Expand file tree Collapse file tree 7 files changed +23
-19
lines changed Original file line number Diff line number Diff line change 11import type { EncodeOutput } from '../encoder/types' ;
2- import type { RegexEncodable } from '../types' ;
2+ import type { RegexComponentResult } from '../types' ;
33
4- export interface Anchor extends RegexEncodable {
4+ export interface Anchor extends RegexComponentResult {
55 type : 'anchor' ;
66 symbol : string ;
77}
Original file line number Diff line number Diff line change 11import { encodeSequence } from '../encoder/encoder' ;
22import type { EncodeOutput } from '../encoder/types' ;
33import { asNodeArray } from '../utils/nodes' ;
4- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
55
6- export interface Capture extends RegexEncodable {
6+ export interface Capture extends RegexComponentResult {
77 type : 'capture' ;
88 children : RegexElement [ ] ;
99}
Original file line number Diff line number Diff line change 11import { encodeSequence } from '../encoder/encoder' ;
22import type { EncodeOutput } from '../encoder/types' ;
33import { asNodeArray } from '../utils/nodes' ;
4- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
55
6- export interface ChoiceOf extends RegexEncodable {
6+ export interface ChoiceOf extends RegexComponentResult {
77 type : 'choiceOf' ;
88 alternatives : RegexElement [ ] [ ] ;
99}
Original file line number Diff line number Diff line change 11import { encodeAtom } from '../encoder/encoder' ;
22import type { EncodeOutput } from '../encoder/types' ;
33import { asNodeArray } from '../utils/nodes' ;
4- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
55
6- export interface OneOrMore extends RegexEncodable {
6+ export interface OneOrMore extends RegexComponentResult {
77 type : 'oneOrMore' ;
88 children : RegexElement [ ] ;
99}
1010
11- export interface Optionally extends RegexEncodable {
11+ export interface Optionally extends RegexComponentResult {
1212 type : 'optionally' ;
1313 children : RegexElement [ ] ;
1414}
1515
16- export interface ZeroOrMore extends RegexEncodable {
16+ export interface ZeroOrMore extends RegexComponentResult {
1717 type : 'zeroOrMore' ;
1818 children : RegexElement [ ] ;
1919}
Original file line number Diff line number Diff line change 11import { encodeAtom } from '../encoder/encoder' ;
22import type { EncodeOutput } from '../encoder/types' ;
33import { asNodeArray } from '../utils/nodes' ;
4- import type { RegexElement , RegexEncodable , RegexSequence } from '../types' ;
4+ import type { RegexComponentResult , RegexElement , RegexSequence } from '../types' ;
55
6- export interface Repeat extends RegexEncodable {
6+ export interface Repeat extends RegexComponentResult {
77 type : 'repeat' ;
88 options : RepeatOptions ;
99 children : RegexElement [ ] ;
Original file line number Diff line number Diff line change 11import type { EncodeOutput } from './encoder/types' ;
22
33/**
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.
58 */
69export type RegexSequence = RegexElement [ ] | RegexElement ;
710
811/**
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.
1014 */
11- export type RegexElement = RegexEncodable | string ;
15+ export type RegexElement = RegexComponentResult | string ;
1216
1317/**
1418 * Represents result of calling a regex componen.
1519 */
16- export interface RegexEncodable {
20+ export interface RegexComponentResult {
1721 type : string ;
1822 encode ( ) : EncodeOutput ;
1923}
Original file line number Diff line number Diff line change 11import { buildRegex } from '../src/builders' ;
2- import type { RegexElement , RegexEncodable } from '../src/types' ;
2+ import type { RegexComponentResult , RegexElement } from '../src/types' ;
33
44export function isRegexElement ( node : unknown ) : node is RegexElement {
5- return typeof node === 'string' || isRegexEncodable ( node ) ;
5+ return typeof node === 'string' || isRegexComponentResult ( node ) ;
66}
77
8- export function isRegexEncodable ( element : unknown ) : element is RegexEncodable {
8+ export function isRegexComponentResult ( element : unknown ) : element is RegexComponentResult {
99 return (
1010 typeof element === 'object' &&
1111 element !== null &&
You can’t perform that action at this time.
0 commit comments