services/sync/tps/extensions/mozmill/resource/stdlib/objects.js

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 var EXPORTED_SYMBOLS = ['getLength', ];//'compare'];
michael@0 6
michael@0 7 var getLength = function (obj) {
michael@0 8 var len = 0;
michael@0 9 for (i in obj) {
michael@0 10 len++;
michael@0 11 }
michael@0 12
michael@0 13 return len;
michael@0 14 }
michael@0 15
michael@0 16 // var logging = {}; Components.utils.import('resource://mozmill/stdlib/logging.js', logging);
michael@0 17
michael@0 18 // var objectsLogger = logging.getLogger('objectsLogger');
michael@0 19
michael@0 20 // var compare = function (obj1, obj2, depth, recursion) {
michael@0 21 // if (depth == undefined) {
michael@0 22 // var depth = 4;
michael@0 23 // }
michael@0 24 // if (recursion == undefined) {
michael@0 25 // var recursion = 0;
michael@0 26 // }
michael@0 27 //
michael@0 28 // if (recursion > depth) {
michael@0 29 // return true;
michael@0 30 // }
michael@0 31 //
michael@0 32 // if (typeof(obj1) != typeof(obj2)) {
michael@0 33 // return false;
michael@0 34 // }
michael@0 35 //
michael@0 36 // if (typeof(obj1) == "object" && typeof(obj2) == "object") {
michael@0 37 // if ([x for (x in obj1)].length != [x for (x in obj2)].length) {
michael@0 38 // return false;
michael@0 39 // }
michael@0 40 // for (i in obj1) {
michael@0 41 // recursion++;
michael@0 42 // var result = compare(obj1[i], obj2[i], depth, recursion);
michael@0 43 // objectsLogger.info(i+' in recursion '+result);
michael@0 44 // if (result == false) {
michael@0 45 // return false;
michael@0 46 // }
michael@0 47 // }
michael@0 48 // } else {
michael@0 49 // if (obj1 != obj2) {
michael@0 50 // return false;
michael@0 51 // }
michael@0 52 // }
michael@0 53 // return true;
michael@0 54 // }

mercurial