Options
All
  • Public
  • Public/Protected
  • All
Menu

get-all-files-ts

Index

Functions

Const getAllFiles

  • getAllFiles(filename: string, options?: OptionsParameters): { toArray: () => Promise<(undefined | string)[]>; [asyncIterator]: any }
  • Returns a lazy async iterable/iterator that asynchronously iterates over the file paths recursively found at path in no particular order.

    Calling toArray on the returned value returns a promise that resolves to an array of the file paths.

    example
     import { getAllFiles } from 'get-all-files';

    // Lazily iterate over filenames asynchronously
    for await (const filename of getAllFiles(`path/to/dir/or/file`)) {
    // Could break early on some condition and get-all-files
    // won't have unnecessarily accumulated the filenames in an array
    console.log(filename)
    }

    // Get array of filenames asynchronously
    console.log(await getAllFiles(`path/to/dir/or/file`).toArray())
    async

    Iterable / Iterator

    Parameters

    • filename: string

      entry point path to look for files

    • Optional options: OptionsParameters

      wether to use absolute or relative paths and excluded dirs

    Returns { toArray: () => Promise<(undefined | string)[]>; [asyncIterator]: any }

    an Iterator with a .toString() helper function to return a list of filenames

    • toArray: () => Promise<(undefined | string)[]>
        • (): Promise<(undefined | string)[]>
        • Returns Promise<(undefined | string)[]>

    • [asyncIterator]:function
      • [asyncIterator](): AsyncGenerator<undefined | string, void, unknown>
      • Returns AsyncGenerator<undefined | string, void, unknown>

Const getAllFilesSync

  • getAllFilesSync(filename: string, options?: OptionsParameters): { toArray: () => string[]; [iterator]: any }
  • Returns a lazy iterable / iterator that iterates over the file paths recursively found at path in no particular order.

    Calling toArray on the returned value returns an array of the file paths.

    example
    import { getAllFilesSync } from 'get-all-files'
    // Lazily iterate over filenames synchronously
    for (const filename of getAllFilesSync(`path/to/dir/or/file`)) {
    // Could break early on some condition and get-all-files
    // won't have unnecessarily accumulated the filenames in an array
    console.log(filename)
    }

    // Get array of filenames synchronously
    console.log(getAllFilesSync(`path/to/dir/or/file`).toArray());

    Parameters

    • filename: string

      entry point path to look for files

    • Optional options: OptionsParameters

      wether to use absolute or relative paths and excluded dirs

    Returns { toArray: () => string[]; [iterator]: any }

    an Iterator with a .toString() helper function to return a list of filenames

    • toArray: () => string[]
        • (): string[]
        • Returns string[]

    • [iterator]:function
      • [iterator](): Generator<unknown, void, unknown>
      • Returns Generator<unknown, void, unknown>

Generated using TypeDoc