@vekexasia/bigint-buffer-polyfill
v1.0.0
Published
A library to convert bigint to and from buffers with Buffer polyfills and support for uint/int
Downloads
17
Readme
@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-polyfillor
yarn add @vekexasia/bigint-buffer-polyfillUsage
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)); // 69nTypeScript
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.
