Socket
Socket
Sign inDemoInstall

node-v8-clone

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

8

bench/shared.js

@@ -195,2 +195,5 @@ var plot = require('benchmark.js-plot').plot;

var suite = new Benchmark.Suite;
suite.on('start', function() {
console.log('===', suite_name, '===');
});
suite.on('cycle', function(event) {

@@ -201,4 +204,7 @@ if (typeof gc == 'function') gc();

suite.on('complete', function() {
plot(this, { path: 'results/' + suite_name + '.png' });
var path = 'results/' + suite_name + '.png';
plot(this, { path: path });
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
console.log('written plot:', path);
console.log();
});

@@ -205,0 +211,0 @@

@@ -84,2 +84,3 @@ "use strict";

//var f = this._deepCloneObjectAllProperties;
var f = this._deepCloneObjectProperties;

@@ -95,8 +96,14 @@ if (value.constructor && this._map[value.constructor.name]) {

for (var i = 0, l = props.length; i < l; i++)
if (typeof value[props[i]] === 'object')
if (typeof value[props[i]] === 'object' || typeof value[props[i]] === 'function')
value[props[i]] = cloner._clone(value[props[i]]);
};
Cloner.prototype._deepCloneObjectAllProperties = function(cloner, value) {
var props = Object.getOwnPropertyNames(value);
for (var i = 0, l = props.length; i < l; i++)
if (typeof value[props[i]] === 'object' || typeof value[props[i]] === 'function')
value[props[i]] = cloner._clone(value[props[i]]);
};
Cloner.prototype._deepCloneArrayValues = function(cloner, value) {
for (var i = 0, l = value.length; i < l; i++)
if (typeof value === 'object' || typeof value === 'function')
if (typeof value[i] === 'object' || typeof value[i] === 'function')
value[i] = cloner._clone(value[i]);

@@ -103,0 +110,0 @@ };

2

package.json
{
"name": "node-v8-clone",
"version": "0.4.0",
"version": "0.4.1",
"description": "The most convenient and accurate cloner for node.js. It's also very fast in some cases (benchmarks inside).",

@@ -5,0 +5,0 @@ "main": "lib/clone.js",

@@ -89,2 +89,13 @@ var assert = require('assert');

});
it('should preserve {} non-enumerable properties', function(){
var a = {x : 1};
Object.defineProperty(a, 'y', {value: 2});
assert.deepEqual(Object.keys(a), ['x']);
var b = this.clone(a);
assert.ok(a !== b);
assert.equal(a.x, 1);
assert.equal(a.y, 2);
assert.equal(b.x, 1);
assert.equal(b.y, 2);
});
it('should clone Object.create(null) objects', function(){

@@ -324,2 +335,14 @@ var a = Object.create(null);

});
it('should deeply clone {} non-enumerable properties', false, function(){
var a = {x : 1};
Object.defineProperty(a, 'y', {enumerable: false, configurable: true, writable: true, value: {z: 3}});
assert.deepEqual(Object.keys(a), ['x']);
var b = this.clone(a);
assert.ok(a !== b);
assert.ok(a.y !== b.y);
assert.equal(a.x, 1);
assert.equal(a.y.z, 3);
assert.equal(b.x, 1);
assert.equal(b.y.z, 3);
});
it('should deeply clone nested arrays', function(){

@@ -326,0 +349,0 @@ var a = [[1], 2];

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