Skip to content

Commit 56589c8

Browse files
mcollinaaduh95
andauthored
Apply suggestions from code review
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 939365a commit 56589c8

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

lib/internal/vfs/dir.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,16 @@ class VirtualDir {
8989
}
9090
}
9191

92-
[SymbolAsyncIterator]() {
93-
return this.entries();
94-
}
95-
96-
[SymbolAsyncDispose]() {
97-
return this.close();
98-
}
99-
10092
[SymbolDispose]() {
10193
if (!this.#closed) {
10294
this.closeSync();
10395
}
10496
}
10597
}
10698

99+
VirtualDir.prototype[SymbolAsyncIterator] = VirtualDir.prototype.entries;
100+
VirtualDir.prototype[SymbolAsyncDispose] = VirtualDir.prototype.close;
101+
107102
module.exports = {
108103
VirtualDir,
109104
};

lib/internal/vfs/file_handle.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,11 @@ class VirtualFileHandle {
346346
closeSync() {
347347
this[kClosed] = true;
348348
}
349-
350-
[SymbolAsyncDispose]() {
351-
return this.close();
352-
}
353349
}
354350

351+
VirtualFileHandle.prototype[SymbolAsyncDispose] = VirtualFileHandle.prototype.close;
352+
VirtualFileHandle.prototype[SymbolDispose] = VirtualFileHandle.prototype.closeSync;
353+
355354
/**
356355
* A file handle for in-memory file content.
357356
* Used by MemoryProvider and similar providers.

test/parallel/test-vfs-memory-provider-dynamic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function makeFileEntry(prototypeFrom, contentProvider) {
5151
const provider = new MemoryProvider();
5252
const root = getRoot(provider);
5353

54-
const dir = { __proto__: Object.getPrototypeOf(root) };
55-
Object.assign(dir, {
54+
const dir = {
55+
__proto__: Object.getPrototypeOf(root),
5656
type: 1, // TYPE_DIR
5757
mode: 0o755,
5858
children: new Map(),

0 commit comments

Comments
 (0)