mmdb-lib 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/decoder.js +5 -8
  2. package/package.json +1 -1
package/lib/decoder.js CHANGED
@@ -226,7 +226,7 @@ class Decoder {
226
226
  return this.db.readUIntBE(offset, size);
227
227
  }
228
228
  if (size == 8) {
229
- return this.db.readBigInt64BE(offset).toString();
229
+ return this.db.readBigUInt64BE(offset).toString();
230
230
  }
231
231
  if (size > 16) {
232
232
  return 0;
@@ -237,13 +237,10 @@ class Decoder {
237
237
  return this.db.toString('utf8', offset, offset + size);
238
238
  }
239
239
  decodeBigUint(offset, size) {
240
- const buffer = Buffer.alloc(size);
241
- this.db.copy(buffer, 0, offset, offset + size);
242
- let integer = BigInt(0);
243
- const numberOfLongs = size / 4;
244
- for (let i = 0; i < numberOfLongs; i++) {
245
- integer =
246
- integer * BigInt(4294967296) + BigInt(buffer.readUInt32BE(i << 2));
240
+ let integer = 0n;
241
+ for (let i = 0; i < size; i++) {
242
+ integer <<= 8n;
243
+ integer |= BigInt(this.db.readUInt8(offset + i));
247
244
  }
248
245
  return integer.toString();
249
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mmdb-lib",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "homepage": "https://github.com/runk/mmdb-lib",
5
5
  "description": "Maxmind DB (MMDB) Library",
6
6
  "keywords": [