happy-opfs
    Preparing search index...

    Function readDirSync

    • Synchronous version of readDir. Reads the contents of a directory without file metadata.

      Each entry carries only path and kind: no per-file getFile() lookup is performed and the response stays small, which is what makes listing a large tree feasible. Read metadata with statSync when it is actually needed.

      Parameters

      • dirPath: string

        The absolute path of the directory to read.

      • options: ReadDirSyncOptions & { withMetadata: false }

        Read options with withMetadata: false.

      Returns IOResult<DirEntrySlim[]>

      An IOResult containing an array of directory entries without metadata.

      readDirSync for the metadata-carrying overload

      2.3.0

      readDirSync('/documents', { recursive: true, withMetadata: false })
      .inspect(entries => entries.forEach(entry => console.log(entry.path, entry.kind)));
    • Synchronous version of readDir. Reads the contents of a directory.

      Note: Returns DirEntryLike[] instead of AsyncIterableIterator<DirEntry> because:

      1. Sync API cannot return async iterators
      2. Native FileSystemHandle objects cannot be serialized across threads; DirEntryLike uses FileSystemHandleLike which is JSON-serializable

      Pass { withMetadata: false } to skip the per-file metadata lookup and get DirEntrySlim[] instead, which keeps the response small when listing a large tree.

      Parameters

      • dirPath: string

        The absolute path of the directory to read.

      • Optionaloptions: ReadDirSyncOptions

        Optional read options (e.g., recursive).

      Returns IOResult<DirEntryLike[]>

      An IOResult containing an array of directory entries.

      readDir for the async version.

      1.1.0

      readDirSync('/documents')
      .inspect(entries => entries.forEach(e => console.log(e.path, e.handle.kind)));