tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SentenceBreakIteratorUtf16.mjs (1978B)


      1 // generated by diplomat-tool
      2 import wasm from "./diplomat-wasm.mjs";
      3 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      4 
      5 
      6 /**
      7 * See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/iterators/struct.SentenceBreakIterator.html) for more information.
      8 */
      9 const SentenceBreakIteratorUtf16_box_destroy_registry = new FinalizationRegistry((ptr) => {
     10    wasm.icu4x_SentenceBreakIteratorUtf16_destroy_mv1(ptr);
     11 });
     12 
     13 export class SentenceBreakIteratorUtf16 {
     14    // Internal ptr reference:
     15    #ptr = null;
     16 
     17    // Lifetimes are only to keep dependencies alive.
     18    // Since JS won't garbage collect until there are no incoming edges.
     19    #selfEdge = [];
     20    #aEdge = [];
     21 
     22    #internalConstructor(symbol, ptr, selfEdge, aEdge) {
     23        if (symbol !== diplomatRuntime.internalConstructor) {
     24            console.error("SentenceBreakIteratorUtf16 is an Opaque type. You cannot call its constructor.");
     25            return;
     26        }
     27        this.#aEdge = aEdge;
     28        this.#ptr = ptr;
     29        this.#selfEdge = selfEdge;
     30 
     31        // Are we being borrowed? If not, we can register.
     32        if (this.#selfEdge.length === 0) {
     33            SentenceBreakIteratorUtf16_box_destroy_registry.register(this, this.#ptr);
     34        }
     35 
     36        return this;
     37    }
     38    get ffiValue() {
     39        return this.#ptr;
     40    }
     41 
     42 
     43    /**
     44     * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
     45     * out of range of a 32-bit signed integer.
     46     *
     47     * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/iterators/struct.SentenceBreakIterator.html#method.next) for more information.
     48     */
     49    next() {
     50 
     51        const result = wasm.icu4x_SentenceBreakIteratorUtf16_next_mv1(this.ffiValue);
     52 
     53        try {
     54            return result;
     55        }
     56 
     57        finally {
     58        }
     59    }
     60 
     61    constructor(symbol, ptr, selfEdge, aEdge) {
     62        return this.#internalConstructor(...arguments)
     63    }
     64 }