I am trying to override mathjs Bignumber using:
import * as math from 'mathjs';
export const bgn = (v: number | math.BigNumber) => {
const z = math.bignumber(v) as math.BigNumber;
(z as any).toJSON = () => {
return Number(math.larger(100, z) ? math.round(z,2) : math.round(z,4)).toFixed(4);
}
return z;
}
but for some reason, it's still stringifying it to:
{"mathjs":"BigNumber","value":"42500"}
my goal is to stringify it to a number:
42500