Open chochos opened 11 years ago
This can't be made to work in browser for reasons that should be obvious. And node.js does not offer a synchronous way to read from a stream (even the newest version as of this writing, v0.10.28, which includes a new unstable module called readline
, offers only asynchronous readlines with callbacks).
Would it be worth it to have an asynchronous version in the language module?
Perhaps we should deprecate the synchronous version, and only have the async version. But that would sorta introduce threads into the picture, I guess.
Yes you need threads for this in jvm. And it's IMO an unnecessarily convoluted way of doing things, because of node's event-based callbacks-for-everything model.
I'm hoping the node.js people realize how limited the async readline is (it borders on useless, honestly) and offer a synchronous version.
@chochos can't you just write a polling loop that waits for a response?
Other than having a while (line===undefined);
I haven't found another way of making the damn thing wait.
Isn't there some kind of sleep()
?
There's a sleep
module, but it's not part of the core modules, so if you haven't installed it using npm
, you'll get an error Cannot find module 'sleep'
process.readLine()
is unimplemented; it needs a sensible implementation that could work in browser and node.js