Skip to content

use global offset for buffered chunks #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 15, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ function BinarySplit (matcher) {
matcher = bops.from(matcher || os.EOL)
var buffered
var bufcount = 0
var offset = 0
return through(write, end)

function write (buf, enc, done) {
bufcount++
var offset = 0

if (buffered) {
buf = bops.join([buffered, buf])
Expand All @@ -37,6 +37,7 @@ function BinarySplit (matcher) {
} else {
if (offset >= buf.length) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I don't see how this clause can ever be evaluated true (it doesn't in the tests and any scenario I can think of). So, the offset = 0 two lines below is kind of a guess…

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm also not sure whether this block is necessary there. @maxogden is it safe to remove or does it have a special meaning that's not obvious?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't remember :P Probably me just being overly defensive

buffered = undefined
offset = 0
} else {
buffered = buf
}
Expand Down