Fglob
Bun

function

fs.glob

function glob(
pattern: string | readonly string[],
callback: (err: null | ErrnoException, matches: string[]) => void
): void;

Retrieves the files matching the specified pattern.

import { glob } from 'node:fs';

glob('*.js', (err, matches) => {
  if (err) throw err;
  console.log(matches);
});
function glob(
pattern: string | readonly string[],
callback: (err: null | ErrnoException, matches: Dirent<string>[]) => void
): void;

Retrieves the files matching the specified pattern.

import { glob } from 'node:fs';

glob('*.js', (err, matches) => {
  if (err) throw err;
  console.log(matches);
});
function glob(
pattern: string | readonly string[],
callback: (err: null | ErrnoException, matches: string[]) => void
): void;

Retrieves the files matching the specified pattern.

import { glob } from 'node:fs';

glob('*.js', (err, matches) => {
  if (err) throw err;
  console.log(matches);
});
function glob(
pattern: string | readonly string[],
options: GlobOptions,
callback: (err: null | ErrnoException, matches: string[] | Dirent<string>[]) => void
): void;

Retrieves the files matching the specified pattern.

import { glob } from 'node:fs';

glob('*.js', (err, matches) => {
  if (err) throw err;
  console.log(matches);
});

Referenced types

interface GlobOptionsWithFileTypes

  • cwd?: string | URL

    Current working directory.

  • exclude?: readonly string[] | (fileName: Dirent) => boolean

    Function to filter out files/directories or a list of glob patterns to be excluded. If a function is provided, return true to exclude the item, false to include it. If a string array is provided, each string should be a glob pattern that specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are not supported.

  • withFileTypes: true

    true if the glob should return paths as Dirents, false otherwise.

interface GlobOptionsWithoutFileTypes

  • cwd?: string | URL

    Current working directory.

  • exclude?: readonly string[] | (fileName: string) => boolean

    Function to filter out files/directories or a list of glob patterns to be excluded. If a function is provided, return true to exclude the item, false to include it. If a string array is provided, each string should be a glob pattern that specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are not supported.

  • withFileTypes?: false

    true if the glob should return paths as Dirents, false otherwise.

interface GlobOptions

  • cwd?: string | URL

    Current working directory.

  • exclude?: readonly string[] | (fileName: string | Dirent<string>) => boolean

    Function to filter out files/directories or a list of glob patterns to be excluded. If a function is provided, return true to exclude the item, false to include it. If a string array is provided, each string should be a glob pattern that specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are not supported.

  • withFileTypes?: boolean

    true if the glob should return paths as Dirents, false otherwise.