Module
x/proc/proc.usage.non-streaming.md
A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Popular
Development Notes
Proc Usage with Non-Streaming Input and Output
This is a test that lets me get some early reps on the new API for the simple case, which is non-streaming. Passing strings and byte-arrays to and from processes.
With non-streaming input and output, I can hide the use of Group
because
everything starts in memory and ends in memory.
In this case, I am wrapping gzip
in a couple of functions to allow compression
from string to bytes, and decompression back to string.
I like the readability. There is just enough formalism that everything is
defined, but - aside from Group
boilerplate - nothing extra.
async function gzip(text: string): Promise<Uint8Array> {
const pg = group();
try {
return await runner(stringInput(), bytesOutput()).run(pg, {
cmd: ["gzip", "-c"],
}, text);
} finally {
pg.close();
}
}