Comparing version 1.1.0 to 1.1.1
@@ -9,3 +9,12 @@ module.exports = function klona(x) { | ||
for (k in x) { | ||
tmp[k] = klona(x[k]); | ||
if (k === '__proto__') { | ||
Object.defineProperty(tmp, k, { | ||
value: klona(x[k]), | ||
configurable: 1, | ||
enumerable: 1, | ||
writable: 1, | ||
}); | ||
} else { | ||
tmp[k] = klona(x[k]); | ||
} | ||
} | ||
@@ -23,6 +32,22 @@ return tmp; | ||
if (str === '[object Set]') return new Set(x); | ||
if (str === '[object Date]') return new Date(+x); | ||
if (str === '[object Map]') return new Map(x); | ||
if (str === '[object Set]') { | ||
tmp = new Set(); | ||
x.forEach(function (val) { | ||
tmp.add(klona(val)); | ||
}); | ||
return tmp; | ||
} | ||
if (str === '[object Map]') { | ||
tmp = new Map(); | ||
x.forEach(function (val, key) { | ||
tmp.set(klona(key), klona(val)); | ||
}); | ||
return tmp; | ||
} | ||
if (str === '[object Date]') { | ||
return new Date(+x); | ||
} | ||
if (str === '[object RegExp]') { | ||
@@ -29,0 +54,0 @@ tmp = new RegExp(x.source, x.flags); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.klona=t()}(this,function(){return function e(t){if("object"!=typeof t)return t;var n,o,r=Object.prototype.toString.call(t);if("[object Object]"===r){for(n in o={},t)o[n]=e(t[n]);return o}if("[object Array]"===r){for(n=t.length,o=new Array(n);n--;)o[n]=e(t[n]);return o}return"[object Set]"===r?new Set(t):"[object Date]"===r?new Date(+t):"[object Map]"===r?new Map(t):"[object RegExp]"===r?((o=new RegExp(t.source,t.flags)).lastIndex=t.lastIndex,o):"Array]"===r.slice(-6)?new t.constructor(t):t}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.klona=t()}(this,function(){return function e(t){if("object"!=typeof t)return t;var n,o,r=Object.prototype.toString.call(t);if("[object Object]"===r){for(n in o={},t)"__proto__"===n?Object.defineProperty(o,n,{value:e(t[n]),configurable:1,enumerable:1,writable:1}):o[n]=e(t[n]);return o}if("[object Array]"===r){for(n=t.length,o=new Array(n);n--;)o[n]=e(t[n]);return o}return"[object Set]"===r?(o=new Set,t.forEach(function(t){o.add(e(t))}),o):"[object Map]"===r?(o=new Map,t.forEach(function(t,n){o.set(e(n),e(t))}),o):"[object Date]"===r?new Date(+t):"[object RegExp]"===r?((o=new RegExp(t.source,t.flags)).lastIndex=t.lastIndex,o):"Array]"===r.slice(-6)?new t.constructor(t):t}}); |
{ | ||
"name": "klona", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"repository": "lukeed/klona", | ||
"description": "A tiny (281B) and fast utility to \"deep clone\" Objects, Arrays, Dates, RegExps, and more!", | ||
"description": "A tiny (366B) and fast utility to \"deep clone\" Objects, Arrays, Dates, RegExps, and more!", | ||
"module": "dist/klona.mjs", | ||
@@ -7,0 +7,0 @@ "unpkg": "dist/klona.min.js", |
@@ -20,3 +20,3 @@ <div align="center"> | ||
<div align="center">A tiny (281B) and fast utility to "deep clone" Objects, Arrays, Dates, RegExps, and more!</div> | ||
<div align="center">A tiny (366B) and fast utility to "deep clone" Objects, Arrays, Dates, RegExps, and more!</div> | ||
@@ -23,0 +23,0 @@ |
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
8368
107