tor-browser

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

LocaleParseError.mjs (2469B)


      1 // generated by diplomat-tool
      2 import wasm from "./diplomat-wasm.mjs";
      3 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      4 
      5 
      6 /**
      7 * Additional information: [1](https://docs.rs/icu/latest/icu/locale/enum.ParseError.html)
      8 */
      9 
     10 
     11 export class LocaleParseError {
     12    #value = undefined;
     13 
     14    static #values = new Map([
     15        ["Unknown", 0],
     16        ["Language", 1],
     17        ["Subtag", 2],
     18        ["Extension", 3]
     19    ]);
     20 
     21    static getAllEntries() {
     22        return LocaleParseError.#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 LocaleParseError.#objectValues[arguments[1]];
     34        }
     35 
     36        if (value instanceof LocaleParseError) {
     37            return value;
     38        }
     39 
     40        let intVal = LocaleParseError.#values.get(value);
     41 
     42        // Nullish check, checks for null or undefined
     43        if (intVal != null) {
     44            return LocaleParseError.#objectValues[intVal];
     45        }
     46 
     47        throw TypeError(value + " is not a LocaleParseError and does not correspond to any of its enumerator values.");
     48    }
     49 
     50    static fromValue(value) {
     51        return new LocaleParseError(value);
     52    }
     53 
     54    get value(){
     55        return [...LocaleParseError.#values.keys()][this.#value];
     56    }
     57 
     58    get ffiValue(){
     59        return this.#value;
     60    }
     61    static #objectValues = [
     62        new LocaleParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
     63        new LocaleParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
     64        new LocaleParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
     65        new LocaleParseError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
     66    ];
     67 
     68    static Unknown = LocaleParseError.#objectValues[0];
     69    static Language = LocaleParseError.#objectValues[1];
     70    static Subtag = LocaleParseError.#objectValues[2];
     71    static Extension = LocaleParseError.#objectValues[3];
     72 
     73 
     74    constructor(value) {
     75        return this.#internalConstructor(...arguments)
     76    }
     77 }