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