gcp-metadata icon indicating copy to clipboard operation
gcp-metadata copied to clipboard

refactor!: Remove `json-bigint`

Open danielbankhead opened this issue 1 year ago • 0 comments

Remove json-bigint and @types/json-bigint.

We can use native bigints via the JSON.parse reviver parameter and essentially check via:

// JSON spec for number: https://www.json.org/json-en.html
const isInt = /^-?\d+(e(\+|\-)?\d+)?$/i.test(n);
const int = +n;

const value = Number.isSafeInteger(int) ? int : BigInt(n);

Documentation:

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/BigInt#using_bigint_to_convert_a_number_to_a_bigint
  • https://www.json.org/json-en.html

danielbankhead avatar Jun 28 '23 21:06 danielbankhead