-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
next major: breaking changethis is a change that we should wait to bundle into the next major versionthis is a change that we should wait to bundle into the next major versionpriority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.semver: majorHint for users that this is an API breaking change.Hint for users that this is an API breaking change.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
Remove json-bigint and @types/json-bigint.
We can use native bigints via the JSON.parse reviver parameter and essentially check via:
const jsonParse = (stringified: string) => JSON.parse(stringified, (key, value, context) => {
if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
// Use the context for the appropriate precision
return BigInt(context.source);
}
return value;
});Example:
const bigJSON = '{"largeNumber": 12345678901234567890, "a": {"b": 1, "c": 893081290390128309213821903 }}';
const res = jsonParse(bigJSON);
// res:
// {
// largeNumber: 12345678901234567890n,
// a: { b: 1, c: 893081290390128309213821903n }
// }Improves on:
- fix: properly handle large numbers in responses gcp-metadata#74
- fix: ask gaxios for text and not json gcp-metadata#152
Documentation:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
next major: breaking changethis is a change that we should wait to bundle into the next major versionthis is a change that we should wait to bundle into the next major versionpriority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.semver: majorHint for users that this is an API breaking change.Hint for users that this is an API breaking change.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.