{"library":"node-int64","title":"64-bit Integer Representation for JavaScript","description":"The `node-int64` library provides a class, `Int64`, to precisely represent 64-bit integers in JavaScript, addressing the inherent limitation of JavaScript's IEEE 754 double-precision floats which lose integer precision beyond +/- 2^53. It is currently at version 0.4.0, which was published 11 years ago, and the project is not actively maintained, with its author noting that native `BigInt`s will likely obsolete it. The library aims to provide a Number-like object primarily for carrying 64-bit integer values, such as those encountered in binary data formats like Apache Thrift, rather than for performing 64-bit integer arithmetic. While instances can be coerced to JavaScript numbers for basic operations, values exceeding the safe integer range will resolve to `Infinity`. Its primary utility lies in preserving the exact 64-bit binary representation, which can be extracted as an octet string or Node.js `Buffer`. This makes it suitable for interoperability with systems requiring precise 64-bit data types, distinguishing it from libraries focused on arbitrary-precision arithmetic.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install node-int64"],"cli":null},"imports":["const Int64 = require('node-int64');","const myInt = new Int64('123456789abcdef0');","import Int64 = require('node-int64');\n// or\n/// <reference types=\"node-int64\" />"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const Int64 = require('node-int64');\n\n// Create an Int64 from a JavaScript number (up to 2^53 precision)\nconst smallInt = new Int64(0x123456789);\nconsole.log(`Small Int: ${smallInt.toString(16)} (value: ${smallInt.valueOf()})`);\n\n// Create an Int64 from a hexadecimal string for full 64-bit precision\nconst bigHex = '123456789abcdef0';\nconst largeInt = new Int64(bigHex);\nconsole.log(`Large Int (hex): ${largeInt.toOctetString()} (value: ${largeInt.valueOf()})`);\n\n// Create an Int64 from a Node.js Buffer\nconst buffer = Buffer.from([0xDE, 0xAD, 0xBE, 0xEF, 0x01, 0x02, 0x03, 0x04]);\nconst intFromBuffer = new Int64(buffer);\nconsole.log(`From Buffer: ${intFromBuffer.toOctetString()} (value: ${intFromBuffer.valueOf()})`);\n\n// Extract the 64-bit value into a Buffer\nconst outputBuffer = intFromBuffer.toBuffer();\nconsole.log(`To Buffer: ${outputBuffer.toString('hex')}`);\n\n// Check if the internal value is within JS safe integer range\nconsole.log(`Is smallInt finite (JS precision): ${isFinite(smallInt)}`);\nconsole.log(`Is largeInt finite (JS precision): ${isFinite(largeInt)}`);","lang":"javascript","description":"Demonstrates creating `Int64` instances from various inputs (number, hex string, Buffer) and basic output operations like `toOctetString` and `toBuffer`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}