-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request(streams): lines(readable): AsyncIterable<string> #5071
Comments
Does this not already exist via import { TextLineStream } from '@std/streams'
for await (
const line of (await Deno.open('./deno.json'))
.readable
.pipeThrough(new TextEncoderStream())
.pipeThrough(new TextLineStream())
)
console.log(line) |
I'm impartial to adding this. The above code snippet using |
The above example is correct, but it looks a bit cluttered for such typical simple task, compared to other languages/runtimes. Reading lines from a file is much simpler in other languages. python file = open('README.md', 'r')
for line in file.readlines():
print(line) perl open(INFO, "README.md") or die();
foreach $line (<INFO>) {
print $line;
} I think it would be useful to have special/ergonomic wrapper for such typical task |
If something like this is to be added, I think a |
|
I agree with the comment by @iuioiua — this seems convenient, but also somewhat trivial. If it is decided to be added, I think that the return type should be |
Idea from some discussion: A quick helper for getting an async iterable (or maybe another stream) of lines from a ReadableStream.
Example signature:
lines(readable: ReadableStream<Uint8Array>|ReadableStream<string>): AsyncIterable<string>
The text was updated successfully, but these errors were encountered: