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