Skip to content

Commit

Permalink
Added byteOffset in byte event
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Llamas committed May 13, 2012
1 parent 8215814 commit 40d52d9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/buffered-reader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/binary.js
Expand Up @@ -4,8 +4,8 @@ new BufferedReader ("lorem ipsum 2")
.on ("error", function (error){
console.log (error);
})
.on ("byte", function (b){
console.log ("byte: " + b);
.on ("byte", function (b, byteOffset){
console.log ("byte: " + b + ", offset: " + byteOffset);
})
.on ("buffer", function (buffer){
console.log ("buffer: " + buffer);
Expand Down
3 changes: 2 additions & 1 deletion src/buffered-reader.js
Expand Up @@ -94,7 +94,8 @@ BufferedReader.prototype.read = function (){

character = data[i];
if (!stream.encoding){
if (onByte) me.emit ("byte", character);
byteOffset++;
if (onByte) me.emit ("byte", character, byteOffset);
continue;
}

Expand Down

0 comments on commit 40d52d9

Please sign in to comment.