tor-browser

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

LineBreakWordOption.mjs (2392B)


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