services/common/modules-testing/utils.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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 this.EXPORTED_SYMBOLS = [
     8   "TestingUtils",
     9 ];
    11 this.TestingUtils = {
    12   /**
    13    * Perform a deep copy of an Array or Object.
    14    */
    15   deepCopy: function deepCopy(thing, noSort) {
    16     if (typeof(thing) != "object" || thing == null) {
    17       return thing;
    18     }
    20     if (Array.isArray(thing)) {
    21       let ret = [];
    22       for (let element of thing) {
    23         ret.push(this.deepCopy(element, noSort));
    24       }
    26       return ret;
    27     }
    29     let ret = {};
    30     let props = [p for (p in thing)];
    32     if (!noSort) {
    33       props = props.sort();
    34     }
    36     for (let prop of props) {
    37       ret[prop] = this.deepCopy(thing[prop], noSort);
    38     }
    40     return ret;
    41   },
    42 };

mercurial