Skip to content

Commit 1d4adfd

Browse files
author
Fabian Wiles
authored
provide a way to find the bytes read from Buffer
This change could possibly be breaking. Another way to do it would be wrap the return value into another object. ``` return { bytesRead: offset, vars} ``` But that 100% would be a breaking change This allows users to post parsing check the length of the input buffer agasint the number of bytes read from it. Which can make it easier to point out bugs in the application. --- I've another PR for this here: keichi#86 But I like the encoding functionality that you've put together aswell.
1 parent dd75c74 commit 1d4adfd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/binary_parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ Parser.prototype.addRawCode = function(ctx) {
309309

310310
this.resolveReferences(ctx);
311311

312-
ctx.pushCode("return vars;");
312+
ctx.pushCode("vars.__bytesRead = offset; return vars;");
313313
};
314314

315315
Parser.prototype.addRawCodeEncode = function(ctx) {

0 commit comments

Comments
 (0)