UNPKG

@qudtlib/core

Version:

Data model for QUDTLib

1 lines 1.35 kB
{"version":3,"sources":["quantityValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,aAAc,YAAW,cAAc,CAAC,aAAa,CAAC;IACjE,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;gBAEC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;IAKzC,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO;IAMtC,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,YAAY;CAM9C","file":"quantityValue.d.ts","sourcesContent":["import { SupportsEquals } from \"./baseTypes.js\";\nimport { Unit } from \"./unit.js\";\nimport { Decimal } from \"decimal.js\";\nimport { QuantityKind } from \"./quantityKind\";\n\nexport class QuantityValue implements SupportsEquals<QuantityValue> {\n value: Decimal;\n unit: Unit;\n\n constructor(quantity: Decimal, unit: Unit) {\n this.value = quantity;\n this.unit = unit;\n }\n\n equals(other?: QuantityValue): boolean {\n return (\n !!other && this.value.equals(other.value) && this.unit.equals(other.unit)\n );\n }\n\n toString(): string {\n return this.value.toString() + this.unit.toString();\n }\n\n convert(to: Unit, quantityKind?: QuantityKind) {\n return new QuantityValue(\n this.unit.convert(this.value, to, quantityKind),\n to\n );\n }\n}\n"]}