Update index.js

Small fix so that the callback is not called before all chunks of the buffer has been collected.