tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

enum.js (566B)


      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/. */
      4 
      5 "use strict";
      6 
      7 module.exports = {
      8  /**
      9   * Create a simple enum-like object with keys mirrored to values from an array.
     10   * This makes comparison to a specfic value simpler without having to repeat and
     11   * mis-type the value.
     12   */
     13  createEnum(array, target = {}) {
     14    for (const key of array) {
     15      target[key] = key;
     16    }
     17    return target;
     18  },
     19 };