This `typeof` code is all over the place in `stream.js`. I suggest to do the refactor of the file in a separate PR, to make it easier to revert the changes (if the `typeof` thingey turns out to be more significant than expected) without loosing the bugfix from this PR.