remove console.log

This commit is contained in:
chungyau97
2023-06-05 21:59:42 +07:00
parent ae3387ceda
commit f7dd021b38
-11
View File
@@ -237,12 +237,9 @@ export class CustomChainHandler extends BaseCallbackHandler {
export const returnJSONStr = (jsonStr: string): string => { export const returnJSONStr = (jsonStr: string): string => {
let jsonStrArray = jsonStr.split(':') let jsonStrArray = jsonStr.split(':')
// jsonStrArray = jsonStrArray.split('"')
console.log(`jsonStrArray: ${JSON.stringify(jsonStrArray)} length: ${jsonStrArray.length}`)
let wholeString = '' let wholeString = ''
for (let i = 0; i < jsonStrArray.length; i++) { for (let i = 0; i < jsonStrArray.length; i++) {
// console.log(`element: ${jsonStrArray[i]}`)
if (jsonStrArray[i].includes(',') && jsonStrArray[i + 1] !== undefined) { if (jsonStrArray[i].includes(',') && jsonStrArray[i + 1] !== undefined) {
const splitValueAndTitle = jsonStrArray[i].split(',') const splitValueAndTitle = jsonStrArray[i].split(',')
const value = splitValueAndTitle[0] const value = splitValueAndTitle[0]
@@ -252,12 +249,10 @@ export const returnJSONStr = (jsonStr: string): string => {
wholeString += wholeString === '' ? jsonStrArray[i] + ':' : handleEscapeDoubleQuote(jsonStrArray[i]) wholeString += wholeString === '' ? jsonStrArray[i] + ':' : handleEscapeDoubleQuote(jsonStrArray[i])
} }
} }
console.log(`wholeString: ${wholeString}`)
return wholeString return wholeString
} }
const handleEscapeDoubleQuote = (value: string): string => { const handleEscapeDoubleQuote = (value: string): string => {
console.log(`value: ${value}`)
let newValue = '' let newValue = ''
if (value.includes('"')) { if (value.includes('"')) {
const valueArray = value.split('"') const valueArray = value.split('"')
@@ -265,23 +260,17 @@ const handleEscapeDoubleQuote = (value: string): string => {
if ((i + 1) % 2 !== 0) { if ((i + 1) % 2 !== 0) {
switch (valueArray[i]) { switch (valueArray[i]) {
case '': case '':
console.log(`nothing`)
newValue += '"' newValue += '"'
break break
case '}': case '}':
console.log(`}`)
newValue += '"}' newValue += '"}'
break break
default: default:
console.log(`default`)
newValue += '\\"' + valueArray[i] + '\\"' newValue += '\\"' + valueArray[i] + '\\"'
} }
} else { } else {
newValue += valueArray[i] newValue += valueArray[i]
} }
console.log(`valueArray[i]: ${valueArray[i]}`)
console.log(`newValue: ${newValue}`)
} }
} }
return newValue === '' ? value : newValue return newValue === '' ? value : newValue