GeezerVison is showing github.com — lib: make ERM functions into wrappers returning undefined · nodejs/node@cc1aaca
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/fs.md +5-3Lines changed: 5 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -863,7 +863,8 @@ added: | 863 | 863 |
| 864 | 864 | > Stability: 1 - Experimental | 865 | 865 |
| 866 | | -An alias for `filehandle.close()`. | | 866 | +Calls `filehandle.close()` and returns a promise that fulfills when the | | 867 | +filehandle is closed. | 867 | 868 |
| 868 | 869 | ### `fsPromises.access(path[, mode])` | 869 | 870 |
| @@ -6753,7 +6754,8 @@ added: v24.1.0 | 6753 | 6754 |
| 6754 | 6755 | > Stability: 1 - Experimental | 6755 | 6756 |
| 6756 | | -An alias for `dir.close()`. | | 6757 | +Calls `dir.close()` and returns a promise that fulfills when the | | 6758 | +dir is closed. | 6757 | 6759 |
| 6758 | 6760 | #### `dir[Symbol.Dispose]()` | 6759 | 6761 |
| @@ -6763,7 +6765,7 @@ added: v24.1.0 | 6763 | 6765 |
| 6764 | 6766 | > Stability: 1 - Experimental | 6765 | 6767 |
| 6766 | | -An alias for `dir.closeSync()`. | | 6768 | +Calls `dir.closeSync()` and returns `undefined`. | 6767 | 6769 |
| 6768 | 6770 | ### Class: `fs.Dirent` | 6769 | 6771 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/_http_server.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -581,7 +581,7 @@ Server.prototype.close = function close() { | 581 | 581 | }; | 582 | 582 |
| 583 | 583 | Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() { | 584 | | - return promisify(this.close).call(this); | | 584 | + await promisify(this.close).call(this); | 585 | 585 | }); | 586 | 586 |
| 587 | 587 | Server.prototype.closeAllConnections = function closeAllConnections() { | |
Collapse file Copy file name to clipboardExpand all lines: lib/dgram.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -802,7 +802,7 @@ Socket.prototype[SymbolAsyncDispose] = async function() { | 802 | 802 | if (!this[kStateSymbol].handle) { | 803 | 803 | return; | 804 | 804 | } | 805 | | - return FunctionPrototypeCall(promisify(this.close), this); | | 805 | + await FunctionPrototypeCall(promisify(this.close), this); | 806 | 806 | }; | 807 | 807 |
| 808 | 808 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/https.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -117,7 +117,7 @@ Server.prototype.close = function close() { | 117 | 117 | }; | 118 | 118 |
| 119 | 119 | Server.prototype[SymbolAsyncDispose] = async function() { | 120 | | - return FunctionPrototypeCall(promisify(this.close), this); | | 120 | + await FunctionPrototypeCall(promisify(this.close), this); | 121 | 121 | }; | 122 | 122 |
| 123 | 123 | /** | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/fs/dir.js +12-5Lines changed: 12 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,7 +23,10 @@ const { | 23 | 23 | } = require('internal/errors'); | 24 | 24 |
| 25 | 25 | const { FSReqCallback } = binding; | 26 | | -const internalUtil = require('internal/util'); | | 26 | +const { | | 27 | + assignFunctionName, | | 28 | + promisify, | | 29 | +} = require('internal/util'); | 27 | 30 | const { | 28 | 31 | getDirent, | 29 | 32 | getOptions, | @@ -59,9 +62,9 @@ class Dir { | 59 | 62 | validateUint32(this.#options.bufferSize, 'options.bufferSize', true); | 60 | 63 |
| 61 | 64 | this.#readPromisified = FunctionPrototypeBind( | 62 | | - internalUtil.promisify(this.#readImpl), this, false); | | 65 | + promisify(this.#readImpl), this, false); | 63 | 66 | this.#closePromisified = FunctionPrototypeBind( | 64 | | - internalUtil.promisify(this.close), this); | | 67 | + promisify(this.close), this); | 65 | 68 | } | 66 | 69 |
| 67 | 70 | get path() { | @@ -304,12 +307,16 @@ ObjectDefineProperties(Dir.prototype, { | 304 | 307 | [SymbolDispose]: { | 305 | 308 | __proto__: null, | 306 | 309 | ...nonEnumerableDescriptor, | 307 | | - value: Dir.prototype.closeSync, | | 310 | + value: assignFunctionName(SymbolDispose, function() { | | 311 | + this.closeSync(); | | 312 | + }), | 308 | 313 | }, | 309 | 314 | [SymbolAsyncDispose]: { | 310 | 315 | __proto__: null, | 311 | 316 | ...nonEnumerableDescriptor, | 312 | | - value: Dir.prototype.close, | | 317 | + value: assignFunctionName(SymbolAsyncDispose, function() { | | 318 | + this.close(); | | 319 | + }), | 313 | 320 | }, | 314 | 321 | [SymbolAsyncIterator]: { | 315 | 322 | __proto__: null, | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/fs/promises.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -273,7 +273,7 @@ class FileHandle extends EventEmitter { | 273 | 273 | }; | 274 | 274 |
| 275 | 275 | async [SymbolAsyncDispose]() { | 276 | | - return this.close(); | | 276 | + await this.close(); | 277 | 277 | } | 278 | 278 |
| 279 | 279 | /** | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3340,7 +3340,7 @@ class Http2Server extends NETServer { | 3340 | 3340 | } | 3341 | 3341 |
| 3342 | 3342 | async [SymbolAsyncDispose]() { | 3343 | | - return promisify(super.close).call(this); | | 3343 | + await promisify(super.close).call(this); | 3344 | 3344 | } | 3345 | 3345 | } | 3346 | 3346 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/readline/interface.js +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,10 @@ const { | 51 | 51 | validateString, | 52 | 52 | validateUint32, | 53 | 53 | } = require('internal/validators'); | 54 | | -const { kEmptyObject } = require('internal/util'); | | 54 | +const { | | 55 | + assignFunctionName, | | 56 | + kEmptyObject, | | 57 | +} = require('internal/util'); | 55 | 58 | const { | 56 | 59 | inspect, | 57 | 60 | getStringWidth, | @@ -1637,7 +1640,9 @@ class Interface extends InterfaceConstructor { | 1637 | 1640 | return this[kLineObjectStream]; | 1638 | 1641 | } | 1639 | 1642 | } | 1640 | | -Interface.prototype[SymbolDispose] = Interface.prototype.close; | | 1643 | +Interface.prototype[SymbolDispose] = assignFunctionName(SymbolDispose, function() { | | 1644 | + this.close(); | | 1645 | +}); | 1641 | 1646 |
| 1642 | 1647 | module.exports = { | 1643 | 1648 | Interface, | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/streams/readable.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -369,13 +369,13 @@ Readable.prototype[EE.captureRejectionSymbol] = function(err) { | 369 | 369 | this.destroy(err); | 370 | 370 | }; | 371 | 371 |
| 372 | | -Readable.prototype[SymbolAsyncDispose] = function() { | | 372 | +Readable.prototype[SymbolAsyncDispose] = async function() { | 373 | 373 | let error; | 374 | 374 | if (!this.destroyed) { | 375 | 375 | error = this.readableEnded ? null : new AbortError(); | 376 | 376 | this.destroy(error); | 377 | 377 | } | 378 | | - return new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null)))); | | 378 | + await new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null)))); | 379 | 379 | }; | 380 | 380 |
| 381 | 381 | // Manually shove something into the read() buffer. | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/streams/writable.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1149,13 +1149,13 @@ Writable.toWeb = function(streamWritable) { | 1149 | 1149 | return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable); | 1150 | 1150 | }; | 1151 | 1151 |
| 1152 | | -Writable.prototype[SymbolAsyncDispose] = function() { | | 1152 | +Writable.prototype[SymbolAsyncDispose] = async function() { | 1153 | 1153 | let error; | 1154 | 1154 | if (!this.destroyed) { | 1155 | 1155 | error = this.writableFinished ? null : new AbortError(); | 1156 | 1156 | this.destroy(error); | 1157 | 1157 | } | 1158 | | - return new Promise((resolve, reject) => | | 1158 | + await new Promise((resolve, reject) => | 1159 | 1159 | eos(this, (err) => (err && err.name !== 'AbortError' ? reject(err) : resolve(null))), | 1160 | 1160 | ); | 1161 | 1161 | }; |
|