• 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 `LineBreakStrictness`](https://docs.rs/icu/latest/icu/segmenter/options/enum.LineBreakStrictness.html) for more information.
7*/
8
9
10export class LineBreakStrictness {
11
12    #value = undefined;
13
14    static #values = new Map([
15        ["Loose", 0],
16        ["Normal", 1],
17        ["Strict", 2],
18        ["Anywhere", 3]
19    ]);
20
21    static getAllEntries() {
22        return LineBreakStrictness.#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 LineBreakStrictness.#objectValues[arguments[1]];
34        }
35
36        if (value instanceof LineBreakStrictness) {
37            return value;
38        }
39
40        let intVal = LineBreakStrictness.#values.get(value);
41
42        // Nullish check, checks for null or undefined
43        if (intVal != null) {
44            return LineBreakStrictness.#objectValues[intVal];
45        }
46
47        throw TypeError(value + " is not a LineBreakStrictness and does not correspond to any of its enumerator values.");
48    }
49
50    static fromValue(value) {
51        return new LineBreakStrictness(value);
52    }
53
54    get value() {
55        return [...LineBreakStrictness.#values.keys()][this.#value];
56    }
57
58    get ffiValue() {
59        return this.#value;
60    }
61    static #objectValues = [
62        new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
63        new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
64        new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
65        new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
66    ];
67
68    static Loose = LineBreakStrictness.#objectValues[0];
69    static Normal = LineBreakStrictness.#objectValues[1];
70    static Strict = LineBreakStrictness.#objectValues[2];
71    static Anywhere = LineBreakStrictness.#objectValues[3];
72
73    constructor(value) {
74        return this.#internalConstructor(...arguments)
75    }
76}