Skip to content

Commit 2f92c8c

Browse files
mcollinaaduh95
andauthored
Apply suggestions from code review
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 6cd90e1 commit 2f92c8c

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

doc/api/fs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ added: REPLACEME
129129

130130
> Stability: 1 - Experimental
131131
132-
The `fs` module can operate on virtual files when the [`node:vfs`][] module is
133-
used. When a virtual file system is mounted, `fs` operations on paths under
132+
The `node:fs` module can operate on virtual files when the [`node:vfs`][] module is
133+
used. When a virtual file system is mounted, `node:fs` operations on paths under
134134
the mount point are automatically routed to the VFS instead of the real file
135135
system.
136136

@@ -148,7 +148,7 @@ fs.readFileSync('/virtual/data.txt', 'utf8'); // 'Hello from VFS'
148148
myVfs.unmount();
149149
```
150150

151-
Not all `fs` operations are supported with VFS. See the [`node:vfs`][]
151+
Not all `node:fs` operations are supported with VFS. See the [`node:vfs`][]
152152
documentation for the complete list of supported operations and limitations.
153153

154154
## Promises API

doc/api/vfs.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ added: REPLACEME
1111
<!-- source_link=lib/vfs.js -->
1212

1313
The `node:vfs` module provides a virtual file system that can be mounted
14-
alongside the real file system. Virtual files can be read using standard `fs`
14+
alongside the real file system. Virtual files can be read using standard `node:fs`
1515
operations and loaded as modules using `require()` or `import`.
1616

1717
To access it:
@@ -29,7 +29,7 @@ This module is only available under the `node:` scheme.
2929
## Overview
3030

3131
The Virtual File System (VFS) allows you to create in-memory file systems that
32-
integrate seamlessly with the Node.js `fs` module and module loading system. This
32+
integrate seamlessly with the Node.js `node:fs` module and module loading system. This
3333
is useful for:
3434

3535
* Bundling assets in Single Executable Applications (SEA)
@@ -75,7 +75,7 @@ See [Security considerations][] for important warnings about overlay mode.
7575
## Basic usage
7676

7777
The following example shows how to create a virtual file system, add files,
78-
and access them through the standard `fs` API:
78+
and access them through the standard `node:fs` API:
7979

8080
```mjs
8181
import vfs from 'node:vfs';
@@ -155,7 +155,7 @@ Each worker thread has its own independent VFS state. A VFS mounted in the
155155
main thread is not automatically available in worker threads. To use VFS in
156156
workers, create and mount a new VFS instance within each worker.
157157

158-
### fs.watch limitations
158+
### `fs.watch` limitations
159159

160160
The `fs.watch()` and `fs.watchFile()` functions work with VFS files but use
161161
polling internally rather than native file system notifications, since VFS
@@ -226,7 +226,7 @@ added: REPLACEME
226226

227227
The `VirtualFileSystem` class provides a file system interface backed by a
228228
provider. It supports standard file system operations and can be mounted to
229-
make virtual files accessible through the `fs` module.
229+
make virtual files accessible through the `node:fs` module.
230230

231231
### `new VirtualFileSystem([provider][, options])`
232232

@@ -288,7 +288,7 @@ added: REPLACEME
288288
* Returns: {VirtualFileSystem} The VFS instance (for chaining or `using`).
289289

290290
Mounts the virtual file system at the specified path prefix. After mounting,
291-
files in the VFS can be accessed via the `fs` module using paths that start
291+
files in the VFS can be accessed via the `node:fs` module using paths that start
292292
with the prefix.
293293

294294
If a real file system path already exists at the mount prefix, the VFS
@@ -410,7 +410,7 @@ added: REPLACEME
410410
-->
411411

412412
Unmounts the virtual file system. After unmounting, virtual files are no longer
413-
accessible through the `fs` module. The VFS can be remounted at the same or a
413+
accessible through the `node:fs` module. The VFS can be remounted at the same or a
414414
different path by calling `mount()` again. Unmounting also resets the virtual
415415
working directory if one was set.
416416

