Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more
Module

x/pastedeno/dev_deps.ts>walk

Universal Pastebin client for Deno/Node
Latest
function walk
import { walk } from "https://deno.land/x/pastedeno@0.6.2/dev_deps.ts";

Recursively walks through a directory and yields information about each file and directory encountered.

Examples

Basic usage

File structure:

folder
β”œβ”€β”€ script.ts
└── foo.ts
import { walk } from "https://deno.land/std@0.224.0/fs/walk.ts";

const entries = [];
for await (const entry of walk(".")) {
  entries.push(entry);
}

entries[0]!.path; // "folder"
entries[0]!.name; // "folder"
entries[0]!.isFile; // false
entries[0]!.isDirectory; // true
entries[0]!.isSymlink; // false

entries[1]!.path; // "folder/script.ts"
entries[1]!.name; // "script.ts"
entries[1]!.isFile; // true
entries[1]!.isDirectory; // false
entries[1]!.isSymlink; // false

Parameters

root: string | URL

The root directory to start the walk from, as a string or URL.

optional
unnamed 1: WalkOptions = [UNSUPPORTED]

The options for the walk.

Returns

AsyncIterableIterator<WalkEntry>

An async iterable iterator that yields WalkEntry objects.