For transforming a very large file from uppercase to lowercase, which approach is the MOST memory-efficient?
Node.js interview question for Advanced practice.
Answer
Piping through a Transform stream that modifies the Buffer in-place.
Explanation
Modifying the Buffer directly in-place within a Transform stream is the most memory-efficient method because it avoids creating intermediate strings for each chunk. Both options A and B create large strings in memory, which is inefficient for large files. Option D is better than A, but still involves string creation for every line.