npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

int64-node

v1.0.5

Published

Support for representing 64-bit integers in JavaScript

Downloads

23

Readme

int64-node

int64-node is a JavaScript library that provides support for handling 64-bit integer numbers in Node.js. JavaScript's native Numbers are represented as IEEE 754 double-precision floats, which limits the range of values that can be accurately represented to ±2^53. For projects requiring precise 64-bit integer handling, such as node-thrift, int64-node comes to the rescue.

Table of Contents

Installation

You can install int64-node via npm:

npm install int64-node

Usage

Creating Int64 Instances

// Require the int64-node module
const Int64 = require('int64-node');

// Create Int64 instances
const int1 = new Int64(0x12345678, 0x9abcdef0);
const int2 = new Int64('123456789abcdef0');

Performing Arithmetic Operations

// Perform arithmetic operations
const result1 = int1 + 1; // 4886718346
const result2 = int2 + 1; // Infinity

Converting to Different Representations

// Convert to different representations
const octetString1 = int1.toOctetString(); // '0000000123456789'
const octetString2 = int2.toOctetString(); // '123456789abcdef0'
const binaryString1 = int1.toString(2); // '100100011010001010110011110001001'
const binaryString2 = int2.toString(2); // 'Infinity'

Checking Integer Precision

// Check if the value is within integer-precise range
const isInt1Finite = isFinite(int1); // true
const isInt2Finite = isFinite(int2); // false

Copying to a Buffer

// Copy to a buffer
const buffer1 = int1.toBuffer(); // <Buffer 12 34 56 78 9a bc de f0>
const buffer2 = new Buffer(16);
int2.copy(buffer2, 0); // Copies the Int64 value to the buffer

Creating Int64 Instances from a Buffer

// Create Int64 instances from a Buffer
const intFromBuffer = new Int64(new Buffer([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]));

// Create Int64 instances from a Buffer with an offset
const intFromOffset = new Int64(new Buffer([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]), 4);

License

int64-node is licensed under the MIT License. See LICENSE for details.

Contributing

Interested in contributing? Please read our Contributing Guidelines for more information.

Learning

Explore our Learning Resources to get started with int64-node.

Code of Conduct

Please follow our Code of Conduct to ensure a welcoming and inclusive community.

Developer Details

Happy Coding 🚀