when making deep copies of an object, default to alphabetically sorting the properties for adding

This commit is contained in:
Dan Mills 2008-07-23 15:46:48 -07:00
parent 94bb10dca1
commit 39b90d3639

View File

@ -183,7 +183,7 @@ let Utils = {
return true;
},
deepCopy: function Weave_deepCopy(thing, sort) {
deepCopy: function Weave_deepCopy(thing, noSort) {
if (typeof(thing) != "object" || thing == null)
return thing;
let ret;
@ -191,12 +191,12 @@ let Utils = {
if ("Array" == thing.constructor.name) {
ret = [];
for (let i = 0; i < thing.length; i++)
ret.push(Utils.deepCopy(thing[i]), sort);
ret.push(Utils.deepCopy(thing[i]), noSort);
} else {
ret = {};
let props = [p for (p in thing)];
if (sort)
if (!noSort)
props = props.sort();
props.forEach(function(k) ret[k] = Utils.deepCopy(thing[k], sort));
}