Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/intl/icu_capi/bindings/js/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 4 kB image not shown  

Quelle  PluralCategory.mjs   Sprache: unbekannt

 
Spracherkennung für: .mjs vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";



/**
 * See the [Rust documentation for `PluralCategory`](https://docs.rs/icu/2.1.1/icu/plurals/enum.PluralCategory.html) for more information.
 */
export class PluralCategory {
    #value = undefined;

    static #values = new Map([
        ["Zero", 0],
        ["One", 1],
        ["Two", 2],
        ["Few", 3],
        ["Many", 4],
        ["Other", 5]
    ]);

    static getAllEntries() {
        return PluralCategory.#values.entries();
    }

    #internalConstructor(value) {
        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
            // We pass in two internalConstructor arguments to create *new*
            // instances of this type, otherwise the enums are treated as singletons.
            if (arguments[1] === diplomatRuntime.internalConstructor ) {
                this.#value = arguments[2];
                return this;
            }
            return PluralCategory.#objectValues[arguments[1]];
        }

        if (value instanceof PluralCategory) {
            return value;
        }

        let intVal = PluralCategory.#values.get(value);

        // Nullish check, checks for null or undefined
        if (intVal != null) {
            return PluralCategory.#objectValues[intVal];
        }

        throw TypeError(value + " is not a PluralCategory and does not correspond to any of its enumerator values.");
    }

    /** @internal */
    static fromValue(value) {
        return new PluralCategory(value);
    }

    get value(){
        return [...PluralCategory.#values.keys()][this.#value];
    }

    /** @internal */
    get ffiValue(){
        return this.#value;
    }
    static #objectValues = [
        new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
        new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
        new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
        new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
        new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
        new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
    ];

    static Zero = PluralCategory.#objectValues[0];
    static One = PluralCategory.#objectValues[1];
    static Two = PluralCategory.#objectValues[2];
    static Few = PluralCategory.#objectValues[3];
    static Many = PluralCategory.#objectValues[4];
    static Other = PluralCategory.#objectValues[5];


    /**
     * Construct from a string in the format
     * [specified in TR35](https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules)
     *
     * See the [Rust documentation for `get_for_cldr_string`](https://docs.rs/icu/2.1.1/icu/plurals/enum.PluralCategory.html#method.get_for_cldr_string) for more information.
     *
     * See the [Rust documentation for `get_for_cldr_bytes`](https://docs.rs/icu/2.1.1/icu/plurals/enum.PluralCategory.html#method.get_for_cldr_bytes) for more information.
     */
    static getForCldrString(s) {
        let functionCleanupArena = new diplomatRuntime.CleanupArena();

        const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, s)));
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 54, true);


        const result = wasm.icu4x_PluralCategory_get_for_cldr_string_mv1(diplomatReceive.buffer, sSlice.ptr);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new PluralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
        }

        finally {
            functionCleanupArena.free();

            diplomatReceive.free();
        }
    }

    constructor(value) {
        return this.#internalConstructor(...arguments)
    }
}

[Dauer der Verarbeitung: 0.27 Sekunden, vorverarbeitet 2026-08-25]