if (mode == null) {
      mode = constants.F_OK;
    }
Simulates `fs` API in an isolated, memory-based filesystem. This is useful
for testing systems that rely on `fs` without affecting the real filesystem.
This is meant to be a drop-in replacement/mock for `fs`, so it mimics
closely the behavior of file path resolution and file accesses.