Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ function buildCode (location) {
schema.properties[key] = propertyLocation.schema
}

// Using obj['key'] !== undefined instead of obj.hasOwnProperty(prop) for perf reasons,
// see https://github.com/mcollina/fast-json-stringify/pull/3 for discussion.

const sanitized = JSON.stringify(key)
const asString = JSON.stringify(sanitized)

// Using obj['key'] !== undefined instead of obj.hasOwnProperty(prop) for perf reasons,
// see https://github.com/mcollina/fast-json-stringify/pull/3 for discussion.

code += `
if (obj[${sanitized}] !== undefined) {
${addComma}
Expand Down Expand Up @@ -901,7 +901,7 @@ function buildValue (location, input) {
switch (type) {
case 'string': {
code += `
${statement}(${input} === null || typeof ${input} === "${type}" || ${input} instanceof RegExp || (typeof ${input} === "object" && Object.hasOwnProperty.call(${input}, "toString")))
${statement}(${input} === null || typeof ${input} === "${type}" || ${input} instanceof RegExp || (typeof ${input} === "object" && Object.prototype.hasOwnProperty.call(${input}, "toString")))
${nestedResult}
`
break
Expand Down Expand Up @@ -987,7 +987,7 @@ function extendDateTimeType (schema) {
function isEmpty (schema) {
// eslint-disable-next-line
for (var key in schema) {
if (schema.hasOwnProperty(key) && schema[key] !== undefined) {
if (Object.prototype.hasOwnProperty.call(schema, key) && schema[key] !== undefined) {
return false
}
}
Expand Down