Skip to content

Latest commit

 

History

History
51 lines (32 loc) · 1.54 KB

File metadata and controls

51 lines (32 loc) · 1.54 KB

@vekexasia/bigint-buffer-polyfill: Buffer polyfill for BigInt

This project is part of the bigint-swissknife project. It aims to monkeypatch the Buffer native class adding support for BigInts. This is useful when working with Node.js.

Documentation

You can find typedoc documentation here.

Installation

Add the library to your project:

npm install @vekexasia/bigint-buffer-polyfill

or

yarn add @vekexasia/bigint-buffer-polyfill

Usage

Simply import the library and start using it on your Buffers.

import '@vekexasia/bigint-buffer-polyfill';

const buf = Buffer.alloc(16);
buf.writeBigIntBE(-42n, 8);
buf.writeBigUIntLE(69n, 8, 8);

console.log(buf.readBigIntBE(8)); // -42n
console.log(buf.readBigUIntLE(8, 8)); // 69n

TypeScript

The library is entirely written in TypeScript and comes with its own type definitions.

License

This project is licensed under the MIT License - see the LICENSE file for details.