Adds the node:vfs builtin module with VirtualFileSystem and provider classes. No integration with fs, modules, or SEA. Assisted-by: Claude-Opus4.7 Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/63115 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
21 lines
713 B
JavaScript
21 lines
713 B
JavaScript
// Flags: --experimental-vfs
|
|
'use strict';
|
|
|
|
// Buffer encoding for watch(): filename arrives as a Buffer.
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { once } = require('events');
|
|
const vfs = require('node:vfs');
|
|
|
|
(async () => {
|
|
const myVfs = vfs.create();
|
|
myVfs.writeFileSync('/bf.txt', 'a');
|
|
const watcher = myVfs.watch('/bf.txt', { interval: 25, encoding: 'buffer' });
|
|
const changed = once(watcher, 'change');
|
|
myVfs.writeFileSync('/bf.txt', 'longer-content-changed');
|
|
const [eventType, filename] = await changed;
|
|
assert.strictEqual(eventType, 'change');
|
|
assert.deepStrictEqual(filename, Buffer.from('bf.txt'));
|
|
watcher.close();
|
|
})().then(common.mustCall());
|