| // generated by diplomat-tool |
| import wasm from "./diplomat-wasm.mjs"; |
| import * as diplomatRuntime from "./diplomat-runtime.mjs"; |
| |
| |
| /** See the [Rust documentation for `RelativeUnit`](https://docs.rs/icu/latest/icu/calendar/week/enum.RelativeUnit.html) for more information. |
| */ |
| |
| |
| export class WeekRelativeUnit { |
| |
| #value = undefined; |
| |
| static #values = new Map([ |
| ["Previous", 0], |
| ["Current", 1], |
| ["Next", 2] |
| ]); |
| |
| static getAllEntries() { |
| return WeekRelativeUnit.#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 WeekRelativeUnit.#objectValues[arguments[1]]; |
| } |
| |
| if (value instanceof WeekRelativeUnit) { |
| return value; |
| } |
| |
| let intVal = WeekRelativeUnit.#values.get(value); |
| |
| // Nullish check, checks for null or undefined |
| if (intVal != null) { |
| return WeekRelativeUnit.#objectValues[intVal]; |
| } |
| |
| throw TypeError(value + " is not a WeekRelativeUnit and does not correspond to any of its enumerator values."); |
| } |
| |
| static fromValue(value) { |
| return new WeekRelativeUnit(value); |
| } |
| |
| get value() { |
| return [...WeekRelativeUnit.#values.keys()][this.#value]; |
| } |
| |
| get ffiValue() { |
| return this.#value; |
| } |
| static #objectValues = [ |
| new WeekRelativeUnit(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), |
| new WeekRelativeUnit(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), |
| new WeekRelativeUnit(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), |
| ]; |
| |
| static Previous = WeekRelativeUnit.#objectValues[0]; |
| static Current = WeekRelativeUnit.#objectValues[1]; |
| static Next = WeekRelativeUnit.#objectValues[2]; |
| |
| constructor(value) { |
| return this.#internalConstructor(...arguments) |
| } |
| } |