Socket
Socket
Sign inDemoInstall

clone

Package Overview
Dependencies
0
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

40

clone.js
var clone = (function() {
'use strict';
function _instanceof(obj, type) {
return type != null && obj instanceof type;
}
var nativeMap;

@@ -83,7 +87,7 @@ try {

if (parent instanceof nativeMap) {
if (_instanceof(parent, nativeMap)) {
child = new nativeMap();
} else if (parent instanceof nativeSet) {
} else if (_instanceof(parent, nativeSet)) {
child = new nativeSet();
} else if (parent instanceof nativePromise) {
} else if (_instanceof(parent, nativePromise)) {
child = new nativePromise(function (resolve, reject) {

@@ -107,3 +111,3 @@ parent.then(function(value) {

return child;
} else if (parent instanceof Error) {
} else if (_instanceof(parent, Error)) {
child = Object.create(parent);

@@ -131,24 +135,14 @@ } else {

if (parent instanceof nativeMap) {
var keyIterator = parent.keys();
while(true) {
var next = keyIterator.next();
if (next.done) {
break;
}
var keyChild = _clone(next.value, depth - 1);
var valueChild = _clone(parent.get(next.value), depth - 1);
if (_instanceof(parent, nativeMap)) {
parent.forEach(function(value, key) {
var keyChild = _clone(key, depth - 1);
var valueChild = _clone(value, depth - 1);
child.set(keyChild, valueChild);
}
});
}
if (parent instanceof nativeSet) {
var iterator = parent.keys();
while(true) {
var next = iterator.next();
if (next.done) {
break;
}
var entryChild = _clone(next.value, depth - 1);
if (_instanceof(parent, nativeSet)) {
parent.forEach(function(value) {
var entryChild = _clone(value, depth - 1);
child.add(entryChild);
}
});
}

@@ -155,0 +149,0 @@

@@ -11,3 +11,3 @@ {

],
"version": "2.1.0",
"version": "2.1.1",
"repository": {

@@ -42,3 +42,4 @@ "type": "git",

"Martin Jurča (https://github.com/jurca)",
"Misery Lee <miserylee@foxmail.com> (https://github.com/miserylee)"
"Misery Lee <miserylee@foxmail.com> (https://github.com/miserylee)",
"Clemens Wolff (https://github.com/c-w)"
],

@@ -45,0 +46,0 @@ "license": "MIT",

# clone
[![build status](https://secure.travis-ci.org/pvorb/node-clone.svg)](http://travis-ci.org/pvorb/node-clone)
[![build status](https://secure.travis-ci.org/pvorb/clone.svg)](http://travis-ci.org/pvorb/clone) [![downloads](https://img.shields.io/npm/dt/clone.svg)](http://npm-stat.com/charts.html?package=clone)
[![info badge](https://nodei.co/npm/clone.svg?downloads=true&downloadRank=true&stars=true)](http://npm-stat.com/charts.html?package=clone)
offers foolproof _deep cloning_ of objects, arrays, numbers, strings, maps,

@@ -103,2 +101,9 @@ sets, promises, etc. in JavaScript.

### v2.1.1
#### 2017-03-09
- Fix build badge in README
- Add support for cloning Maps and Sets on Internet Explorer
### v2.1.0

@@ -145,3 +150,3 @@

be cloneable. If you find other objects that cannot be cloned, please [open an
issue](https://github.com/pvorb/node-clone/issues/new).
issue](https://github.com/pvorb/clone/issues/new).

@@ -152,3 +157,3 @@

If you encounter any bugs or issues, feel free to [open an issue at
github](https://github.com/pvorb/node-clone/issues) or send me an email to
github](https://github.com/pvorb/clone/issues) or send me an email to
<paul@vorba.ch>. I also always like to hear from you, if you’re using my code.

@@ -158,4 +163,4 @@

Copyright © 2011-2016 [Paul Vorbach](http://paul.vorba.ch/) and
[contributors](https://github.com/pvorb/node-clone/graphs/contributors).
Copyright © 2011-2016 [Paul Vorbach](https://paul.vorba.ch/) and
[contributors](https://github.com/pvorb/clone/graphs/contributors).

@@ -162,0 +167,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc