Source code
Revision control
Copy as Markdown
Other Tools
// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";
/**
* Priority mode for the ICU4X fallback algorithm.
*
* See the [Rust documentation for `LocaleFallbackPriority`](https://docs.rs/icu/latest/icu/locale/fallback/enum.LocaleFallbackPriority.html) for more information.
*/
export class LocaleFallbackPriority {
#value = undefined;
static #values = new Map([
["Language", 0],
["Region", 1]
]);
static getAllEntries() {
return LocaleFallbackPriority.#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 LocaleFallbackPriority.#objectValues[arguments[1]];
}
if (value instanceof LocaleFallbackPriority) {
return value;
}
let intVal = LocaleFallbackPriority.#values.get(value);
// Nullish check, checks for null or undefined
if (intVal != null) {
return LocaleFallbackPriority.#objectValues[intVal];
}
throw TypeError(value + " is not a LocaleFallbackPriority and does not correspond to any of its enumerator values.");
}
static fromValue(value) {
return new LocaleFallbackPriority(value);
}
get value(){
return [...LocaleFallbackPriority.#values.keys()][this.#value];
}
get ffiValue(){
return this.#value;
}
static #objectValues = [
new LocaleFallbackPriority(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
new LocaleFallbackPriority(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
];
static Language = LocaleFallbackPriority.#objectValues[0];
static Region = LocaleFallbackPriority.#objectValues[1];
constructor(value) {
return this.#internalConstructor(...arguments)
}
}