Skip to content

Commit 689b462

Browse files
committed
feat(src): export createRegExp function
1 parent 2795bc2 commit 689b462

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/regexp-string-matcher.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export interface matchPatternResult {
2222
endIndex: number;
2323
}
2424

25-
const createRegExp = (patternString: string): RegExp => {
25+
export const createRegExp = (patternString: string, defaultFlag: string = DEFAULT_FLAGS): RegExp => {
2626
if (patternString.length === 0) {
27-
throw new Error("Empty string can not includes");
27+
throw new Error("Empty string can not handled");
2828
}
2929
if (isRegExpString(patternString)) {
3030
const regExpStructure = parseRegExpString(patternString);
@@ -36,7 +36,7 @@ const createRegExp = (patternString: string): RegExp => {
3636
}
3737
throw new Error(`"${patternString}" can not parse as RegExp.`);
3838
} else {
39-
return new RegExp(escapeStringRegexp(patternString), DEFAULT_FLAGS);
39+
return new RegExp(escapeStringRegexp(patternString), defaultFlag);
4040
}
4141
};
4242

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"target": "es5",
99
"sourceMap": true,
1010
"declaration": true,
11+
"esModuleInterop": true,
1112
"jsx": "preserve",
1213
"lib": [
1314
"es2017",
@@ -32,4 +33,4 @@
3233
".git",
3334
"node_modules"
3435
]
35-
}
36+
}

0 commit comments

Comments
 (0)