5 ms·
I use fs.writeFileSync: $ node -e "fs.writeFileSync(1, Buffer.from('@'.repeat(128 * 1024))); process.exit(0);" | wc -c 131072
by ksr 2y ago
I use fs.writeFileSync:
$ node -e "fs.writeFileSync(1, Buffer.from('@'.repeat(128 * 1024))); process.exit(0);" | wc -c
131072
- 3np 2y agoIt doesn't work for all streams but for the stdout/stderr case where they can be treated like file descriptors, I prefer this simpler approach over fiddling with the Streams API. (If blocking the process on writing synchronously to stdout is indeed what you actually want...)