Categories
JavaScript Answers

How to buffer entire file in memory with Node.js?

Spread the love

To buffer entire file in memory with Node.js, we call readFile.

For instance, we write

const fs = require("fs");

fs.readFile("/etc/passwd", (err, data) => {
  // ...
});

to call readFile to open the /etc/passwd file.

And we get the open file data from data.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *