Reading .buffer readUntil: 'eof' returns buffer 1 too short
See original GitHub issueThanks for the library, really helpful!
I’ve noticed that parsing rest of message into a buffer, it comes back one too short.
var Parser = require('binary-parser').Parser;
var bp = new Parser().buffer('test',{ readUntil: 'eof'});
var buf=new Buffer([1,2,3]);
console.log(bp.parse(buf));
output:
{ test: <Buffer 01 02> }
I am not an expert but I think that there should not be - 1 on this line :
ctx.pushCode('{0} = buffer.slice(offset, buffer.length - 1);',
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to read until EOF from STDOUT in C? - Stack Overflow
The code in your #4 will only work with very small outputs, since it doesn't start reading until the executed command terminates. That...
Read more >Read until EOF but not more then N bytes : r/rust - Reddit
In case there are more bytes than N, it must return an error. ... multiple small reads are really done as a large...
Read more >bufio - Go Packages
Buffered returns the number of bytes that can be read from the current buffer. ... it also returns an error explaining why the...
Read more >read(2): read from file descriptor - Linux man page - Die.net
read () attempts to read up to count bytes from file descriptor fd into the buffer starting at buf. On files that support...
Read more >PEP 3116 – New I/O - Python Enhancement Proposals
The raw I/O and buffered I/O layers deal with units of bytes, ... buffered reads will only return a short read if EOF...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Tks for the workaround.
This is now fixed in release 1.1.6 thanks to @kertal.