• 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/** See the [Rust documentation for `GroupingStrategy`](https://docs.rs/icu/latest/icu/decimal/options/enum.GroupingStrategy.html) for more information.
7*/
8
9
10export class DecimalGroupingStrategy {
11
12    #value = undefined;
13
14    static #values = new Map([
15        ["Auto", 0],
16        ["Never", 1],
17        ["Always", 2],
18        ["Min2", 3]
19    ]);
20
21    static getAllEntries() {
22        return DecimalGroupingStrategy.#values.entries();
23    }
24
25    #internalConstructor(value) {
26        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
27            // We pass in two internalConstructor arguments to create *new*
28            // instances of this type, otherwise the enums are treated as singletons.
29            if (arguments[1] === diplomatRuntime.internalConstructor ) {
30                this.#value = arguments[2];
31                return this;
32            }
33            return DecimalGroupingStrategy.#objectValues[arguments[1]];
34        }
35
36        if (value instanceof DecimalGroupingStrategy) {
37            return value;
38        }
39
40        let intVal = DecimalGroupingStrategy.#values.get(value);
41
42        // Nullish check, checks for null or undefined
43        if (intVal != null) {
44            return DecimalGroupingStrategy.#objectValues[intVal];
45        }
46
47        throw TypeError(value + " is not a DecimalGroupingStrategy and does not correspond to any of its enumerator values.");
48    }
49
50    static fromValue(value) {
51        return new DecimalGroupingStrategy(value);
52    }
53
54    get value() {
55        return [...DecimalGroupingStrategy.#values.keys()][this.#value];
56    }
57
58    get ffiValue() {
59        return this.#value;
60    }
61    static #objectValues = [
62        new DecimalGroupingStrategy(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
63        new DecimalGroupingStrategy(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
64        new DecimalGroupingStrategy(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
65        new DecimalGroupingStrategy(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
66    ];
67
68    static Auto = DecimalGroupingStrategy.#objectValues[0];
69    static Never = DecimalGroupingStrategy.#objectValues[1];
70    static Always = DecimalGroupingStrategy.#objectValues[2];
71    static Min2 = DecimalGroupingStrategy.#objectValues[3];
72
73    constructor(value) {
74        return this.#internalConstructor(...arguments)
75    }
76}