WordBreakIteratorLatin1.mjs (2995B)
1 // generated by diplomat-tool 2 import { SegmenterWordType } from "./SegmenterWordType.mjs" 3 import wasm from "./diplomat-wasm.mjs"; 4 import * as diplomatRuntime from "./diplomat-runtime.mjs"; 5 6 7 /** 8 * See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/iterators/struct.WordBreakIterator.html) for more information. 9 */ 10 const WordBreakIteratorLatin1_box_destroy_registry = new FinalizationRegistry((ptr) => { 11 wasm.icu4x_WordBreakIteratorLatin1_destroy_mv1(ptr); 12 }); 13 14 export class WordBreakIteratorLatin1 { 15 // Internal ptr reference: 16 #ptr = null; 17 18 // Lifetimes are only to keep dependencies alive. 19 // Since JS won't garbage collect until there are no incoming edges. 20 #selfEdge = []; 21 #aEdge = []; 22 23 #internalConstructor(symbol, ptr, selfEdge, aEdge) { 24 if (symbol !== diplomatRuntime.internalConstructor) { 25 console.error("WordBreakIteratorLatin1 is an Opaque type. You cannot call its constructor."); 26 return; 27 } 28 this.#aEdge = aEdge; 29 this.#ptr = ptr; 30 this.#selfEdge = selfEdge; 31 32 // Are we being borrowed? If not, we can register. 33 if (this.#selfEdge.length === 0) { 34 WordBreakIteratorLatin1_box_destroy_registry.register(this, this.#ptr); 35 } 36 37 return this; 38 } 39 get ffiValue() { 40 return this.#ptr; 41 } 42 43 44 /** 45 * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is 46 * out of range of a 32-bit signed integer. 47 * 48 * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/iterators/struct.WordBreakIterator.html#method.next) for more information. 49 */ 50 next() { 51 52 const result = wasm.icu4x_WordBreakIteratorLatin1_next_mv1(this.ffiValue); 53 54 try { 55 return result; 56 } 57 58 finally { 59 } 60 } 61 62 /** 63 * Return the status value of break boundary. 64 * 65 * See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/iterators/struct.WordBreakIterator.html#method.word_type) for more information. 66 */ 67 get wordType() { 68 69 const result = wasm.icu4x_WordBreakIteratorLatin1_word_type_mv1(this.ffiValue); 70 71 try { 72 return new SegmenterWordType(diplomatRuntime.internalConstructor, result); 73 } 74 75 finally { 76 } 77 } 78 79 /** 80 * Return true when break boundary is word-like such as letter/number/CJK 81 * 82 * See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/iterators/struct.WordBreakIterator.html#method.is_word_like) for more information. 83 */ 84 get isWordLike() { 85 86 const result = wasm.icu4x_WordBreakIteratorLatin1_is_word_like_mv1(this.ffiValue); 87 88 try { 89 return result; 90 } 91 92 finally { 93 } 94 } 95 96 constructor(symbol, ptr, selfEdge, aEdge) { 97 return this.#internalConstructor(...arguments) 98 } 99 }