Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private fracParseCJK(extResult: ExtractResult): ParseResult {
let result = new ParseResult(extResult);
let resultText = extResult.text;
let splitResult = RegExpUtility.split(this.config.fracSplitRegex, resultText);
let intPart = "";
let demoPart = "";
let numPart = "";
if (splitResult.length === 3) {
intPart = splitResult[0] || "";
demoPart = splitResult[1] || "";
numPart = splitResult[2] || "";
}
else {
intPart = this.config.zeroChar;
demoPart = splitResult[0] || "";
numPart = splitResult[1] || "";
}
let intValue = this.isDigitCJK(intPart)
? this.getDigitValueCJK(intPart, 1.0)
private douParseCJK(extResult: ExtractResult): ParseResult {
let result = new ParseResult(extResult);
let resultText = extResult.text;
if (RegExpUtility.isMatch(this.config.doubleAndRoundRegex, resultText)) {
resultText = this.replaceUnit(resultText);
let power = this.config.roundNumberMapChar.get(resultText.charAt(resultText.length - 1));
result.value = this.getDigitValueCJK(resultText.substr(0, resultText.length - 1), power);
}
else {
resultText = this.replaceUnit(resultText);
let splitResult = RegExpUtility.split(this.config.pointRegex, resultText);
if (splitResult[0] === "") {
splitResult[0] = this.config.zeroChar;
}
if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, splitResult[0])) {
result.value = this.getIntValueCJK(splitResult[0]) - this.getPointValueCJK(splitResult[1]);
}
else {
result.value = this.getIntValueCJK(splitResult[0]) + this.getPointValueCJK(splitResult[1]);
}
}
result.resolutionStr = this.toString(result.value);
return result;
}
if (doubleText.includes("G") || doubleText.includes("G")) {
power = 1000000000;
}
if (doubleText.includes("T") || doubleText.includes("T")) {
power = 1000000000000;
}
result.value = this.getDigitValueCJK(resultText, power);
}
else {
let doubleMatch = RegExpUtility.getMatches(this.config.percentageRegex, resultText).pop();
let doubleText = this.replaceUnit(doubleMatch.value);
let splitResult = RegExpUtility.split(this.config.pointRegex, doubleText);
if (splitResult[0] === "") {
splitResult[0] = this.config.zeroChar;
}
let doubleValue = this.getIntValueCJK(splitResult[0]);
if (splitResult.length === 2) {
if (RegExpUtility.isMatch(this.config.negativeNumberSignRegex, splitResult[0])) {
doubleValue -= this.getPointValueCJK(splitResult[1]);
}
else {
doubleValue += this.getPointValueCJK(splitResult[1]);
}
}
result.value = doubleValue;
}