Call Decimal.fromValue on objects that are Decimal-like

I _already_ know I'm going to update b_e.js without remembering I made
this change. If you've noticed that has occurred please link me to this
commit and shame me.
This commit is contained in:
thepaperpilot 2022-02-20 16:01:27 -06:00
parent 067ba6ce90
commit ebf26c58e7

View file

@ -507,7 +507,7 @@ export default class Decimal {
public layer: number = Number.NaN; public layer: number = Number.NaN;
constructor(value?: DecimalSource) { constructor(value?: DecimalSource) {
if (value instanceof Decimal) { if (value instanceof Decimal || (value != null && typeof value === "object" && "sign" in value && "mag" in value && "layer" in value)) {
this.fromDecimal(value); this.fromDecimal(value);
} else if (typeof value === "number") { } else if (typeof value === "number") {
this.fromNumber(value); this.fromNumber(value);
@ -1556,7 +1556,7 @@ export default class Decimal {
} }
public fromValue(value: DecimalSource): Decimal { public fromValue(value: DecimalSource): Decimal {
if (value instanceof Decimal) { if (value instanceof Decimal || (value != null && typeof value === "object" && "sign" in value && "mag" in value && "layer" in value)) {
return this.fromDecimal(value); return this.fromDecimal(value);
} }