1// generated by diplomat-tool 2import wasm from "./diplomat-wasm.mjs"; 3import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6/** ECMA-402 compatible sign display preference. 7* 8*See the [Rust documentation for `SignDisplay`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.SignDisplay.html) for more information. 9*/ 10 11 12export class FixedDecimalSignDisplay { 13 14 #value = undefined; 15 16 static #values = new Map([ 17 ["Auto", 0], 18 ["Never", 1], 19 ["Always", 2], 20 ["ExceptZero", 3], 21 ["Negative", 4] 22 ]); 23 24 static getAllEntries() { 25 return FixedDecimalSignDisplay.#values.entries(); 26 } 27 28 #internalConstructor(value) { 29 if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { 30 // We pass in two internalConstructor arguments to create *new* 31 // instances of this type, otherwise the enums are treated as singletons. 32 if (arguments[1] === diplomatRuntime.internalConstructor ) { 33 this.#value = arguments[2]; 34 return this; 35 } 36 return FixedDecimalSignDisplay.#objectValues[arguments[1]]; 37 } 38 39 if (value instanceof FixedDecimalSignDisplay) { 40 return value; 41 } 42 43 let intVal = FixedDecimalSignDisplay.#values.get(value); 44 45 // Nullish check, checks for null or undefined 46 if (intVal != null) { 47 return FixedDecimalSignDisplay.#objectValues[intVal]; 48 } 49 50 throw TypeError(value + " is not a FixedDecimalSignDisplay and does not correspond to any of its enumerator values."); 51 } 52 53 static fromValue(value) { 54 return new FixedDecimalSignDisplay(value); 55 } 56 57 get value() { 58 return [...FixedDecimalSignDisplay.#values.keys()][this.#value]; 59 } 60 61 get ffiValue() { 62 return this.#value; 63 } 64 static #objectValues = [ 65 new FixedDecimalSignDisplay(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), 66 new FixedDecimalSignDisplay(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), 67 new FixedDecimalSignDisplay(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), 68 new FixedDecimalSignDisplay(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), 69 new FixedDecimalSignDisplay(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), 70 ]; 71 72 static Auto = FixedDecimalSignDisplay.#objectValues[0]; 73 static Never = FixedDecimalSignDisplay.#objectValues[1]; 74 static Always = FixedDecimalSignDisplay.#objectValues[2]; 75 static ExceptZero = FixedDecimalSignDisplay.#objectValues[3]; 76 static Negative = FixedDecimalSignDisplay.#objectValues[4]; 77 78 constructor(value) { 79 return this.#internalConstructor(...arguments) 80 } 81}