Create a union of multiple file systems
masterYou can use the exported ufs instance to layer multiple file systems. The order of .use() calls determines the priority: file systems added later will shadow or overlay those added earlier if they contain the same paths.
unionfs works with any object that implements the standard fs API, such as memfs (in-memory), linkfs (path redirection), or memory-fs.
import { ufs } from 'unionfs';
import { fs as fs1 } from 'memfs';
import * as fs2 from 'fs';
// Layer fs1 on top of fs2
ufs.use(fs1).use(fs2);
// Operations on ufs will now search through the layered file systems
ufs.readFileSync(/* ... */);