@@ -419,15 +419,15 @@ has no effect.
419419

420420
### File System Methods
421421

422-
The `VirtualFileSystem` class provides methods that mirror the `fs` module API.
422+
The `VirtualFileSystem` class provides methods that mirror the `node:fs` module API.
423423
All paths are relative to the VFS root (not the mount point).
424424

425-
These methods accept the same argument types as their `fs` counterparts,
425+
These methods accept the same argument types as their `node:fs` counterparts,
426426
including `string`, `Buffer`, `TypedArray`, and `DataView` where applicable.
427427

428428
#### Overlay mode behavior
429429

430-
When overlay mode is enabled, the following behavior applies to `fs` operations
430+
When overlay mode is enabled, the following behavior applies to `node:fs` operations
431431
on mounted paths.
432432

433433
**Path encoding:** The VFS uses UTF-8 encoding for file and directory names
@@ -465,11 +465,11 @@ before VFS operations.
465465

466466
#### Synchronous Methods
467467

468-
The `VirtualFileSystem` class supports all common synchronous `fs` methods
468+
The `VirtualFileSystem` class supports all common synchronous `node:fs` methods
469469
for reading, writing, and managing files and directories. Methods mirror the
470-
`fs` module API.
470+
`node:fs` module API.
471471

472-
The following `fs` sync methods have **no** VFS equivalent:
472+
The following `node:fs` sync methods have **no** VFS equivalent:
473473

474474
* `chmodSync()` / `fchmodSync()` - VFS does not support permission changes
475475
* `chownSync()` / `fchownSync()` - VFS does not support ownership changes
@@ -515,9 +515,7 @@ added: REPLACEME
515515
The `VirtualProvider` class is an abstract base class for VFS providers.
516516
Providers implement the actual file system storage and operations.
517517

518-
### Properties
519-
520-
#### `provider.readonly`
518+
### `provider.readonly`
521519

522520
<!-- YAML
523521
added: REPLACEME
@@ -691,9 +689,9 @@ added: REPLACEME
691689

692690
The real file system path that this provider wraps.
693691

694-
## Integration with `fs` module
692+
## Integration with `node:fs` module
695693

696-
When a VFS is mounted, the standard `fs` module automatically routes operations
694+
When a VFS is mounted, the standard `node:fs` module automatically routes operations
697695
to the VFS for paths that match the mount prefix:
698696

699697
```mjs
@@ -765,10 +763,10 @@ console.log(greet('World')); // Hello, World!
765763

766764
## Implementation details
767765

768-
### Stats objects
766+
### `Stats` objects
769767

770-
The VFS returns real `fs.Stats` objects from `stat()`, `lstat()`, and `fstat()`
771-
operations. These Stats objects behave identically to those returned by the real
768+
The VFS returns real {fs.Stats} objects from `stat()`, `lstat()`, and `fstat()`
769+
operations. These `Stats` objects behave identically to those returned by the real
772770
file system:
773771

774772
* `stats.isFile()`, `stats.isDirectory()`, `stats.isSymbolicLink()` work correctly
@@ -955,13 +953,13 @@ fs.readFileSync('/etc/shadow'); // Returns 'intercepted!' (mocked)
955953

956954
This is particularly dangerous because:
957955

958-
* It's harder to detect than full path shadowing
959-
* Only specific targeted files are affected
960-
* Other operations appear to work normally
956+
* It is harder to detect than full path shadowing.
957+
* Only specific targeted files are affected.
958+
* Other operations appear to work normally.
961959

962960
### Monitoring VFS mounts
963961

964-
To help detect unauthorized VFS usage, the `process` object emits events when
962+
To help detect unauthorized VFS usage, `node:process` emits events when
965963
a VFS is mounted or unmounted:
966964

967965
```cjs

0 commit comments

Comments
 (0)