I have seen several demonstrations of node streams that are something like
createReadStream(file)
.pipe(filter(/test/i))
.pipe(count())
Demonstrating how you would count the instances of the string "test" inside of file. filter and count are largely handwaved in the code samples, without any implementation shown.
Separately, I have seen several times that you can't count on where a chunk will be- they'll be arbitrarily sized.
Combining these two, why doesn't the code above have a bug, where a chunk may end right in the middle of the word "test"?