Skip to main content

Module fs_promises

Module fs_promises 

Source
Expand description

Node fs/promises (also require('fs').promises) — Promise-returning file operations.

Every method delegates to the SAME synchronous I/O the *Sync fs module performs (readFile→readFileSync, chmod→chmodSync, …), then wraps the outcome in a settled Promise: fulfilled with the value on success, rejected with an Error object on failure. Delegating to fs::call keeps the encoding handling, Stats/Dirent/Dir shapes, and error strings identical to the rest of fs.

open returns a FileHandle: a port of node’s class over the same synchronous descriptor calls (fs_filehandle.js), which readFile, writeFile and appendFile also route through when handed one.

The work is performed synchronously (node-js has no thread-pooled fs at this layer), and the Promise settles in the loop’s poll phase, as an I/O completion — ordered with the callback forms’ completions, as in node.

Constants§

METHODS

Functions§

call