Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7ef9c70

Browse filesBrowse files
baruchirodanielleadams
authored andcommitted
fs: replace finally with PromisePrototypeFinally
#35993 (comment) PR-URL: #35995 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 0a4c96a commit 7ef9c70
Copy full SHA for 7ef9c70

File tree

Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Open diff view settings
Collapse file

‎lib/internal/fs/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/promises.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
MathMin,
1616
NumberIsSafeInteger,
1717
Promise,
18+
PromisePrototypeFinally,
1819
PromiseResolve,
1920
Symbol,
2021
Uint8Array,
@@ -431,7 +432,7 @@ async function rename(oldPath, newPath) {
431432

432433
async function truncate(path, len = 0) {
433434
const fd = await open(path, 'r+');
434-
return ftruncate(fd, len).finally(fd.close);
435+
return PromisePrototypeFinally(ftruncate(fd, len), fd.close);
435436
}
436437

437438
async function ftruncate(handle, len = 0) {
@@ -559,7 +560,7 @@ async function lchmod(path, mode) {
559560
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()');
560561

561562
const fd = await open(path, O_WRONLY | O_SYMLINK);
562-
return fchmod(fd, mode).finally(fd.close);
563+
return PromisePrototypeFinally(fchmod(fd, mode), fd.close);
563564
}
564565

565566
async function lchown(path, uid, gid) {
@@ -635,7 +636,7 @@ async function writeFile(path, data, options) {
635636
return writeFileHandle(path, data);
636637

637638
const fd = await open(path, flag, options.mode);
638-
return writeFileHandle(fd, data).finally(fd.close);
639+
return PromisePrototypeFinally(writeFileHandle(fd, data), fd.close);
639640
}
640641

641642
async function appendFile(path, data, options) {
@@ -653,7 +654,7 @@ async function readFile(path, options) {
653654
return readFileHandle(path, options);
654655

655656
const fd = await open(path, flag, 0o666);
656-
return readFileHandle(fd, options).finally(fd.close);
657+
return PromisePrototypeFinally(readFileHandle(fd, options), fd.close);
657658
}
658659

659660
module.exports = {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.