Skip to content

Commit

Permalink
Updated Dir to be compatible with AsyncIterator<Dirent> (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Dec 1, 2024
1 parent 91f72a8 commit e45de25
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/emulation/dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Dirent implements _Dirent {
/**
* A class representing a directory stream.
*/
export class Dir implements _Dir {
export class Dir implements _Dir, AsyncIterator<Dirent> {
protected closed = false;

protected checkClosed(): void {
Expand Down Expand Up @@ -132,7 +132,11 @@ export class Dir implements _Dir {
/**
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
*/
public [Symbol.asyncIterator](): AsyncIterableIterator<Dirent> {
public [Symbol.asyncIterator](): this {
return this;
}

public [Symbol.asyncDispose]() {
return Promise.resolve();
}
}

0 comments on commit e45de25

Please sign in to comment.