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: the last logical expression is redundant, as we've already determined that off and len are both >= 0, so off + len can't be < 0.