Skip to content

Commit

Permalink
jsonOutput is useless
Browse files Browse the repository at this point in the history
Signed-off-by: francesco <[email protected]>
  • Loading branch information
cesco69 authored Apr 19, 2024
1 parent 686e6ce commit 431a8e4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ function buildArray (context, location) {

functionCode += `
let value
let jsonOutput = ''
let json = ''
`

if (Array.isArray(itemsSchema)) {
Expand All @@ -556,11 +556,9 @@ function buildArray (context, location) {
functionCode += `
if (${i} < arrayLength) {
if (${buildArrayTypeCondition(item.type, `[${i}]`)}) {
let json = ''
${tmpRes}
jsonOutput += json
if (${i} < arrayLength - 1) {
jsonOutput += ','
json += ','
}
} else {
throw new Error(\`Item at ${i} does not match schema definition.\`)
Expand All @@ -572,27 +570,25 @@ function buildArray (context, location) {
if (schema.additionalItems) {
functionCode += `
for (let i = ${itemsSchema.length}; i < arrayLength; i++) {
jsonOutput += JSON.stringify(obj[i])
json += JSON.stringify(obj[i])
if (i < arrayLength - 1) {
jsonOutput += ','
json += ','
}
}`
}
} else {
const code = buildValue(context, itemsLocation, 'obj[i]')
functionCode += `
for (let i = 0; i < arrayLength; i++) {
let json = ''
${code}
jsonOutput += json
if (i < arrayLength - 1) {
jsonOutput += ','
json += ','
}
}`
}

functionCode += `
return \`[\${jsonOutput}]\`
return \`[\${json}]\`
}`

context.functions.push(functionCode)
Expand Down

0 comments on commit 431a8e4

Please sign in to comment.