letsfreezethat
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -56,4 +56,5 @@ (function() { | ||
deep_freeze = function(d) { | ||
var k, v; | ||
if ((!d) || d === true) { | ||
/* thx to https://github.com/lukeed/klona/blob/master/src/json.js */ | ||
var is_first, k, v; | ||
if ((!d) || (d === true)) { | ||
/* TAINT code duplication */ | ||
@@ -63,3 +64,3 @@ /* immediately return for zero, empty string, null, undefined, NaN, false, true: */ | ||
} | ||
/* thx to https://github.com/lukeed/klona/blob/master/src/json.js */ | ||
is_first = true; | ||
switch (Object.prototype.toString.call(d)) { | ||
@@ -69,6 +70,8 @@ case '[object Array]': | ||
while (k--) { | ||
if (((v = d[k]) != null) && ((typeof v) === 'object')) { | ||
if (((v = d[k]) != null) && ((typeof v) === 'object') && (!frozen(v))) { | ||
if (is_first && (frozen(d))) { | ||
is_first = false; | ||
d = deep_copy(d); | ||
} | ||
d[k] = deep_freeze(v); | ||
} else { | ||
d[k] = v; | ||
} | ||
@@ -80,6 +83,8 @@ } | ||
v = d[k]; | ||
if ((v != null) && ((typeof v) === 'object')) { | ||
if ((v != null) && ((typeof v) === 'object') && (!frozen(v))) { | ||
if (is_first && (frozen(d))) { | ||
is_first = false; | ||
d = deep_copy(d); | ||
} | ||
d[k] = deep_freeze(v); | ||
} else { | ||
d[k] = v; | ||
} | ||
@@ -86,0 +91,0 @@ } |
{ | ||
"name": "letsfreezethat", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "An utterly minimal immutability library in the spirit of immer", | ||
@@ -5,0 +5,0 @@ "main": "./freeze.js", |
Sorry, the diff of this file is not supported yet
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
40656
151