node-v8-clone
It's a c++ addon for node.js that does the most accurate cloning for node.js. It's also very fast in some cases (benchmarks inside).
Installation:
Tested on node.js versions 0.8, 0.9, 0.10 and 0.11.13 (prior 0.11.x versions are not compatible).
You may be asked to install make
and g++
as well.
npm install node-v8-clone
Usage:
var clone = clone;var a = x: y: {} ; // deep clonevar b = ;a === b // falseax === bx // falseaxy === bxy // false // shallow clonevar c = ;a === c // falseax === cx // trueaxy === cxy // true
Extended syntax:
var Cloner = Cloner;var a = 1 2 3 4 5; // create a cloner instance for deep cloning optimized for arrays.var c = true 'Array': Clonerdeep_array ;var b = c;a === b // falsea1 === b1 // false
Benchmark results
Running tests
For running tests you'll need to install dev dependencies at first (run in node-v8-clone dir):
$ npm install
To run tests for node-v8-clone run:
$ npm test
To run tests for 3rdparty modules run:
$ npm run-script benchmark-prepare
$ npm run-script test-3rdparty
Test results are available here.
Also you may want to check the module's page at Travis CI.