Here's the task. Ten gigabyte file, you transform every line, and memory has to stay flat the whole way through. Walk me through your design.
A strong answer designs a bounded-memory file pipeline, handles split lines and split characters at chunk boundaries, and proves flat memory with metrics
I'd build a pipeline with three stages, basically. fs.createReadStream reads the input, a transform splits the chunks into lines and applies the per-line change, and a writable stage writes the output file. You wire them with stream.pipeline so if anything errors the whole chain gets torn down. The read stream emits chunks of around 64KiB, so memory only ever holds a chunk or two instead of the whole file. The tricky bit is chunks don't line up with line endings, so the splitter keeps the trailing partial line in a small buffer and sticks it in front of the next chunk. readline.createInterface or a split transform handles that for you. Backpressure stops the reader outrunning the writer, so the footprint stays constant from the first byte to the ten-billionth. To verify I'd just watch process.memoryUsage() during a run, it should plateau early and stay flat regardless of file size.