Skip to content

Commit 7013932

Browse files
committed
Use reduce() to build flags string
1 parent 155290b commit 7013932

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/regex-builder.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ export default class RegexBuilder {
3737
.forEach(str => this.#flags.add(str));
3838
}
3939

40-
let flagsStr = "";
41-
this.#flags.forEach(flagStr => flagsStr += flagStr);
42-
const regex = new RegExp(this.#regexString, flagsStr);
40+
const flagsString = [...this.#flags].reduce((flags, flag) => flags + flag, "");
41+
const regex = new RegExp(this.#regexString, flagsString);
4342
this.#regexString = "";
4443
this.#flags.clear();
4544
return regex;

0 commit comments

Comments
 (0)