blob: 6de1bdfc174216c6542959329b3a2f9d7c4cbb9e [file] [log] [blame]
// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";
/** An ICU4X Measurement Unit object which represents a single unit of measurement
*such as `meter`, `second`, `kilometer-per-hour`, `square-meter`, etc.
*
*You can create an instance of this object using [`MeasureUnitParser`] by calling the `parse_measure_unit` method.
*
*See the [Rust documentation for `MeasureUnit`](https://docs.rs/icu/latest/icu/experimental/measure/measureunit/struct.MeasureUnit.html) for more information.
*/
const MeasureUnit_box_destroy_registry = new FinalizationRegistry((ptr) => {
wasm.icu4x_MeasureUnit_destroy_mv1(ptr);
});
export class MeasureUnit {
// Internal ptr reference:
#ptr = null;
// Lifetimes are only to keep dependencies alive.
// Since JS won't garbage collect until there are no incoming edges.
#selfEdge = [];
#internalConstructor(symbol, ptr, selfEdge) {
if (symbol !== diplomatRuntime.internalConstructor) {
console.error("MeasureUnit is an Opaque type. You cannot call its constructor.");
return;
}
this.#ptr = ptr;
this.#selfEdge = selfEdge;
// Are we being borrowed? If not, we can register.
if (this.#selfEdge.length === 0) {
MeasureUnit_box_destroy_registry.register(this, this.#ptr);
}
return this;
}
get ffiValue() {
return this.#ptr;
}
constructor(symbol, ptr, selfEdge) {
return this.#internalConstructor(...arguments)
}
}