• path {string|Buffer|URL}
    • options {string|Object}
      • encoding {string} 默认值: 'utf8'
      • withFileTypes {boolean} 默认值: false
    • callback {Function}
      • err {Error}
      • files {string[]|Buffer[]|fs.Dirent[]}

    异步的 readdir(3)。 读取目录的内容。 回调有两个参数 (err, files),其中 files 是目录中文件的名称的数组(不包括 '.''..')。

    可选的 options 参数可以是字符串(指定字符编码)、或具有 encoding 属性(指定用于传给回调的文件名的字符编码)的对象。 如果 encoding 被设置为 'buffer',则返回的文件名会作为 Buffer 对象传入。

    如果 options.withFileTypes 被设置为 true,则 files 数组会包含 [fs.Dirent] 对象。