Comparing version 0.1.3 to 0.1.4
30
index.js
@@ -1,8 +0,16 @@ | ||
module.exports = function clone (src) { | ||
// ES6 Map | ||
var map | ||
try { | ||
map = Map | ||
} catch (_) {} | ||
var set | ||
// ES6 Set | ||
try { | ||
set = Set | ||
} catch (_) {} | ||
module.exports = function clone(src) { | ||
// Null/undefined/functions/etc | ||
if ( | ||
!src || | ||
typeof src !== 'object' || | ||
typeof src === 'function' | ||
) { | ||
if (!src || typeof src !== 'object' || typeof src === 'function') { | ||
return src | ||
@@ -31,2 +39,12 @@ } | ||
// ES6 Maps | ||
if (map && src instanceof map) { | ||
return new Map(Array.from(src.entries())) | ||
} | ||
// ES6 Sets | ||
if (set && src instanceof set) { | ||
return new Set(Array.from(src.values())) | ||
} | ||
// Object | ||
@@ -33,0 +51,0 @@ if (src instanceof Object) { |
{ | ||
"name": "nanoclone", | ||
"version": "0.1.3", | ||
"description": "290B to deep clone JavaScript objects", | ||
"version": "0.1.4", | ||
"description": "200B to deep clone JavaScript objects", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3718
56
0