googleapis / googleapis/google-cloud-node

refactor!: Remove `json-bigint`

Aperta
#7,741 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
library: google-cloud-node-core next major: breaking change priority: p3 semver: major type: feature request
Lingua principale
TypeScript
Stelle
3.2k
Fork
712
Merge medio
2g 9h
PR unite (30g)
104

Descrizione

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

We can use native `bigint`s via the JSON.parse [reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) parameter and essentially check via:

```ts
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:
```js
const bigJSON = '{"largeNumber": 12345678901234567890, "a": {"b": 1, "c": 893081290390128309213821903 }}';
const res = jsonParse(bigJSON);

// res:
// {
// largeNumber: 12345678901234567890n,
// a: { b: 1, c: 893081290390128309213821903n }
// }

```

Improves on:
- https://github.com/googleapis/gcp-metadata/pull/74
- https://github.com/googleapis/gcp-metadata/pull/152

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by searching the repository for imports and package declarations for `json-bigint` and `@types/json-bigint`, then identify the JSON parsing entry points that depend on them. Replace those uses with the native JSON.parse reviver approach described in the issue, remove both dependencies, and run the affected tests or repository checks to confirm large integers remain precise.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
node.js, typescript
Ambito
backend, developer-experience
Tipo di issue
Refactoring
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.