Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asins/deep-clone

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asins/deep-clone - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

50

dist/index.esm.js

@@ -8,27 +8,39 @@ /**

function clone(o) {
let res;
if (typeof o !== 'object' || o === null)
return o;
// @ts-ignore Date类型转为T类型
if (o instanceof Date)
return new Date(o);
if (Array.isArray(o)) {
const keys = Object.keys(o);
const a2 = new Array(keys.length);
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
a2[k] = clone(o[k]);
res = o;
else if (o instanceof Date)
res = new Date(o);
else if (Array.isArray(o))
res = cloneArray(o, clone);
else if (o instanceof Map)
res = new Map(cloneArray(Array.from(o), clone));
else if (o instanceof Set)
res = new Set(cloneArray(Array.from(o), clone));
else if (ArrayBuffer.isView(o))
res = o.slice(0);
else if (o instanceof Element)
res = o;
else {
res = {};
for (var k in o) {
if (Object.hasOwnProperty.call(o, k) === false)
continue;
// @ts-ignore Object类型转为T类型
res[k] = clone(o[k]);
}
// @ts-ignore Array类型转为T类型
return a2;
}
const o2 = {};
for (const k in o) {
if (Object.hasOwnProperty.call(o, k) === false)
continue;
// @ts-ignore Object类型转为T类型
o2[k] = clone(o[k]);
return res;
}
function cloneArray(a, fn) {
var keys = Object.keys(a);
var a2 = new Array(keys.length);
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
a2[k] = fn(a[k]);
}
return o2;
// @ts-ignore Array类型转为T类型
return a2;
}
export { clone as default };

@@ -12,27 +12,39 @@ 'use strict';

function clone(o) {
let res;
if (typeof o !== 'object' || o === null)
return o;
// @ts-ignore Date类型转为T类型
if (o instanceof Date)
return new Date(o);
if (Array.isArray(o)) {
const keys = Object.keys(o);
const a2 = new Array(keys.length);
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
a2[k] = clone(o[k]);
res = o;
else if (o instanceof Date)
res = new Date(o);
else if (Array.isArray(o))
res = cloneArray(o, clone);
else if (o instanceof Map)
res = new Map(cloneArray(Array.from(o), clone));
else if (o instanceof Set)
res = new Set(cloneArray(Array.from(o), clone));
else if (ArrayBuffer.isView(o))
res = o.slice(0);
else if (o instanceof Element)
res = o;
else {
res = {};
for (var k in o) {
if (Object.hasOwnProperty.call(o, k) === false)
continue;
// @ts-ignore Object类型转为T类型
res[k] = clone(o[k]);
}
// @ts-ignore Array类型转为T类型
return a2;
}
const o2 = {};
for (const k in o) {
if (Object.hasOwnProperty.call(o, k) === false)
continue;
// @ts-ignore Object类型转为T类型
o2[k] = clone(o[k]);
return res;
}
function cloneArray(a, fn) {
var keys = Object.keys(a);
var a2 = new Array(keys.length);
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
a2[k] = fn(a[k]);
}
return o2;
// @ts-ignore Array类型转为T类型
return a2;
}
exports["default"] = clone;
{
"name": "@asins/deep-clone",
"version": "1.0.9",
"version": "1.0.10",
"description": "对象深度拷贝",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc