Closed conradz closed 12 years ago
mixIn
doesn't clone the properties it just copy the references, so I think this implementation is closer to object/merge
.
$.extend(true, foo, bar);
also doesn't clone the properties, it just overwrites the members of all arrays/objects. I think we should match jQuery behavior for the deepMixIn
method.
Do think we need a mutating object/merge
? I feel it's redundant if we have a deepMixIn
.
Thanks for all the good feedback and pull requests!
OK, I changed object/deepMixIn
to not clone child objects. My use case didn't really matter if we don't clone the child objects, I had just put it in because object/merge
had it. Didn't see that jQuery.extend
didn't have it, though. I'm using this to receive incremental updates from the server in JSON format, and update the existing data on the client.
@conradz I updated it to also merge arrays, matching the $.extend(true)
behavior. Thanks once again.
This adds a method that works like jQuery's extend method with the first parameter
true
to specify the deep copy.Not totally sure about the name, it could be a mutating
object/merge
or a deep copyingobject/mixIn
method. It is closest toobject/mixIn
in the code, though.