diff --git a/index.js b/index.js index f26ee30b..379f2a98 100644 --- a/index.js +++ b/index.js @@ -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} @@ -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 @@ -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 } }