fsPromises.mkdtempDisposable(prefix[, options])
prefix<string> | <Buffer> | <URL>options<string> | <Object>encoding<string> 默认值:'utf8'
- 返回:<Promise> 使用异步可释放对象的 Promise 完成:
path<string> 创建目录的路径。remove<AsyncFunction> 一个用于删除已创建目录的函数。[Symbol.asyncDispose]<AsyncFunction> 与remove相同。
生成的 Promise 包含一个异步可释放的对象,该对象的 path 属性保存所创建的目录路径。当对象被释放时,如果目录仍然存在,则目录及其内容将被异步删除。如果目录无法删除,释放操作将抛出错误。该对象具有一个异步的 remove() 方法,可执行相同的任务。
【The resulting Promise holds an async-disposable object whose path property
holds the created directory path. When the object is disposed, the directory
and its contents will be removed asynchronously if it still exists. If the
directory cannot be deleted, disposal will throw an error. The object has an
async remove() method which will perform the same task.】
这个函数以及结果对象上的释放函数都是异步的,因此应该像 await using dir = await fsPromises.mkdtempDisposable('prefix') 中那样使用 await + await using。
【Both this function and the disposal function on the resulting object are
async, so it should be used with await + await using as in
await using dir = await fsPromises.mkdtempDisposable('prefix').】
有关详细信息,请参阅 fsPromises.mkdtemp() 的文档。
【For detailed information, see the documentation of fsPromises.mkdtemp().】
可选的 options 参数可以是指定编码的字符串,或者是一个具有 encoding 属性的对象,用于指定要使用的字符编码。
【The optional options argument can be a string specifying an encoding, or an
object with an encoding property specifying the character encoding to use.】