File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -9,27 +9,27 @@ function BinarySplit (matcher) {
9
9
matcher = bops . from ( matcher || os . EOL )
10
10
var buffered
11
11
var bufcount = 0
12
- var offset = 0
13
12
return through ( write , end )
14
13
15
14
function write ( buf , enc , done ) {
16
15
bufcount ++
17
-
16
+ var offset = 0
17
+ var lastMatch = 0
18
18
if ( buffered ) {
19
19
buf = bops . join ( [ buffered , buf ] )
20
+ offset = buffered . length
20
21
buffered = undefined
21
22
}
22
23
23
- while ( buf ) {
24
+ while ( true ) {
24
25
var idx = firstMatch ( buf , offset )
25
26
if ( idx !== - 1 && idx < buf . length ) {
26
- this . push ( bops . subarray ( buf , 0 , idx ) )
27
- buf = bops . subarray ( buf , idx + matcher . length )
28
- offset = 0
27
+ this . push ( bops . subarray ( buf , lastMatch , idx ) )
28
+ offset = idx + matcher . length
29
+ lastMatch = offset
29
30
} else {
30
- buffered = buf
31
- offset = buf . length
32
- buf = undefined
31
+ buffered = bops . subarray ( buf , lastMatch )
32
+ break
33
33
}
34
34
}
35
35
You can’t perform that action at this time.
0 commit comments