| // generated by diplomat-tool |
| import wasm from "./diplomat-wasm.mjs"; |
| import * as diplomatRuntime from "./diplomat-runtime.mjs"; |
| |
| |
| /** See the [Rust documentation for `Style`](https://docs.rs/icu/latest/icu/displaynames/options/enum.Style.html) for more information. |
| */ |
| |
| |
| export class DisplayNamesStyle { |
| |
| #value = undefined; |
| |
| static #values = new Map([ |
| ["Narrow", 0], |
| ["Short", 1], |
| ["Long", 2], |
| ["Menu", 3] |
| ]); |
| |
| static getAllEntries() { |
| return DisplayNamesStyle.#values.entries(); |
| } |
| |
| #internalConstructor(value) { |
| if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { |
| // We pass in two internalConstructor arguments to create *new* |
| // instances of this type, otherwise the enums are treated as singletons. |
| if (arguments[1] === diplomatRuntime.internalConstructor ) { |
| this.#value = arguments[2]; |
| return this; |
| } |
| return DisplayNamesStyle.#objectValues[arguments[1]]; |
| } |
| |
| if (value instanceof DisplayNamesStyle) { |
| return value; |
| } |
| |
| let intVal = DisplayNamesStyle.#values.get(value); |
| |
| // Nullish check, checks for null or undefined |
| if (intVal != null) { |
| return DisplayNamesStyle.#objectValues[intVal]; |
| } |
| |
| throw TypeError(value + " is not a DisplayNamesStyle and does not correspond to any of its enumerator values."); |
| } |
| |
| static fromValue(value) { |
| return new DisplayNamesStyle(value); |
| } |
| |
| get value() { |
| return [...DisplayNamesStyle.#values.keys()][this.#value]; |
| } |
| |
| get ffiValue() { |
| return this.#value; |
| } |
| static #objectValues = [ |
| new DisplayNamesStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), |
| new DisplayNamesStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), |
| new DisplayNamesStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), |
| new DisplayNamesStyle(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), |
| ]; |
| |
| static Narrow = DisplayNamesStyle.#objectValues[0]; |
| static Short = DisplayNamesStyle.#objectValues[1]; |
| static Long = DisplayNamesStyle.#objectValues[2]; |
| static Menu = DisplayNamesStyle.#objectValues[3]; |
| |
| constructor(value) { |
| return this.#internalConstructor(...arguments) |
| } |
| } |