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>
25 lines
648 B
JavaScript
25 lines
648 B
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
// VFS readFile callback API.
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const vfs = require('node:vfs');
|
|
|
|
const myVfs = vfs.create();
|
|
myVfs.writeFileSync('/async-read.txt', 'async content');
|
|
|
|
myVfs.readFile('/async-read.txt', 'utf8', common.mustSucceed((data) => {
|
|
assert.strictEqual(data, 'async content');
|
|
}));
|
|
|
|
myVfs.readFile('/async-read.txt', common.mustSucceed((data) => {
|
|
assert.ok(Buffer.isBuffer(data));
|
|
assert.strictEqual(data.toString(), 'async content');
|
|
}));
|
|
|
|
myVfs.readFile('/missing.txt', common.expectsError({
|
|
code: 'ENOENT',
|
|
}));
|