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