Comparing version 2.2.2 to 2.2.3
41
index.js
@@ -7,2 +7,4 @@ 'use strict'; | ||
const isSymbol = require('./lib/is-symbol'); | ||
const isIterator = require('./lib/is-iterator'); | ||
const wrapIterator = require('./lib/wrap-iterator'); | ||
const ignoreProperty = require('./lib/ignore-property'); | ||
@@ -57,2 +59,21 @@ const Cache = require('./lib/cache'); | ||
const prepareValue = (value, target, property, basePath) => { | ||
if ( | ||
isBuiltin.withoutMutableMethods(value) || | ||
property === 'constructor' || | ||
(isShallow && !SmartClone.isHandledMethod(target, property)) || | ||
ignoreProperty(cache, options, property) || | ||
cache.isGetInvariant(target, property) || | ||
(ignoreDetached && cache.isDetached(target, object)) | ||
) { | ||
return value; | ||
} | ||
if (basePath === undefined) { | ||
basePath = cache.getPath(target); | ||
} | ||
return cache.getProxy(value, path.concat(basePath, property), handler, proxyTarget); | ||
}; | ||
const handler = { | ||
@@ -79,14 +100,3 @@ get(target, property, receiver) { | ||
if ( | ||
isBuiltin.withoutMutableMethods(value) || | ||
property === 'constructor' || | ||
(isShallow && !SmartClone.isHandledMethod(target, property)) || | ||
ignoreProperty(cache, options, property) || | ||
cache.isGetInvariant(target, property) || | ||
(ignoreDetached && cache.isDetached(target, object)) | ||
) { | ||
return value; | ||
} | ||
return cache.getProxy(value, path.concat(cache.getPath(target), property), handler, proxyTarget); | ||
return prepareValue(value, target, property); | ||
}, | ||
@@ -172,2 +182,9 @@ | ||
if ( | ||
(thisArg instanceof Map || thisArg instanceof Set) && | ||
isIterator(result) | ||
) { | ||
return wrapIterator(result, target, thisArg, applyPath, prepareValue); | ||
} | ||
return (SmartClone.isHandledType(result) && isHandledMethod) ? | ||
@@ -174,0 +191,0 @@ cache.getProxy(result, applyPath, handler, proxyTarget) : |
@@ -65,4 +65,3 @@ 'use strict'; | ||
'has', | ||
'toString', | ||
'keys' | ||
'toString' | ||
]); | ||
@@ -91,2 +90,8 @@ | ||
const COLLECTION_ITERATOR_METHODS = [ | ||
'keys', | ||
'values', | ||
'entries' | ||
]; | ||
const SHALLOW_MUTABLE_MAP_METHODS = { | ||
@@ -103,6 +108,8 @@ set: shallowEqualMaps, | ||
const HANDLED_SET_METHODS = new Set([...IMMUTABLE_SET_METHODS] | ||
.concat(Object.keys(SHALLOW_MUTABLE_SET_METHODS))); | ||
.concat(Object.keys(SHALLOW_MUTABLE_SET_METHODS)) | ||
.concat(COLLECTION_ITERATOR_METHODS)); | ||
const HANDLED_MAP_METHODS = new Set([...IMMUTABLE_MAP_METHODS] | ||
.concat(Object.keys(SHALLOW_MUTABLE_MAP_METHODS))); | ||
.concat(Object.keys(SHALLOW_MUTABLE_MAP_METHODS)) | ||
.concat(COLLECTION_ITERATOR_METHODS)); | ||
@@ -109,0 +116,0 @@ class Clone { |
{ | ||
"name": "on-change", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Watch an object or array for changes", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
30659
16
852