Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const SOTRAGE_OBJ_KEYS = [
'total',
'used',
'used_other',
// 'used_reduced',
'free',
'reserved',
'unavailable_free',
'unavailable_used',
'limit',
'alloc',
'real',
];
BigInteger.PETABYTE = new BigInteger(PETABYTE);
// We are overriding BigInteger.prototype.toJSON to make sure that JSON.stringify({ size: bigint }) will behave nicely
// however BigInteger creates 3 prototypes internally (Integer, SmallInteger, BigInteger)
// and writes the 'toJSON' property explicitly for all of them, we have to overwrite all 3.
const IntegerPrototype = BigInteger.prototype;
const BigIntegerPrototype = Object.getPrototypeOf(BigInteger.PETABYTE.multiply(BigInteger.PETABYTE));
const SmallIntegerPrototype = Object.getPrototypeOf(BigInteger.zero);
IntegerPrototype.toJSON = bigint_to_json_method;
BigIntegerPrototype.toJSON = bigint_to_json_method;
SmallIntegerPrototype.toJSON = bigint_to_json_method;
/**
* @this {BigInteger}
*/
function bigint_to_json_method() {
return bigint_to_json(this);