deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

Please do a Deno existence check in io/buffer.ts BufReader.readline

Open johnspurlock opened this issue 3 years ago • 3 comments

I'd like to use std streams in the browser, and the only reference to the Deno ns after bundling is this reference:

https://github.com/denoland/deno_std/blob/09e24d81ce0bacebe81b3c9f683a6ecf9263fc12/io/buffer.ts#L499

Mind doing an existence check here to make sure it runs in the browser?

Thanks, - John

johnspurlock avatar Jun 27 '22 15:06 johnspurlock

PRs are welcome

bartlomieju avatar Jun 27 '22 18:06 bartlomieju

I would say io/buffer.ts isnt intended to be web compatible, especially from a ts perspective given that Deno namespace interfaces are used. for web compat you should rather use web streams.

crowlKats avatar Jun 27 '22 20:06 crowlKats

@crowlKats I'm actually bundling std streams, and the only reference to buffer is the one I pointed out above, seems like it could be elided if the Deno ns is not present with no issues, unless I'm missing something

Can inspect the bundle output here: https://bundle.deno.dev/https://deno.land/[email protected]/streams/mod.ts

johnspurlock avatar Jun 27 '22 21:06 johnspurlock

@bartlomieju, is the streams module meant to be web compatible? One would think so. However, there doesn't appear to be any explicit mention of that being the case. If so, the checks mentioned above within the streams module might make sense.

iuioiua avatar Aug 28 '22 01:08 iuioiua

Actually, it looks as though the block in question can be deleted anyway.

https://github.com/denoland/deno_std/blob/36fa687ecc30b4a69d6bb498afc501cb06bc20d0/io/buffer.ts#L499-L501

The following block takes care of that same condition.

https://github.com/denoland/deno_std/blob/36fa687ecc30b4a69d6bb498afc501cb06bc20d0/io/buffer.ts#L513-L515

This might fix our issue.

iuioiua avatar Aug 28 '22 07:08 iuioiua

Thank you!!

johnspurlock avatar Aug 30 '22 13:08 johnspurlock