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 0.1.15 to 0.1.16

9

clone.js

@@ -7,2 +7,4 @@ 'use strict';

// shim for Node's 'util' package
// DO NOT REMOVE THIS! It is required for compatibility with EnderJS (http://enderjs.com/).
var util = {

@@ -46,5 +48,7 @@ isArray: function (ar) {

* a particular depth. (optional - defaults to Infinity)
* @param `prototype` - sets the prototype to be used when cloning an object.
* (optional - defaults to parent prototype).
*/
function clone(parent, circular, depth) {
function clone(parent, circular, depth, prototype) {
// maintain two arrays for circular references, where corresponding parents

@@ -88,3 +92,4 @@ // and children have the same index

} else {
child = Object.create(Object.getPrototypeOf(parent));
if (typeof prototype == 'undefined') child = Object.create(Object.getPrototypeOf(parent));
else child = Object.create(prototype);
}

@@ -91,0 +96,0 @@

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

],
"version": "0.1.15",
"version": "0.1.16",
"repository": {

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

"Ilya Shaisultanov (https://github.com/diversario)",
"Nathan MacInnes <nathan@macinn.es> (http://macinn.es/)"
"Nathan MacInnes <nathan@macinn.es> (http://macinn.es/)",
"Benjamin E. Coe <ben@npmjs.com> (https://twitter.com/benjamincoe)"
],

@@ -36,0 +37,0 @@ "engines": {

@@ -249,2 +249,11 @@ if(module.parent === null) {

exports['parent prototype is overriden with prototype provided'] = function (test) {
test.expect(1);
function Constructor() {}
var a = new Constructor();
var b = clone(a, true, Infinity, null);
test.strictEqual(b.__defineSetter__, undefined);
test.done();
}
exports['clone object with null children'] = function(test) {

@@ -251,0 +260,0 @@ test.expect(1);

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