Skip to content

Commit cd586bf

Browse files
authored
use hasOwnProperty from prototype (#510)
1 parent f8bdac3 commit cd586bf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,12 @@ function buildCode (location) {
346346
schema.properties[key] = propertyLocation.schema
347347
}
348348

349-
// Using obj['key'] !== undefined instead of obj.hasOwnProperty(prop) for perf reasons,
350-
// see https://github.com/mcollina/fast-json-stringify/pull/3 for discussion.
351-
352349
const sanitized = JSON.stringify(key)
353350
const asString = JSON.stringify(sanitized)
354351

352+
// Using obj['key'] !== undefined instead of obj.hasOwnProperty(prop) for perf reasons,
353+
// see https://github.com/mcollina/fast-json-stringify/pull/3 for discussion.
354+
355355
code += `
356356
if (obj[${sanitized}] !== undefined) {
357357
${addComma}
@@ -901,7 +901,7 @@ function buildValue (location, input) {
901901
switch (type) {
902902
case 'string': {
903903
code += `
904-
${statement}(${input} === null || typeof ${input} === "${type}" || ${input} instanceof RegExp || (typeof ${input} === "object" && Object.hasOwnProperty.call(${input}, "toString")))
904+
${statement}(${input} === null || typeof ${input} === "${type}" || ${input} instanceof RegExp || (typeof ${input} === "object" && Object.prototype.hasOwnProperty.call(${input}, "toString")))
905905
${nestedResult}
906906
`
907907
break
@@ -987,7 +987,7 @@ function extendDateTimeType (schema) {
987987
function isEmpty (schema) {
988988
// eslint-disable-next-line
989989
for (var key in schema) {
990-
if (schema.hasOwnProperty(key) && schema[key] !== undefined) {
990+
if (Object.prototype.hasOwnProperty.call(schema, key) && schema[key] !== undefined) {
991991
return false
992992
}
993993
}

0 commit comments

Comments
 (0)