创建自定义提供者
🌐 Creating custom providers
const { VirtualProvider } = require('node:vfs');
class StaticProvider extends VirtualProvider {
get readonly() { return true; }
statSync(path) { /* ... */ }
openSync(path, flags) { /* ... */ }
readdirSync(path, options) { /* ... */ }
// ...
} 基类会对任何未被重写的原始类型抛出 ERR_METHOD_NOT_IMPLEMENTED,并且拒绝来自 readonly 提供者的 EROFS 写入。
🌐 The base class throws ERR_METHOD_NOT_IMPLEMENTED for any primitive
that has not been overridden, and rejects writes from a readonly
provider with EROFS.