@@ -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
432433async 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
437438async 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
565566async 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
641642async 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
659660module . exports = {
0 commit comments