| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cb632e4 commit 92348a9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1608,10 +1608,13 @@ This is the synchronous version of [`fs.chown()`][]. | |||
| 1608 | 1608 | ||
| 1609 | 1609 | See also: chown(2). | |
| 1610 | 1610 | ||
| 1611 | - ## `fs.close(fd, callback)` | ||
| 1611 | + ## `fs.close(fd[, callback])` | ||
| 1612 | 1612 | <!-- YAML | |
| 1613 | 1613 | added: v0.0.2 | |
| 1614 | 1614 | changes: | |
| 1615 | + - version: REPLACEME | ||
| 1616 | + pr-url: https://github.com/nodejs/node/pull/37174 | ||
| 1617 | + description: A default callback is now used if one is not provided. | ||
| 1615 | 1618 | - version: v10.0.0 | |
| 1616 | 1619 | pr-url: https://github.com/nodejs/node/pull/12562 | |
| 1617 | 1620 | description: The `callback` parameter is no longer optional. Not passing | |
@@ -1632,6 +1635,9 @@ to the completion callback. | |||
| 1632 | 1635 | Calling `fs.close()` on any file descriptor (`fd`) that is currently in use | |
| 1633 | 1636 | through any other `fs` operation may lead to undefined behavior. | |
| 1634 | 1637 | ||
| 1638 | + If the `callback` argument is omitted, a default callback function that rethrows | ||
| 1639 | + any error as an uncaught exception will be used. | ||
| 1640 | + | ||
| 1635 | 1641 | ## `fs.closeSync(fd)` | |
| 1636 | 1642 | <!-- YAML | |
| 1637 | 1643 | added: v0.1.21 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -434,9 +434,14 @@ function readFileSync(path, options) { | |||
| 434 | 434 | return buffer; | |
| 435 | 435 | } | |
| 436 | 436 | ||
| 437 | - function close(fd, callback) { | ||
| 437 | + function defaultCloseCallback(err) { | ||
| 438 | + if (err != null) throw err; | ||
| 439 | + } | ||
| 440 | + | ||
| 441 | + function close(fd, callback = defaultCloseCallback) { | ||
| 438 | 442 | validateInt32(fd, 'fd', 0); | |
| 439 | - callback = makeCallback(callback); | ||
| 443 | + if (callback !== defaultCloseCallback) | ||
| 444 | + callback = makeCallback(callback); | ||
| 440 | 445 | ||
| 441 | 446 | const req = new FSReqCallback(); | |
| 442 | 447 | req.oncomplete = callback; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments