Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XList.mjs

raw
1 import wasm from "./diplomat-wasm.mjs"
2 import * as diplomatRuntime from "./diplomat-runtime.mjs"
3
4 const ICU4XList_box_destroy_registry = new FinalizationRegistry(underlying => {
5 wasm.ICU4XList_destroy(underlying);
6 });
7
8 export class ICU4XList {
9 #lifetimeEdges = [];
10 constructor(underlying, owned, edges) {
11 this.underlying = underlying;
12 this.#lifetimeEdges.push(...edges);
13 if (owned) {
14 ICU4XList_box_destroy_registry.register(this, underlying);
15 }
16 }
17
18 static create() {
19 return new ICU4XList(wasm.ICU4XList_create(), true, []);
20 }
21
22 static create_with_capacity(arg_capacity) {
23 return new ICU4XList(wasm.ICU4XList_create_with_capacity(arg_capacity), true, []);
24 }
25
26 push(arg_val) {
27 const buf_arg_val = diplomatRuntime.DiplomatBuf.str8(wasm, arg_val);
28 wasm.ICU4XList_push(this.underlying, buf_arg_val.ptr, buf_arg_val.size);
29 buf_arg_val.free();
30 }
31
32 len() {
33 return wasm.ICU4XList_len(this.underlying);
34 }
35
36 is_empty() {
37 return wasm.ICU4XList_is_empty(this.underlying);
38 }
39 }