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.18 to 0.1.19

19

clone.js

@@ -75,2 +75,3 @@ 'use strict';

var child;
var proto;
if (typeof parent != 'object') {

@@ -92,4 +93,10 @@ return parent;

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

@@ -108,2 +115,10 @@

for (var i in parent) {
var attrs;
if (proto) {
attrs = Object.getOwnPropertyDescriptor(proto, i);
}
if (attrs && attrs.set == null) {
continue;
}
child[i] = _clone(parent[i], depth - 1);

@@ -110,0 +125,0 @@ }

5

package.json

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

],
"version": "0.1.18",
"version": "0.1.19",
"repository": {

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

"Benjamin E. Coe <ben@npmjs.com> (https://twitter.com/benjamincoe)",
"Nathan Zadoks (https://github.com/nathan7)"
"Nathan Zadoks (https://github.com/nathan7)",
"Róbert Oroszi <robert+gh@oroszi.net> (https://github.com/oroce)"
],

@@ -38,0 +39,0 @@ "license": "MIT",

@@ -24,3 +24,3 @@ # clone

a = { foo: { bar: 'baz' } }; // inital value of a
a = { foo: { bar: 'baz' } }; // initial value of a

@@ -56,3 +56,3 @@ b = clone(a); // clone a -> b

There is no error if `undefined` or `null` is passed as `obj`.
* `depth` -- depth to wich the object is to be cloned (optional,
* `depth` -- depth to which the object is to be cloned (optional,
defaults to infinity)

@@ -59,0 +59,0 @@

@@ -272,1 +272,19 @@ if(module.parent === null) {

}
exports['clone instance with getter'] = function(test) {
test.expect(1);
function Ctor() {};
Object.defineProperty(Ctor.prototype, 'prop', {
configurable: true,
enumerable: true,
get: function() {
return 'value';
}
});
var a = new Ctor();
var b = clone(a);
test.strictEqual(b.prop, 'value');
test.done();
};
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