Skip to content

Trying different ways of reading Deno.stdin.

Notifications You must be signed in to change notification settings

hugojosefson/deno-stdin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno stdin experiments

Trying different ways of reading Deno.stdin. I hope to be able to switch in and out of Deno.stdin.setRaw(), while waiting for input, without locking up or encountering errors.

That could be useful for making a port of ink for Deno work correctly.

Conclusion

deno run --reload https://raw.githubusercontent.com/hugojosefson/deno-stdin/main/src/demo.ts --silent

Source code in: src/demo.ts

Apparently, setting raw mode on Deno.stdin, and reading/writing is fine, as long as you await the Promise returned from Deno.Writer.write.

Don't just write in the background haphazardly, and then try to Deno.stdin.setRaw() while that's happening. Instead, in a loop where you await each Deno.Writer.write, check a let done: boolean flag for whether to stop writing and resetting the raw mode to false.

About

Trying different ways of reading Deno.stdin.

Topics

Resources

Stars

Watchers

Forks