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.
Nit: since the first conditional block throws, there's no need for the second one to be within an *else*.