blob: 87da0d3a05b513d907d7c4689b5ae901bcd3e64b [file] [log] [blame]
// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";
/** See the [Rust documentation for `LineBreakStrictness`](https://docs.rs/icu/latest/icu/segmenter/options/enum.LineBreakStrictness.html) for more information.
*/
export class LineBreakStrictness {
#value = undefined;
static #values = new Map([
["Loose", 0],
["Normal", 1],
["Strict", 2],
["Anywhere", 3]
]);
static getAllEntries() {
return LineBreakStrictness.#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 LineBreakStrictness.#objectValues[arguments[1]];
}
if (value instanceof LineBreakStrictness) {
return value;
}
let intVal = LineBreakStrictness.#values.get(value);
// Nullish check, checks for null or undefined
if (intVal != null) {
return LineBreakStrictness.#objectValues[intVal];
}
throw TypeError(value + " is not a LineBreakStrictness and does not correspond to any of its enumerator values.");
}
static fromValue(value) {
return new LineBreakStrictness(value);
}
get value() {
return [...LineBreakStrictness.#values.keys()][this.#value];
}
get ffiValue() {
return this.#value;
}
static #objectValues = [
new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
new LineBreakStrictness(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
];
static Loose = LineBreakStrictness.#objectValues[0];
static Normal = LineBreakStrictness.#objectValues[1];
static Strict = LineBreakStrictness.#objectValues[2];
static Anywhere = LineBreakStrictness.#objectValues[3];
constructor(value) {
return this.#internalConstructor(...arguments)
}
}