Giter VIP home page Giter VIP logo

read-bigint's Introduction

Read BigInt

NPM Version Node.js CI CodeQL Dependabot: enabled codecov Bundlesize Bundle Watched code style: prettier

๐Ÿ‘“๐Ÿ’ฏ Read Unsigned/Signed Big/Little-Endian BigInt from Buffer

Install

npm install read-bigint

Usage

import {
    readBigInt64BE,
    readBigInt64LE,
    readBigUInt64BE,
    readBigUInt64LE,
} from "read-bigint";

const buffer = Buffer.from([
    0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
]);

readBigInt64BE(buffer, /* offset */ 1); // => 1234605616436508552n
readBigInt64LE(buffer, /* offset */ 1); // => -8613303245920329199n
readBigUInt64BE(buffer, /* offset */ 1); // => 1234605616436508552n
readBigUInt64LE(buffer, /* offset */ 1); // => 9833440827789222417n

The purpose of this package is to be able to read native BigInt from native Buffer. This is mostly useful when targeting Node 10 (LTS Dubnium), which supports BigInt, but does not have native methods for reading BigInt from Buffer. On Node 12 or any later version of Node, you should use the native Buffer methods instead.

API

Each of the exported methods is a direct copy of the Native Buffer.readBigInt() methods.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.