Skip to content

Commit c59845a

Browse files
blueloversmysticatea
authored andcommitted
Update: parseRegExpLiteral supports RegExp object
Fixes #1 Fixes #2
1 parent bec224b commit c59845a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export { AST, RegExpParser, RegExpValidator }
1212
* @returns The AST of the regular expression.
1313
*/
1414
export function parseRegExpLiteral(
15-
source: string,
15+
source: string | RegExp,
1616
options?: RegExpParser.Options,
1717
): AST.RegExpLiteral {
18-
return new RegExpParser(options).parseLiteral(source)
18+
return new RegExpParser(options).parseLiteral(source instanceof RegExp ? String(source) : source)
1919
}
2020

2121
/**

0 commit comments

Comments
 (0)