Installation
``
npm install uint128
`
Usage
`
js
const { Int128, UInt128 } = require('uint128');
const encodedUInt128 = UInt128.encodeBE(1000000000000000000000000000000n);
console.log(encodedUInt128, UInt128.decodeBE(encodedUInt128))
const encodedInt128 = Int128.encodeBE(-1000000000000000000000000000000n);
console.log(encodedInt128, Int128.decodeBE(encodedInt128))
``
Classes
Int128
$3
Encodes a 128 bit integer as Big Endian Buffer.
| Param | Type | Description |
| ------ | ------------------- | ----------------- |
| int |
BigInt | Integer to encode |
$3
Decodes a Big Endian Buffer into a 128 bit integer
| Param | Type | Description |
| ------ | -------------------- | ------------------- |
| buffer |
Buffer | Buffer to decode |
| offset |
Integer | Offset to decode at |
$3
Encodes a 128 bit integer as Little Endian Buffer.
| Param | Type | Description |
| ------ | ------------------- | ----------------- |
| int |
BigInt | Integer to encode |
$3
Decodes a Little Endian Buffer into a 128 bit integer
| Param | Type | Description |
| ------ | -------------------- | ------------------- |
| buffer |
Buffer | Buffer to decode |
| offset |
Integer | Offset to decode at |
UInt128
$3
Encodes a 128 bit unsigned integer as Big Endian Buffer.
| Param | Type | Description |
| ------ | ------------------- | ----------------- |
| int |
BigInt | Integer to encode |
$3
Decodes a Big Endian Buffer into a 128 bit unsigned integer
| Param | Type | Description |
| ------ | -------------------- | ------------------- |
| buffer |
Buffer | Buffer to decode |
| offset |
Integer | Offset to decode at |
$3
Encodes a 128 bit unsigned integer as Little Endian Buffer.
| Param | Type | Description |
| ------ | ------------------- | ----------------- |
| int |
BigInt | Integer to encode |
$3
Decodes a Little Endian Buffer into a 128 bit unsigned integer
| Param | Type | Description |
| ------ | -------------------- | ------------------- |
| buffer |
Buffer | Buffer to decode |
| offset |
Integer | Offset to decode at |