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