stellar / js-stellar-base

The lowest-level stellar helper library. It consists of classes to read, write, hash, and sign Stellar xdr
https://stellar.github.io/js-stellar-base/
Apache License 2.0
106 stars 138 forks source link

Should we not modify the settings of the default BigNumber instance? #727

Closed overcat closed 7 months ago

overcat commented 7 months ago

Describe the bug See https://gist.github.com/Shaptic/5ce4f16d9cce7118f391fbde398c2f30?permalink_comment_id=4873892#gistcomment-4873892

What version are you on? v10.0.2

To Reproduce N/A

Expected behavior Wouldn't it be better if we could not affect the settings of the default instance?

import {BigNumber} from "bignumber.js";

const SDKBigNumber = BigNumber.clone()
SDKBigNumber.DEBUG = true
try {
    new SDKBigNumber("invalid")
} catch (e) {
    console.log("error")
}

// This will not affect the settings of the default instance, so no exception here.
console.log(new BigNumber("invalid"))

Additional context N/A