Skip to content

Commit a8a7af2

Browse files
committed
chore: convert to set
1 parent ca39e0d commit a8a7af2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,19 +352,19 @@ function buildInnerObject (context, location) {
352352
const requiredProperties = schema.required || []
353353

354354
// Should serialize required properties first
355-
const propertiesKeys = Object.keys(schema.properties || {}).sort(
355+
const propertiesKeys = new Set(Object.keys(schema.properties || {}).sort(
356356
(key1, key2) => {
357357
const required1 = requiredProperties.includes(key1)
358358
const required2 = requiredProperties.includes(key2)
359359
return required1 === required2 ? 0 : required1 ? -1 : 1
360360
}
361-
)
361+
))
362362
const hasRequiredProperties = requiredProperties.includes(propertiesKeys[0])
363363

364364
let code = 'let value\n'
365365

366366
for (const key of requiredProperties) {
367-
if (!propertiesKeys.includes(key)) {
367+
if (!propertiesKeys.has(key)) {
368368
const sanitizedKey = JSON.stringify(key)
369369
code += `if (obj[${sanitizedKey}] === undefined) throw new Error('${sanitizedKey.replace(/'/g, '\\\'')} is required!')\n`
370370
}
@@ -846,7 +846,7 @@ function buildAllOf (context, location, input) {
846846
]
847847

848848
const allOfsLocation = location.getPropertyLocation('allOf')
849-
for (let i = 0, allOfsLength = allOfsLocation.length; i < allOfsLength; i++) {
849+
for (let i = 0, allOfLength = allOf.length; i < allOfLength; i++) {
850850
locations.push(allOfsLocation.getPropertyLocation(i))
851851
}
852852

0 commit comments

Comments
 (0)