1// generated by diplomat-tool 2import wasm from "./diplomat-wasm.mjs"; 3import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6/** An ICU4X Measurement Unit object which represents a single unit of measurement 7*such as `meter`, `second`, `kilometer-per-hour`, `square-meter`, etc. 8* 9*You can create an instance of this object using [`MeasureUnitParser`] by calling the `parse_measure_unit` method. 10* 11*See the [Rust documentation for `MeasureUnit`](https://docs.rs/icu/latest/icu/experimental/measure/measureunit/struct.MeasureUnit.html) for more information. 12*/ 13const MeasureUnit_box_destroy_registry = new FinalizationRegistry((ptr) => { 14 wasm.icu4x_MeasureUnit_destroy_mv1(ptr); 15}); 16 17export class MeasureUnit { 18 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 32 this.#ptr = ptr; 33 this.#selfEdge = selfEdge; 34 35 // Are we being borrowed? If not, we can register. 36 if (this.#selfEdge.length === 0) { 37 MeasureUnit_box_destroy_registry.register(this, this.#ptr); 38 } 39 40 return this; 41 } 42 get ffiValue() { 43 return this.#ptr; 44 } 45 46 constructor(symbol, ptr, selfEdge) { 47 return this.#internalConstructor(...arguments) 48 } 49}