Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 7db3666

Browse files
committed
dezalgo(maybeCallback(arguments)) for closeFromSnapshot
1 parent d80531e commit 7db3666

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

prelude/bootstrap.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,13 @@ var modifyNativeAddonWin32 = (function () {
699699
// close /////////////////////////////////////////////////////////
700700
// ///////////////////////////////////////////////////////////////
701701

702-
function closeFromSnapshot (fd) {
703-
ancestor.closeSync.call(fs, fd);
702+
function closeFromSnapshot (fd, cb) {
704703
delete docks[fd];
704+
if (cb) {
705+
ancestor.close.call(fs, fd, cb);
706+
} else {
707+
return ancestor.closeSync.call(fs, fd);
708+
}
705709
}
706710

707711
fs.closeSync = function (fd) {
@@ -717,17 +721,8 @@ var modifyNativeAddonWin32 = (function () {
717721
return ancestor.close.apply(fs, arguments);
718722
}
719723

720-
var callback = maybeCallback(arguments);
721-
try {
722-
var r = closeFromSnapshot(fd);
723-
process.nextTick(function () {
724-
callback(null, r);
725-
});
726-
} catch (error) {
727-
process.nextTick(function () {
728-
callback(error);
729-
});
730-
}
724+
var callback = dezalgo(maybeCallback(arguments));
725+
closeFromSnapshot(fd, callback);
731726
};
732727

733728
// ///////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)