Optimize ByteArrayInputStream

This saves a few seconds at startup. It's also used a lot in general, so it's worth implementing it in JS.
I don't know where I had my head :smile: