fsPromises.mkdtempDisposable(prefix[, options])
-
返回:<Promise> 使用 Promise 实现异步可处置对象:
¥Returns: <Promise> Fulfills with a Promise for an async-disposable Object:
-
path
<string> 已创建目录的路径。¥
path
<string> The path of the created directory. -
remove
<AsyncFunction> 删除已创建目录的函数。¥
remove
<AsyncFunction> A function which removes the created directory. -
[Symbol.asyncDispose]
<AsyncFunction> 与remove
相同。¥
[Symbol.asyncDispose]
<AsyncFunction> The same asremove
.
-
生成的 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.