diff --git a/.gitignore b/.gitignore index b512c09..448c205 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +.directory diff --git a/lib/types.js b/lib/types.js index 055635b..1a12d3b 100644 --- a/lib/types.js +++ b/lib/types.js @@ -153,6 +153,23 @@ module.exports.Buffer = { } } +/* + * bigInt - big integers + */ +module.exports.bigint = { + write: function (BN, data, path) { + if (typeof(BN) !== 'bigint') { + throw new TypeError('Expected a BigInt at ' + path + ', got ' + BN) + } + console.log(BN.toString(16)) + console.log(new Buffer(BN.toString(16), 'hex')); + exports.Buffer.write(new Buffer(BN.toString(16), 'hex'), data, path) + }, + read: function (state) { + return BigInt('0x' + exports.Buffer.read(state).toString('hex')) + } +} + /* * either 0x00 or 0x01 */ @@ -241,4 +258,4 @@ module.exports.date = { read: function (state) { return new Date(exports.uint.read(state)) } -} \ No newline at end of file +}