You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I'm writing a protocol handler now in 2024. The protocol is designed in a comfort way that I always know how many bytes to handle next... So is there any way to "await stream.read( n );" which resolves once n bytes are available?
I cannot find anything like this. Yes of course I can also write a state machine like in the node old days, nor does await iterator help, since againa state machine is the required nevertheless (and these are so unhuman to write). And I guess I could a build a promise resolve framework arouhnd the stream myself, so I get a readable linear readable protocol handler, but honestly dealing with promises that way is complicated.
But did I overlook it, or is native node not able to do that? Which IMO would be a quite sensible request in an async/await world.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
So I'm writing a protocol handler now in 2024. The protocol is designed in a comfort way that I always know how many bytes to handle next... So is there any way to "await stream.read( n );" which resolves once n bytes are available?
I cannot find anything like this. Yes of course I can also write a state machine like in the node old days, nor does await iterator help, since againa state machine is the required nevertheless (and these are so unhuman to write). And I guess I could a build a promise resolve framework arouhnd the stream myself, so I get a readable linear readable protocol handler, but honestly dealing with promises that way is complicated.
But did I overlook it, or is native node not able to do that? Which IMO would be a quite sensible request in an async/await world.
Beta Was this translation helpful? Give feedback.
All reactions