gcp-metadata
gcp-metadata copied to clipboard
refactor!: Remove `json-bigint`
Remove json-bigint
and @types/json-bigint
.
We can use native bigint
s 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