keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
868 stars 136 forks source link

Unable to encode uint64 #152

Closed sabahath786 closed 4 years ago

sabahath786 commented 4 years ago

var ipHeader = new Parser() .uint16("fragment_id") .uint16("fragment_total") .uint64("date_time")

var anIpHeader = {
fragment_id: 1, fragment_total: 1, datetime: 4744430483355899789, }

console.log(ipHeader.encode(anIpHeader).toString("hex"));

### I am getting error: internal/buffer.js:598 let lo = Number(value & 0xffffffffn); ^

TypeError: Cannot mix BigInt and other types, use explicit conversions at writeBigU_Int64BE (internal/buffer.js:598:25) at Buffer.writeBigUInt64BE (internal/buffer.js:618:10) at SmartBuffer._writeNumberValue (C:\work\ugves\project\repo-poc\emulator-prs-poc\nodejs-es-to-prs\node-start-es6\node_modules\smart-buffer\src\smartbuffer.ts:1402:10) at SmartBuffer.writeBigUInt64BE (C:\work\ugves\project\repo-poc\emulator-prs-poc\nodejs-es-to-prs\node-start-es6\node_modules\smart-buffer\src\smartbuffer.ts:576:17) at Parser.compiledEncode (evalmachine.:11:13)

Please help me how can i fix this issue

keichi commented 4 years ago

You seem to be using a fork of this package. Please create an issue on the fork.