Function lsDirs

  • Lists files in the specified directory path, filtering by a regular expression pattern.

    The returned entries are configurable using the additional options, such as listing recursively to subdirectories, and filter specific file and/or directory names using a regular expression.

    The additional options can be an object or a regex pattern to specify only the match field. If passed as a RegExp object, the rest options (except the match field) for reading the directory will uses default options.

    If the options argument not specified (or undefined), then it uses the default value:

    [LsOptions]: {
    encoding: 'utf8',
    recursive: false,
    match: /.+/,
    exclude: undefined
    }

    History

    1.0.0

    As of version 1.0.0, this function now accepts file URL paths. This can be either a string URL path or a URL object, and it must follow the 'file:' protocol. An URIError will be thrown if the specified file URL path has invalid file URL syntax or is used with unsupported protocols.

    0.1.0

    Added in version 0.1.0.

    Parameters

    • dirpath: string | URL

      The directory path to search, must be a Node path (i.e., similar to POSIX path) or a valid file URL path.

    • Optional options: RegExp | LsOptions

      Additional options for reading the directory. Refer to LsOptions documentation for more details.

    Returns Promise<LsResult>

    A promise that resolves with an array of string representing the entries result excluding '.' and '..' or an empty array ([]) if any files and directories does not match with the specified filter options.

Generated using TypeDoc v0.25.12