What are streams and what are the four types?
Assesses fundamental understanding of Node.js conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
Streams process data in chunks instead of buffering everything, which keeps memory flat for large files and real-time traffic. Four types:
- Readable: source of data (fs.createReadStream, http request).
- Writable: destination (fs.createWriteStream, http response).
- Duplex: both, such as a TCP socket.
- Transform: duplex that modifies data as it passes (zlib.createGzip, a parser).
Pipelines propagate backpressure and errors:
const { pipeline } = require('node:stream/promises');
await pipeline(
fs.createReadStream('in.csv'),
new Transform({ transform(c, _e, cb) { cb(null, c.toString().toUpperCase()); } }),
fs.createWriteStream('out.csv'),
);
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.