Skip to content

Commit cb0bdd4

Browse files
author
Wanasit Tanakitrungruang
committedNov 19, 2023
Fix: RUTimeUnitWithinFormatParser to lazy loading
1 parent 96dcd11 commit cb0bdd4

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed
 

‎src/locales/ru/parsers/RUTimeUnitWithinFormatParser.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@ import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/
66
const PATTERN = `(?:(?:около|примерно)\\s*(?:~\\s*)?)?(${TIME_UNITS_PATTERN})${REGEX_PARTS.rightBoundary}`;
77

88
export default class RUTimeUnitWithinFormatParser extends AbstractParserWithWordBoundaryChecking {
9-
private readonly patternWithPrefix: RegExp;
10-
private readonly patternWithoutPrefix: RegExp;
11-
12-
constructor() {
13-
super();
14-
this.patternWithPrefix = new RegExp(`(?:в течение|в течении)\\s*${PATTERN}`, REGEX_PARTS.flags);
15-
this.patternWithoutPrefix = new RegExp(PATTERN, REGEX_PARTS.flags);
16-
}
17-
189
patternLeftBoundary(): string {
1910
return REGEX_PARTS.leftBoundary;
2011
}
2112

2213
innerPattern(context: ParsingContext): RegExp {
23-
return context.option.forwardDate ? this.patternWithoutPrefix : this.patternWithPrefix;
14+
return context.option.forwardDate
15+
? new RegExp(PATTERN, REGEX_PARTS.flags)
16+
: new RegExp(`(?:в течение|в течении)\\s*${PATTERN}`, REGEX_PARTS.flags);
2417
}
2518

2619
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents {

0 commit comments

Comments
 (0)
Please sign in to comment.