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