Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

int64-buffer

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

int64-buffer

64bit Long Integer on Buffer/Array/ArrayBuffer in Pure JavaScript

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3M
decreased by-6.58%
Maintainers
0
Weekly downloads
 
Created

What is int64-buffer?

The int64-buffer npm package provides utilities for handling 64-bit integers in JavaScript. It allows you to create, manipulate, and convert 64-bit integers, which are not natively supported by JavaScript's number type.

What are int64-buffer's main functionalities?

Creating Int64 and Uint64 instances

This feature allows you to create instances of 64-bit signed and unsigned integers using high and low 32-bit parts.

const Int64 = require('int64-buffer').Int64;
const Uint64 = require('int64-buffer').Uint64;

const int64 = new Int64(0x12345678, 0x9abcdef0);
const uint64 = new Uint64(0x12345678, 0x9abcdef0);

console.log(int64.toString()); // '1311768467463790320'
console.log(uint64.toString()); // '1311768467463790320'

Converting between different formats

This feature allows you to convert 64-bit integers to different formats such as Buffer, hexadecimal string, and JavaScript number.

const Int64 = require('int64-buffer').Int64;

const int64 = new Int64(0x12345678, 0x9abcdef0);

const buffer = int64.toBuffer();
const hexString = int64.toString(16);
const number = int64.toNumber();

console.log(buffer); // <Buffer 12 34 56 78 9a bc de f0>
console.log(hexString); // '123456789abcdef0'
console.log(number); // 1311768467463790320

Reading and writing from/to Buffers

This feature allows you to read 64-bit integers from Buffers and write 64-bit integers to Buffers.

const Int64 = require('int64-buffer').Int64;

const buffer = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]);
const int64 = new Int64(buffer);

console.log(int64.toString()); // '1311768467463790320'

const newBuffer = Buffer.alloc(8);
int64.toBuffer().copy(newBuffer);

console.log(newBuffer); // <Buffer 12 34 56 78 9a bc de f0>

Other packages similar to int64-buffer

Keywords

FAQs

Package last updated on 15 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc