Skip to content

Commit

Permalink
feat(fs/unstable): added DirEntry type and conversion function denola…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbronder committed Jan 8, 2025
1 parent 9b86f0f commit e331aec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/_to_dir_entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2018-2025 the Deno authors. MIT license.

import type { DirEntry } from "./unstable_types.ts";

export function toDirEntry(s: import("node:fs").Dirent): DirEntry {
return {
name: s.name,
isFile: s.isFile(),
isDirectory: s.isDirectory(),
isSymlink: s.isSymbolicLink(),
};
}
15 changes: 15 additions & 0 deletions fs/unstable_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,18 @@ export interface FileInfo {
* _Linux/Mac OS only._ */
isSocket: boolean | null;
}

export interface DirEntry {
/** The file name of the entry. It is just the entity name and does not
* include the full path. */
name: string;
/** True if this is info for a regular file. Mutually exclusive to
* `FileInfo.isDirectory` and `FileInfo.isSymlink`. */
isFile: boolean;
/** True if this is info for a regular directory. Mutually exclusive to
* `FileInfo.isFile` and `FileInfo.isSymlink`. */
isDirectory: boolean;
/** True if this is info for a symlink. Mutually exclusive to
* `FileInfo.isFile` and `FileInfo.isDirectory`. */
isSymlink: boolean;
}

0 comments on commit e331aec

Please sign in to comment.