0

I need to make deep cloning an objects in Node.js. I'm using _.extend at now but according this it might get a problems due shallow copying of nested objects. I need to have deep cloning most like as jQuery.extend. So my question is there are any Node.js modules (or native ones) for deep object cloning?

James
  • 5,137
  • 5
  • 40
  • 80
Erik
  • 14,060
  • 49
  • 132
  • 218

1 Answers1

-2

https://github.com/lodash/lodash

has deep clone method which i think is what you want :)

var cloneOfDeepNestedObject _.cloneDeep(deepNestedObject);

http://lodash.com/docs#cloneDeep

provides a one for one replacement for underscore with some additinoal methods

seems stable used it a few times, seems to be equivalent, claims to be faster too

aqm
  • 2,942
  • 23
  • 30