issue #40, generalized to check if the stream is ReadableStream