1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/objects.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +var EXPORTED_SYMBOLS = ['getLength', ];//'compare']; 1.9 + 1.10 +var getLength = function (obj) { 1.11 + var len = 0; 1.12 + for (i in obj) { 1.13 + len++; 1.14 + } 1.15 + 1.16 + return len; 1.17 +} 1.18 + 1.19 +// var logging = {}; Components.utils.import('resource://mozmill/stdlib/logging.js', logging); 1.20 + 1.21 +// var objectsLogger = logging.getLogger('objectsLogger'); 1.22 + 1.23 +// var compare = function (obj1, obj2, depth, recursion) { 1.24 +// if (depth == undefined) { 1.25 +// var depth = 4; 1.26 +// } 1.27 +// if (recursion == undefined) { 1.28 +// var recursion = 0; 1.29 +// } 1.30 +// 1.31 +// if (recursion > depth) { 1.32 +// return true; 1.33 +// } 1.34 +// 1.35 +// if (typeof(obj1) != typeof(obj2)) { 1.36 +// return false; 1.37 +// } 1.38 +// 1.39 +// if (typeof(obj1) == "object" && typeof(obj2) == "object") { 1.40 +// if ([x for (x in obj1)].length != [x for (x in obj2)].length) { 1.41 +// return false; 1.42 +// } 1.43 +// for (i in obj1) { 1.44 +// recursion++; 1.45 +// var result = compare(obj1[i], obj2[i], depth, recursion); 1.46 +// objectsLogger.info(i+' in recursion '+result); 1.47 +// if (result == false) { 1.48 +// return false; 1.49 +// } 1.50 +// } 1.51 +// } else { 1.52 +// if (obj1 != obj2) { 1.53 +// return false; 1.54 +// } 1.55 +// } 1.56 +// return true; 1.57 +// }