https://kotlinlang.org logo
#javascript
Title
# javascript
m

Matt Nelson

03/01/2024, 5:05 PM
Anyone know of a way to convert a stream.Writable into something synchronous, like Java's
java.io.OutputStream
???
Only way I know with Kotlin is via coroutines and make the
write
function of my wrapper a
suspend
function, but that is undesireable.
r

Robert Jaros

03/01/2024, 5:33 PM
I would say there is no way to convert async to sync in a single threaded environment.
m

Matt Nelson

03/01/2024, 5:36 PM
So you're saying I have to open a file descriptor, wrap it with a
stream.Readable
to pass to the
ChildProcess
for
stdin
, then write to that file descriptor via
writeSync
?
Uggh... don't even know if that'll work, and would need to be a named descriptor (file path) b/c can't open a unix pipe (or MS version of pipes)...
e

Edoardo Luppi

03/02/2024, 12:38 PM
The answer is you cannot. I already went through the desperation phase and accepted it.
m

Matt Nelson

03/02/2024, 12:48 PM
Yup, I spent about 2 hours trying to get something to work with custom
stream.Duplex
implementations, etc. The end result was sucking it up and adding the coroutines dependency sad panda
⏸️ 1