mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Enable node:vfs by default. --no-experimental-vfs disables node:vfs exposure and --vfs-load. Assisted-by: pi Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/66318 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
30 lines
754 B
JavaScript
30 lines
754 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'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' },
|
|
);
|