FileHandle
The object fs/promises open() returns for an open file, wrapping its file descriptor with promise-based read, write and close methods.
In more detail
It lets you read or write at chosen positions without loading the whole file. Always close it, ideally in a finally block or with await using, because waiting for garbage collection to close it is unreliable.
Related terms
- file descriptor — A small number the operating system gives a process for each open file, socket or pipe, used in every later read or write.
- positional read and write — Reading or writing a file at an explicit byte offset instead of wherever the previous operation stopped.
- try...catch — A statement that runs code in a try block and, if that code throws an exception, runs a catch block instead of crashing.
Taught in
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services