Comparing version 6.0.4 to 6.1.1
@@ -119,3 +119,3 @@ 'use strict'; | ||
const { isDeepEqual, valueOf, hasOwnEnumerableProperty } = internals; | ||
const { keys } = Object; | ||
const { keys, getOwnPropertySymbols } = Object; | ||
@@ -230,2 +230,34 @@ if (instanceType === internals.arrayType) { | ||
// Check symbols | ||
if (options.symbols) { | ||
const objSymbols = getOwnPropertySymbols(obj); | ||
const refSymbols = new Set(getOwnPropertySymbols(ref)); | ||
for (let i = 0; i < objSymbols.length; ++i) { | ||
const key = objSymbols[i]; | ||
if (hasOwnEnumerableProperty(obj, key)) { | ||
if (!hasOwnEnumerableProperty(ref, key)) { | ||
return false; | ||
} | ||
if (!isDeepEqual(obj[key], ref[key], options, seen)) { | ||
return false; | ||
} | ||
} | ||
else if (hasOwnEnumerableProperty(ref, key)) { | ||
return false; | ||
} | ||
refSymbols.delete(key); | ||
} | ||
for (const key of refSymbols) { | ||
if (hasOwnEnumerableProperty(ref, key)) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
@@ -232,0 +264,0 @@ }; |
@@ -69,3 +69,3 @@ 'use strict'; | ||
if (cloneDeep) { | ||
const keys = Object.getOwnPropertyNames(obj); | ||
const keys = Reflect.ownKeys(obj); | ||
for (let i = 0; i < keys.length; ++i) { | ||
@@ -130,6 +130,8 @@ const key = keys[i]; | ||
const keys = Object.keys(source); | ||
const keys = Reflect.ownKeys(source); | ||
for (let i = 0; i < keys.length; ++i) { | ||
const key = keys[i]; | ||
if (key === '__proto__') { | ||
if (key === '__proto__' || | ||
!Object.prototype.propertyIsEnumerable.call(source, key)) { | ||
continue; | ||
@@ -204,3 +206,3 @@ } | ||
const copy = exports.clone(source); // Deep copy the rest | ||
internals.restore(copy, source, storage); // Shallow copy the stored items and restore | ||
internals.restore(copy, source, storage); // Shallow copy the stored items and restore | ||
return copy; | ||
@@ -212,8 +214,10 @@ }; | ||
const storage = {}; | ||
const storage = new Map(); | ||
for (let i = 0; i < keys.length; ++i) { | ||
const key = keys[i]; | ||
const value = exports.reach(source, key); | ||
if (value !== undefined) { | ||
storage[key] = value; | ||
if (typeof value === 'object' || | ||
typeof value === 'function') { | ||
storage.set(key, value); | ||
internals.reachSet(source, key, undefined); | ||
@@ -229,7 +233,5 @@ } | ||
const keys = Object.keys(storage); | ||
for (let i = 0; i < keys.length; ++i) { | ||
const key = keys[i]; | ||
internals.reachSet(copy, key, storage[key]); | ||
internals.reachSet(source, key, storage[key]); | ||
for (const [key, value] of storage) { | ||
internals.reachSet(copy, key, value); | ||
internals.reachSet(source, key, value); | ||
} | ||
@@ -241,3 +243,3 @@ }; | ||
const path = key.split('.'); | ||
const path = Array.isArray(key) ? key : key.split('.'); | ||
let ref = obj; | ||
@@ -343,3 +345,4 @@ for (let i = 0; i < path.length; ++i) { | ||
valuePairs = values; | ||
values = Object.keys(values); | ||
const symbols = Object.getOwnPropertySymbols(values).filter(Object.prototype.propertyIsEnumerable.bind(values)); | ||
values = [...Object.keys(values), ...symbols]; | ||
} | ||
@@ -419,3 +422,3 @@ else { | ||
else { | ||
const keys = Object.getOwnPropertyNames(ref); | ||
const keys = Reflect.ownKeys(ref); | ||
for (let i = 0; i < keys.length; ++i) { | ||
@@ -494,9 +497,17 @@ const key = keys[i]; | ||
const path = chain.split(options.separator || '.'); | ||
const isChainArray = Array.isArray(chain); | ||
exports.assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain'); | ||
const path = isChainArray ? chain : chain.split(options.separator || '.'); | ||
let ref = obj; | ||
for (let i = 0; i < path.length; ++i) { | ||
let key = path[i]; | ||
if (key[0] === '-' && Array.isArray(ref)) { | ||
key = key.slice(1, key.length); | ||
key = ref.length - key; | ||
if (Array.isArray(ref)) { | ||
const number = Number(key); | ||
if (Number.isInteger(number) && number < 0) { | ||
key = ref.length + number; | ||
} | ||
} | ||
@@ -503,0 +514,0 @@ |
{ | ||
"name": "hoek", | ||
"description": "General purpose node utilities", | ||
"version": "6.0.4", | ||
"version": "6.1.1", | ||
"repository": "git://github.com/hapijs/hoek", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
30683
8
810
0