1.0.0 • Published 4 years ago

bigint-serde v1.0.0

Weekly downloads
-
License
MIT OR GPL-3.0-or...
Repository
-
Last release
4 years ago

bigint-serde

JS implementation of JSON serialization of BigInt and BigUint types from Rust num-bigint crate

Build Status Coverage Status

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