Skip to content

Commit c966c6c

Browse files
refactor: remove unused isArray buildValue argument (#449)
1 parent 1c120dd commit c966c6c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function build (schema, options) {
303303
schema.type = inferTypeByKeyword(schema)
304304
}
305305

306-
const { code, laterCode } = buildValue('', 'main', 'input', location, false)
306+
const { code, laterCode } = buildValue('', 'main', 'input', location)
307307
const contextFunctionCode = `
308308
'use strict'
309309
function main (input) {
@@ -738,7 +738,7 @@ function buildCode (location, code, laterCode, locationPath) {
738738
json += ${asString} + ':'
739739
`
740740

741-
const result = buildValue(laterCode, locationPath + key, `obj[${JSON.stringify(key)}]`, mergeLocation(propertyLocation, { schema: schema.properties[key] }), false)
741+
const result = buildValue(laterCode, locationPath + key, `obj[${JSON.stringify(key)}]`, mergeLocation(propertyLocation, { schema: schema.properties[key] }))
742742
code += result.code
743743
laterCode = result.laterCode
744744

@@ -970,7 +970,7 @@ function buildArray (location, code, functionName, locationPath, isObjectPropert
970970
const accessor = '[i]'
971971
if (Array.isArray(schema.items)) {
972972
result = schema.items.reduce((res, item, i) => {
973-
const tmpRes = buildValue(laterCode, locationPath + accessor + i, 'obj[i]', mergeLocation(location, { schema: item }), true)
973+
const tmpRes = buildValue(laterCode, locationPath + accessor + i, 'obj[i]', mergeLocation(location, { schema: item }))
974974
const condition = `i === ${i} && ${buildArrayTypeCondition(item.type, accessor)}`
975975
return {
976976
code: `${res.code}
@@ -983,7 +983,7 @@ function buildArray (location, code, functionName, locationPath, isObjectPropert
983983
}, result)
984984

985985
if (schema.additionalItems) {
986-
const tmpRes = buildValue(laterCode, locationPath + accessor, 'obj[i]', mergeLocation(location, { schema: schema.items }), true)
986+
const tmpRes = buildValue(laterCode, locationPath + accessor, 'obj[i]', mergeLocation(location, { schema: schema.items }))
987987
result.code += `
988988
else if (i >= ${schema.items.length}) {
989989
${tmpRes.code}
@@ -997,7 +997,7 @@ function buildArray (location, code, functionName, locationPath, isObjectPropert
997997
}
998998
`
999999
} else {
1000-
result = buildValue(laterCode, locationPath + accessor, 'obj[i]', mergeLocation(location, { schema: schema.items }), true)
1000+
result = buildValue(laterCode, locationPath + accessor, 'obj[i]', mergeLocation(location, { schema: schema.items }))
10011001
}
10021002

10031003
if (isObjectProperty) {
@@ -1104,7 +1104,7 @@ function generateFuncName () {
11041104
return 'anonymous' + genFuncNameCounter++
11051105
}
11061106

1107-
function buildValue (laterCode, locationPath, input, location, isArray) {
1107+
function buildValue (laterCode, locationPath, input, location) {
11081108
let schema = location.schema
11091109

11101110
if (schema.$ref) {
@@ -1162,7 +1162,7 @@ function buildValue (laterCode, locationPath, input, location, isArray) {
11621162
// beware: dereferenceOfRefs has side effects and changes schema.anyOf
11631163
const locations = dereferenceOfRefs(location, schema.anyOf ? 'anyOf' : 'oneOf')
11641164
locations.forEach((location, index) => {
1165-
const nestedResult = buildValue(laterCode, locationPath + 'i' + index, input, location, isArray)
1165+
const nestedResult = buildValue(laterCode, locationPath + 'i' + index, input, location)
11661166
// Since we are only passing the relevant schema to ajv.validate, it needs to be full dereferenced
11671167
// otherwise any $ref pointing to an external schema would result in an error.
11681168
// Full dereference of the schema happens as side effect of two functions:
@@ -1216,7 +1216,7 @@ function buildValue (laterCode, locationPath, input, location, isArray) {
12161216
sortedTypes.forEach((type, index) => {
12171217
const statement = index === 0 ? 'if' : 'else if'
12181218
const tempSchema = Object.assign({}, schema, { type })
1219-
const nestedResult = buildValue(laterCode, locationPath, input, mergeLocation(location, { schema: tempSchema }), isArray)
1219+
const nestedResult = buildValue(laterCode, locationPath, input, mergeLocation(location, { schema: tempSchema }))
12201220
switch (type) {
12211221
case 'string': {
12221222
code += `

0 commit comments

Comments
 (0)