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>
29 lines
735 B
JavaScript
29 lines
735 B
JavaScript
// Flags: --experimental-vfs
|
|
'use strict';
|
|
|
|
// VFS stream constructors must validate start/end synchronously.
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const vfs = require('node:vfs');
|
|
|
|
const myVfs = vfs.create();
|
|
myVfs.writeFileSync('/file.txt', 'abc');
|
|
|
|
// ReadStream: start > end must throw ERR_OUT_OF_RANGE synchronously
|
|
assert.throws(
|
|
() => myVfs.createReadStream('/file.txt', { start: 2, end: 1 }),
|
|
{ code: 'ERR_OUT_OF_RANGE' },
|
|
);
|
|
|
|
// ReadStream: negative start
|
|
assert.throws(
|
|
() => myVfs.createReadStream('/file.txt', { start: -1 }),
|
|
{ code: 'ERR_OUT_OF_RANGE' },
|
|
);
|
|
|
|
// ReadStream: negative end
|
|
assert.throws(
|
|
() => myVfs.createReadStream('/file.txt', { end: -1 }),
|
|
{ code: 'ERR_OUT_OF_RANGE' },
|
|
);
|