tor-browser

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

LocaleFallbackPriority.mjs (2296B)


      1 // generated by diplomat-tool
      2 import wasm from "./diplomat-wasm.mjs";
      3 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      4 
      5 
      6 /**
      7 * Priority mode for the ICU4X fallback algorithm.
      8 *
      9 * See the [Rust documentation for `LocaleFallbackPriority`](https://docs.rs/icu/latest/icu/locale/fallback/enum.LocaleFallbackPriority.html) for more information.
     10 */
     11 
     12 
     13 export class LocaleFallbackPriority {
     14    #value = undefined;
     15 
     16    static #values = new Map([
     17        ["Language", 0],
     18        ["Region", 1]
     19    ]);
     20 
     21    static getAllEntries() {
     22        return LocaleFallbackPriority.#values.entries();
     23    }
     24 
     25    #internalConstructor(value) {
     26        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
     27            // We pass in two internalConstructor arguments to create *new*
     28            // instances of this type, otherwise the enums are treated as singletons.
     29            if (arguments[1] === diplomatRuntime.internalConstructor ) {
     30                this.#value = arguments[2];
     31                return this;
     32            }
     33            return LocaleFallbackPriority.#objectValues[arguments[1]];
     34        }
     35 
     36        if (value instanceof LocaleFallbackPriority) {
     37            return value;
     38        }
     39 
     40        let intVal = LocaleFallbackPriority.#values.get(value);
     41 
     42        // Nullish check, checks for null or undefined
     43        if (intVal != null) {
     44            return LocaleFallbackPriority.#objectValues[intVal];
     45        }
     46 
     47        throw TypeError(value + " is not a LocaleFallbackPriority and does not correspond to any of its enumerator values.");
     48    }
     49 
     50    static fromValue(value) {
     51        return new LocaleFallbackPriority(value);
     52    }
     53 
     54    get value(){
     55        return [...LocaleFallbackPriority.#values.keys()][this.#value];
     56    }
     57 
     58    get ffiValue(){
     59        return this.#value;
     60    }
     61    static #objectValues = [
     62        new LocaleFallbackPriority(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
     63        new LocaleFallbackPriority(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
     64    ];
     65 
     66    static Language = LocaleFallbackPriority.#objectValues[0];
     67    static Region = LocaleFallbackPriority.#objectValues[1];
     68 
     69 
     70    constructor(value) {
     71        return this.#internalConstructor(...arguments)
     72    }
     73 }