From e45de25c0c36013001e49dc22469da879f9809fa Mon Sep 17 00:00:00 2001 From: James Prevett Date: Sun, 1 Dec 2024 12:26:42 -0600 Subject: [PATCH] Updated `Dir` to be compatible with `AsyncIterator` (#147) --- src/emulation/dir.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/emulation/dir.ts b/src/emulation/dir.ts index c606914e..75790852 100644 --- a/src/emulation/dir.ts +++ b/src/emulation/dir.ts @@ -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 { protected closed = false; protected checkClosed(): void { @@ -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 { + public [Symbol.asyncIterator](): this { return this; } + + public [Symbol.asyncDispose]() { + return Promise.resolve(); + } }