tor-browser

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

MeasureUnit.mjs (1583B)


      1 // generated by diplomat-tool
      2 import wasm from "./diplomat-wasm.mjs";
      3 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      4 
      5 
      6 /**
      7 * An ICU4X Measurement Unit object which represents a single unit of measurement
      8 * such as `meter`, `second`, `kilometer-per-hour`, `square-meter`, etc.
      9 *
     10 * You can create an instance of this object using [`MeasureUnitParser`] by calling the `parse` method.
     11 *
     12 * See the [Rust documentation for `MeasureUnit`](https://docs.rs/icu/latest/icu/experimental/measure/measureunit/struct.MeasureUnit.html) for more information.
     13 */
     14 const MeasureUnit_box_destroy_registry = new FinalizationRegistry((ptr) => {
     15    wasm.icu4x_MeasureUnit_destroy_mv1(ptr);
     16 });
     17 
     18 export class MeasureUnit {
     19    // Internal ptr reference:
     20    #ptr = null;
     21 
     22    // Lifetimes are only to keep dependencies alive.
     23    // Since JS won't garbage collect until there are no incoming edges.
     24    #selfEdge = [];
     25 
     26    #internalConstructor(symbol, ptr, selfEdge) {
     27        if (symbol !== diplomatRuntime.internalConstructor) {
     28            console.error("MeasureUnit is an Opaque type. You cannot call its constructor.");
     29            return;
     30        }
     31        this.#ptr = ptr;
     32        this.#selfEdge = selfEdge;
     33 
     34        // Are we being borrowed? If not, we can register.
     35        if (this.#selfEdge.length === 0) {
     36            MeasureUnit_box_destroy_registry.register(this, this.#ptr);
     37        }
     38 
     39        return this;
     40    }
     41    get ffiValue() {
     42        return this.#ptr;
     43    }
     44 
     45 
     46    constructor(symbol, ptr, selfEdge) {
     47        return this.#internalConstructor(...arguments)
     48    }
     49 }