Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/fs/walk.ts>walk

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function walk
import { walk } from "https://deno.land/std@0.153.0/fs/walk.ts";

Walks the file tree rooted at root, yielding each file or directory in the tree filtered according to the given options. The files are walked in lexical order, which makes the output deterministic but means that for very large directories walk() can be inefficient.

Options:

  • maxDepth?: number = Infinity;
  • includeFiles?: boolean = true;
  • includeDirs?: boolean = true;
  • followSymlinks?: boolean = false;
  • exts?: string[];
  • match?: RegExp[];
  • skip?: RegExp[];
      import { walk } from "./walk.ts";
      import { assert } from "../testing/asserts.ts";

      for await (const entry of walk(".")) {
        console.log(entry.path);
        assert(entry.isFile);
      }

Parameters

root: string
optional
unnamed 1: WalkOptions = [UNSUPPORTED]

Returns

AsyncIterableIterator<WalkEntry>