bigint-serde
v1.0.0
Published
JS implementation of JSON serialization of BigInt and BigUint types from Rust num_bigint crate
Downloads
8
Readme
bigint-serde
JS implementation of JSON serialization of BigInt and BigUint types from Rust num-bigint crate
Example
BigInt
const {
toJSON,
fromJSON,
} = require('bigint-serde');
console.log(toJSON(-123456789123456789n)); // → [-1,[2899336981,28744523]]
console.log(fromJSON([-1,[2899336981,28744523]])); // → -123456789123456789n
BigUint
const {
toJSON,
fromJSON,
} = require('bigint-serde/unsigned');
console.log(toJSON(123456789123456789n)); // → [2899336981,28744523]
console.log(fromJSON([2899336981,28744523])); // → 123456789123456789n
Install
yarn add bigint-serde