Skip to content

Latest commit

 

History

History

jsoncopy

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

jsoncopy

Create a deep clone of an object using JSON functionalities. Very efficient and quick, not a comprehensive copyier (can't copy functions, circular references)

const jsoncopy = require('jsoncopy');

const orig = {top: {nested: {value: 1}}};
const copy = jsoncopy(obj);
obj.top.nested.value = 2;

orig.top.nested.value // 2
copy.top.nested.value // 1

Transpiled version

Environments which exclude node_modules from the transpiling pipeline should include the "browser" entry instead of "main". This exposes an ES5 commonjs module.

Also available for explicit import:

const jsoncopy = require('jsoncopy/dist');