tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TimeZoneIterator.mjs (2008B)


      1 // generated by diplomat-tool
      2 import { TimeZone } from "./TimeZone.mjs"
      3 import wasm from "./diplomat-wasm.mjs";
      4 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      5 
      6 
      7 /**
      8 * See the [Rust documentation for `TimeZoneIter`](https://docs.rs/icu/latest/icu/time/zone/iana/struct.TimeZoneIter.html) for more information.
      9 */
     10 const TimeZoneIterator_box_destroy_registry = new FinalizationRegistry((ptr) => {
     11    wasm.icu4x_TimeZoneIterator_destroy_mv1(ptr);
     12 });
     13 
     14 export class TimeZoneIterator {
     15    // Internal ptr reference:
     16    #ptr = null;
     17 
     18    // Lifetimes are only to keep dependencies alive.
     19    // Since JS won't garbage collect until there are no incoming edges.
     20    #selfEdge = [];
     21    #aEdge = [];
     22 
     23    #internalConstructor(symbol, ptr, selfEdge, aEdge) {
     24        if (symbol !== diplomatRuntime.internalConstructor) {
     25            console.error("TimeZoneIterator is an Opaque type. You cannot call its constructor.");
     26            return;
     27        }
     28        this.#aEdge = aEdge;
     29        this.#ptr = ptr;
     30        this.#selfEdge = selfEdge;
     31 
     32        // Are we being borrowed? If not, we can register.
     33        if (this.#selfEdge.length === 0) {
     34            TimeZoneIterator_box_destroy_registry.register(this, this.#ptr);
     35        }
     36 
     37        return this;
     38    }
     39    get ffiValue() {
     40        return this.#ptr;
     41    }
     42 
     43 
     44    /**
     45     * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/time/zone/iana/struct.TimeZoneIter.html#method.next) for more information.
     46     */
     47    #iteratorNext() {
     48 
     49        const result = wasm.icu4x_TimeZoneIterator_next_mv1(this.ffiValue);
     50 
     51        try {
     52            return result === 0 ? null : new TimeZone(diplomatRuntime.internalConstructor, result, []);
     53        }
     54 
     55        finally {
     56        }
     57    }
     58 
     59    next(){
     60        const out = this.#iteratorNext();
     61 
     62        return {
     63            value: out,
     64            done: out === null,
     65        };
     66    }
     67 
     68    constructor(symbol, ptr, selfEdge, aEdge) {
     69        return this.#internalConstructor(...arguments)
     70    }
     71 }