We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9311f0 commit 5292ffeCopy full SHA for 5292ffe
1 file changed
index.js
@@ -2,7 +2,23 @@
2
* @format
3
*/
4
5
-if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')
+if (typeof BigInt === 'undefined') {
6
+ const bi = require('big-integer')
7
+
8
+ // BugFix for BigInt('0xffffffffffffffff') by CBOR lib
9
+ function myBigInt(value) {
10
+ if (typeof value === 'string') {
11
+ const match = value.match(/^0([xo])([0-9a-f]+)$/i)
12
+ if (match) {
13
+ return bi(match[2], match[1].toLowerCase() === 'x' ? 16 : 8)
14
+ }
15
16
+ return bi(value)
17
18
19
+ global.BigInt = myBigInt;
20
+}
21
22
global.Buffer = global.Buffer || require('buffer').Buffer;
23
24
import process from 'process';
0 commit comments