Fix quantity type
Currently, the quantity type does not support multiple quantities, lists, etc on the root level.
import { XMLElement } from "../XMLElement";
import { ByteDataType } from "./ByteDataType";
import { FormulaType } from "./FormulaType";
import { ListType } from "./ListType";
import { QuantityType } from "./QuantityType";
import { TextType } from "./TextType";
import { ensureArray } from "../Util";
export class DataType extends XMLElement {
text?: TextType[];
formula?: FormulaType[];
byteData?: ByteDataType[];
xml?: unknown; // TODO: Implement XML Block
quantity?: QuantityType[];
list?: ListType[];
constructor(options: Partial<DataType> = {}) {
super(options);
if (options.text) this.text = ensureArray(options.text).map((x) => new TextType(x));
else if (options.formula) this.formula = ensureArray(options.formula).map((x) => new FormulaType(x));
else if (options.byteData) this.byteData = ensureArray(options.byteData).map((x) => new ByteDataType(x));
else if (options.xml) this.xml = options.xml;
else if (options.quantity) this.quantity = ensureArray(options.quantity).map((x) => new QuantityType(x));
else if (options.list) this.list = ensureArray(options.list).map((x) => new ListType(x));
else throw new Error("The DataType Block needs one child element");
}
}