filehandle.close()
- 返回: <Promise> 成功时将使用
undefined
履行。
等待句柄上的任何未决操作完成后,关闭文件句柄。
import { open } from 'fs/promises';
let filehandle;
try {
filehandle = await open('thefile.txt', 'r');
} finally {
await filehandle?.close();
}
- Returns: <Promise> Fulfills with
undefined
upon success.
Closes the file handle after waiting for any pending operation on the handle to complete.
import { open } from 'fs/promises';
let filehandle;
try {
filehandle = await open('thefile.txt', 'r');
} finally {
await filehandle?.close();
}