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

const ICU4XLocaleFallbackerWithConfig_box_destroy_registry = new FinalizationRegistry(underlying => {
  wasm.ICU4XLocaleFallbackerWithConfig_destroy(underlying);
});

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

  fallback_for_locale(arg_locale) {
    return new ICU4XLocaleFallbackIterator(wasm.ICU4XLocaleFallbackerWithConfig_fallback_for_locale(this.underlying, arg_locale.underlying), true, [this]);
  }
}