node-int64
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Node-int64 is a popular npm package that provides support for representing 64-bit integers in JavaScript. In JavaScript, Numbers are generally represented as IEEE 754 double-precision floats, which unfortunately means they lose integer precision for values beyond +/- 2^53. This becomes a problem for projects that need to accurately handle 64-bit ints. Hence, a performant, Number-like class is needed, and Node-int64 fulfills that need. Vectoring as a support module for projects like node-thrift, Node-int64 provides a highly performant, Number-like class enabling accurate calculations and data representation.
In order to use Node-int64 in your JavaScript code, you need to install it through npm and then require
it in your project file. Once it has been imported, you can create new instances of Int64. Here are some code examples to illustrate:
// Node-int64 is required in the project
var Int64 = require('node-int64')
// New Int64 instances can be created like this:
var x = new Int64(0x123456789)
var y = new Int64('123456789abcdef0')
// You can also create Int64s by passing hi/lo words, a Buffer, and a Buffer with an offset:
new Int64(0x12345678, 0x9abcdef0)
new Int64(new Buffer([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]))
new Int64(new Buffer([0,0,0,0,0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]), 4)
These instances behave like JavaScript-native Numbers in many ways, and you can perform certain operations on them. Keep in mind, however, that Node-int64 is suited for carrying around int64 values, not for doing 64-bit integer arithmetic.
Detailed documentation for Node-int64 can be found in the README file at the project's GitHub page. This file contains comprehensive information about the package's functionality and gives concrete examples of its utilization in JavaScript.