As it happens i have an even better API than this article proposes! They propose just using an async iterator of UInt8Array. I almost like this idea, but it's not quite all the way there. They propose this: type Stream = { next(): Promise }> } I propose this, which I call a stream iterator! type Stream = { next(): { done, value: T } | Promise } Obviously I'm gonna be biased, but I'm pretty sure my version is also obj…
There is no such thing as Uint8Array . Uint8Array is a primitive for a bunch of bytes, because that is what data is in a stream. Adding types on top of that isn't a protocol concern but an application-level one.
[0] https://github.com/microsoft/TypeScript/blob/924810c077dd410...