Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let year = -1;
let er: ExtractResult;
if (isChinese) {
let yearNum = 0;
er = this.integerExtractor.extract(yearStr).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
yearNum = Number.parseInt(this.numberParser.parse(er).value);
}
if (yearNum < 10) {
yearNum = 0;
for (let index = 0; index < yearStr.length; index++) {
let char = yearStr.charAt(index);
yearNum *= 10;
er = this.integerExtractor.extract(char).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
yearNum += Number.parseInt(this.numberParser.parse(er).value);
}
}
year = yearNum;
}
else {
year = yearNum;
}
}
else {
year = Number.parseInt(yearStr, 10);
}
return year === 0 ? -1 : year;
}
private convertChineseToNumber(source: string): number {
let num = -1;
let er = this.integerExtractor.extract(source).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
num = Number.parseInt(this.numberParser.parse(er).value);
}
return num;
}
private convertYear(yearStr: string, isChinese: boolean): number {
let year = -1;
let er: ExtractResult;
if (isChinese) {
let yearNum = 0;
er = this.integerExtractor.extract(yearStr).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
yearNum = Number.parseInt(this.numberParser.parse(er).value);
}
if (yearNum < 10) {
yearNum = 0;
for (let index = 0; index < yearStr.length; index++) {
let char = yearStr.charAt[index];
yearNum *= 10;
er = this.integerExtractor.extract(char).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
yearNum += Number.parseInt(this.numberParser.parse(er).value);
}
}
}
else {
year = yearNum;
private parseChineseWrittenNumberToValue(source: string): number {
let num = -1;
let er = this.integerExtractor.extract(source);
if (er && er[0].type === NumberConstants.SYS_NUM_INTEGER) {
num = Number.parseInt(this.config.numberParser.parse(er[0]).value);
}
return num;
}
}
private convertChineseYearToNumber(source: string): number {
let year = 0;
let er = this.config.integerExtractor.extract(source).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
year = Number.parseInt(this.config.numberParser.parse(er).value);
}
if (year < 10) {
year = 0;
for (let i = 0; i < source.length; i++) {
let char = source.charAt(i);
year *= 10;
let er = this.config.integerExtractor.extract(char).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
year += Number.parseInt(this.config.numberParser.parse(er).value);
}
}
}
return year < 10 ? -1 : year;
}
private convertChineseYearToNumber(source: string): number {
let year = 0;
let er = this.config.integerExtractor.extract(source).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
year = Number.parseInt(this.config.numberParser.parse(er).value);
}
if (year < 10) {
year = 0;
for (let i = 0; i < source.length; i++) {
let char = source.charAt(i);
year *= 10;
let er = this.config.integerExtractor.extract(char).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
year += Number.parseInt(this.config.numberParser.parse(er).value);
}
}
}
return year < 10 ? -1 : year;
}
let year = -1;
let er: ExtractResult;
if (isChinese) {
let yearNum = 0;
er = this.integerExtractor.extract(yearStr).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
yearNum = Number.parseInt(this.numberParser.parse(er).value);
}
if (yearNum < 10) {
yearNum = 0;
for (let index = 0; index < yearStr.length; index++) {
let char = yearStr.charAt[index];
yearNum *= 10;
er = this.integerExtractor.extract(char).pop();
if (er && er.type === NumberConstants.SYS_NUM_INTEGER) {
yearNum += Number.parseInt(this.numberParser.parse(er).value);
}
}
}
else {
year = yearNum;
}
}
else {
year = Number.parseInt(yearStr, 10);
}
return year === 0 ? -1 : year;
}