Performance: Buffer and streams relationship
MEDIUM IMPACT
This concept affects how efficiently data is handled and transferred in Node.js applications, impacting memory usage and responsiveness.
const fs = require('fs'); const stream = fs.createReadStream('largefile.txt'); stream.on('data', chunk => processData(chunk));
const fs = require('fs'); const data = fs.readFileSync('largefile.txt'); processData(data);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous read with full buffer | N/A | N/A | N/A | [X] Bad |
| Stream with buffer chunks | N/A | N/A | N/A | [OK] Good |