immutable-assign
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -115,9 +115,9 @@ "use strict"; | ||
function getPropPath(getProp, obj, context, option) { | ||
var objCopy = quickCopy(obj, undefined, option.useConstructor, option.copyFunc); | ||
var paths = []; | ||
var objCopy; | ||
if (typeof Proxy === "undefined") { | ||
_getPropPathViaProperty(obj, objCopy, paths); | ||
objCopy = _getPropPathViaProperty(obj, paths); | ||
} | ||
else { | ||
objCopy = _getPropPathViaProxy(obj, objCopy, paths); | ||
objCopy = _getPropPathViaProxy(obj, paths); | ||
} | ||
@@ -127,4 +127,5 @@ getProp(objCopy, context); | ||
} | ||
function _getPropPathViaProperty(obj, objCopy, paths, level) { | ||
function _getPropPathViaProperty(obj, paths, level) { | ||
if (level === void 0) { level = 0; } | ||
var objCopy = quickCopy(obj, paths[level - 1]); | ||
var propertyNames = Object.getOwnPropertyNames(obj); | ||
@@ -141,7 +142,5 @@ propertyNames.forEach(function (propKey) { | ||
var propValue = obj[propKey]; | ||
var propValueCopy = quickCopy(propValue); | ||
if (propValue != undefined) { | ||
_getPropPathViaProperty(propValue, propValueCopy, paths, level + 1); | ||
return _getPropPathViaProperty(propValue, paths, level + 1); | ||
} | ||
return propValueCopy; | ||
} | ||
@@ -154,22 +153,19 @@ return obj[propKey]; | ||
}); | ||
return objCopy; | ||
} | ||
function _getPropPathViaProxy(obj, objCopy, paths, level) { | ||
function _getPropPathViaProxy(obj, paths, level) { | ||
if (level === void 0) { level = 0; } | ||
var handlers = { | ||
get: function (target, propKey) { | ||
var propValue = obj[propKey]; | ||
if (level == paths.length) { | ||
paths.push(propKey); | ||
var propValue = obj[propKey]; | ||
if (typeof propValue === "object") { | ||
var propValueCopy = quickCopy(propValue); | ||
if (propValue != undefined) { | ||
propValueCopy = _getPropPathViaProxy(propValue, propValueCopy, paths, level + 1); | ||
} | ||
return propValueCopy; | ||
if (typeof propValue === "object" && propValue != null) { | ||
return _getPropPathViaProxy(propValue, paths, level + 1); | ||
} | ||
} | ||
return obj[propKey]; | ||
return propValue; | ||
}, | ||
}; | ||
return new Proxy(objCopy, handlers); | ||
return new Proxy(quickCopy(obj, paths[level - 1]), handlers); | ||
} | ||
@@ -176,0 +172,0 @@ // For performance |
{ | ||
"name": "immutable-assign", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": | ||
@@ -14,2 +14,3 @@ "Lightweight immutable helper that allows you to continue working with Plain JavaScript Objects", | ||
"test-karma-mac": "node_modules/.bin/karma start --browsers Safari,Chrome", | ||
"test-karma-mac-no-proxy": "NO_PROXY='true' yarn run test-karma-mac", | ||
"cover": "node node_modules/istanbul/lib/cli.js cover node_modules/jasmine/bin/jasmine.js", | ||
@@ -16,0 +17,0 @@ "debug": "node --inspect --inspect-brk node_modules/jasmine/bin/jasmine.js", |
@@ -483,3 +483,3 @@ # immutable-assign (iassign.js) | ||
* 2.0.3 - Replaced the proxy-polyfill with Object.defineProperty(), which has much better browser support. | ||
* 2.0.4 - Replaced the proxy-polyfill with Object.defineProperty(), which has much better browser support. | ||
* 2.0.1 - Minor bug fixes. | ||
@@ -486,0 +486,0 @@ * 2.0.0 - |
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
1518262
7251