File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -19,25 +19,28 @@ function BinarySplit (matcher) {
19
19
buf = bops . join ( [ buffered , buf ] )
20
20
buffered = undefined
21
21
}
22
+ console . error ( buf , offset )
22
23
23
24
while ( buf ) {
24
25
var idx = firstMatch ( buf , offset )
25
26
if ( idx ) {
26
- var line = bops . subarray ( buf , offset , idx )
27
27
if ( idx === buf . length ) {
28
- buffered = line
28
+ console . error ( 'idx === buf.length' )
29
+ buffered = buf
29
30
buf = undefined
30
31
offset = idx
31
32
} else {
32
- this . push ( line )
33
- offset = idx + matcher . length
33
+ console . error ( 'idx !== buf.length' )
34
+ this . push ( bops . subarray ( buf , 0 , idx ) )
35
+ buf = bops . subarray ( buf , idx )
36
+ offset = 0
34
37
}
35
38
} else if ( idx === 0 ) {
36
39
buf = bops . subarray ( buf , offset + matcher . length )
37
40
} else {
38
41
if ( offset >= buf . length ) {
39
42
buffered = undefined
40
- offset = 0
43
+ // offset = 0
41
44
} else {
42
45
buffered = buf
43
46
}
Original file line number Diff line number Diff line change @@ -65,3 +65,15 @@ test('matcher at index 0 check', function (t) {
65
65
splitStream . write ( new Buffer ( '\nhello\nmax' ) )
66
66
splitStream . end ( )
67
67
} )
68
+
69
+ test ( 'chunked input' , function ( t ) {
70
+ fs . createReadStream ( 'test.json' )
71
+ . pipe ( split ( '\n' ) )
72
+ . pipe ( split ( 'i' ) )
73
+ . pipe ( splitTest ( ':' , function ( err , items ) {
74
+ if ( err ) throw err
75
+ console . error ( '...' , err , items )
76
+ t . equals ( items . length , 4 )
77
+ t . end ( )
78
+ } ) )
79
+ } )
You can’t perform that action at this time.
0 commit comments