deep extend (like jQuery's) for nodeJS

itsatony picture itsatony · Feb 22, 2012 · Viewed 41.1k times · Source

I am struggling with deep copies of objects in nodeJS. my own extend is crap. underscore's extend is flat. there are rather simple extend variants here on stackexchange, but none are even close to jQuery.extend(true, {}, obj, obj, obj) .. (most are actually terrible and screw up the benefits of asnyc code.)

hence, my question: is there a good deep copy for NodeJS? Has anybody ported jQuery's ?

Answer

Raynos picture Raynos · Feb 22, 2012

It's already been ported. node-extend

Note the project doesn't have tests and doesn't have much popularity, so use at your own risk.

As mentioned you probably don't need deep copies. Try to change your data structures so you only need shallow copies.

Few months later

I wrote a smaller module instead, recommend you use xtend. It's not got an implementation containing jQuery baggage nor does it have bugs like node-extend does.