fs.readFile()
Convenience functions that read a whole file into memory, or write a whole file, in one call.
In more detail
They are simple and fine for small files, but a large file means a large allocation, so stream big files instead. writeFile replaces the whole file unless you ask for append mode.
Related terms
- node:fs — The built-in Node.js module for working with files and folders, in promise, callback and synchronous forms.
- stream — Data that flows between a program and a source or destination piece by piece, rather than all at once.
- FileHandle — The object fs/promises open() returns for an open file, wrapping its file descriptor with promise-based read, write and close methods.
Taught in
- Event Loop Lifecycle: The Six Phases & libuv uv_run — Node.js Internals & Backend Services
- Poll & Check Phases: I/O Callbacks & setImmediate — Node.js Internals & Backend Services
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services