summaryrefslogtreecommitdiffstats
path: root/intl/icu_capi/js/package/lib/ICU4XLocaleFallbackIterator.js
blob: 4540e3d7db26e04f20d35035d2f303339421acb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import wasm from "./diplomat-wasm.mjs"
import * as diplomatRuntime from "./diplomat-runtime.js"
import { ICU4XLocale } from "./ICU4XLocale.js"

const ICU4XLocaleFallbackIterator_box_destroy_registry = new FinalizationRegistry(underlying => {
  wasm.ICU4XLocaleFallbackIterator_destroy(underlying);
});

export class ICU4XLocaleFallbackIterator {
  #lifetimeEdges = [];
  constructor(underlying, owned, edges) {
    this.underlying = underlying;
    this.#lifetimeEdges.push(...edges);
    if (owned) {
      ICU4XLocaleFallbackIterator_box_destroy_registry.register(this, underlying);
    }
  }

  get() {
    return new ICU4XLocale(wasm.ICU4XLocaleFallbackIterator_get(this.underlying), true, []);
  }

  step() {
    wasm.ICU4XLocaleFallbackIterator_step(this.underlying);
  }
}