TheSpyder / rescript-webapi

ReScript bindings to the DOM and other Web APIs
http://tinymce.github.io/rescript-webapi/api/Webapi/
Other
149 stars 36 forks source link

ReadableStream bindings are incorrect #91

Open TheSpyder opened 2 years ago

TheSpyder commented 2 years ago

I'm not sure where the inspiration for the current bindings came from, but in them "byob" readers don't have a read method. This is not true:

https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/read https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader/read

They even return the same shape of object. BYOB readers are still experimental, I think we can flatten these bindings into a single Reader.t and it will work just fine (we also need to fix the return type of the read method).

Note that we'll probably have to use the same module rec trick to avoid creating a full nested module, this is a cool idea that we might be able to leverage elsewhere. Instead of var ModuleName = {} which tree shaking can't remove, it only generates var ModuleName which I would hope can be removed.