Permalink
Browse files

Added byteOffset in byte event

  • Loading branch information...
Gabriel Llamas
Gabriel Llamas committed May 13, 2012
1 parent 8215814 commit 40d52d94ee5e666bb746334e40144c0b85c1e9d4
Showing with 5 additions and 4 deletions.
  1. +1 −1 build/buffered-reader.js
  2. +2 −2 examples/binary.js
  3. +2 −1 src/buffered-reader.js
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -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);
View
@@ -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;
}

0 comments on commit 40d52d9

Please sign in to comment.