Closed TheMychenik closed 2 years ago
How to explain, I would like to be able to get the maximum pointer of the parser to compare with buffer that i try to parse example:
let incomingArray = new Parser() .uint8('someData1') .skip(7) .uint8('someData2') .skip(7) .uint8('someData3') // incomingArray.getMaxSize() >> 17 // msg.length >> 16 if (msg.length <= incomingArray.getMaxSize()) // incomingArray.parse(msg) else // skip, log or what you want
or not to throw range error and parse available size
let incomingArray = new Parser() .parseAsManyAsYouCan() .uint8('someData1') .skip(7) .uint8('someData2') .skip(7) .uint8('someData3') // incomingArray.parse(msg) >> msg { someData: '1', someData2: '2' } // no someData3 but no err
Is incomingArray.sizeOf() what you need?
incomingArray.sizeOf()
Exactly! Thanks, I didn't find it in the readme
Yes, I will document the method in the readme. Thanks for pointing it out!
How to explain, I would like to be able to get the maximum pointer of the parser to compare with buffer that i try to parse example:
or not to throw range error and parse available size