| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -861,7 +861,8 @@ added: | |||
| 861 | 861 | ||
| 862 | 862 | > Stability: 1 - Experimental | |
| 863 | 863 | ||
| 864 | - An alias for `filehandle.close()`. | ||
| 864 | + Calls `filehandle.close()` and returns a promise that fulfills when the | ||
| 865 | + filehandle is closed. | ||
| 865 | 866 | ||
| 866 | 867 | ### `fsPromises.access(path[, mode])` | |
| 867 | 868 | ||
@@ -6745,7 +6746,8 @@ added: REPLACEME | |||
| 6745 | 6746 | ||
| 6746 | 6747 | > Stability: 1 - Experimental | |
| 6747 | 6748 | ||
| 6748 | - An alias for `dir.close()`. | ||
| 6749 | + Calls `dir.close()` and returns a promise that fulfills when the | ||
| 6750 | + dir is closed. | ||
| 6749 | 6751 | ||
| 6750 | 6752 | #### `dir[Symbol.Dispose]()` | |
| 6751 | 6753 | ||
@@ -6755,7 +6757,7 @@ added: REPLACEME | |||
| 6755 | 6757 | ||
| 6756 | 6758 | > Stability: 1 - Experimental | |
| 6757 | 6759 | ||
| 6758 | - An alias for `dir.closeSync()`. | ||
| 6760 | + Calls `dir.closeSync()` and returns `undefined`. | ||
| 6759 | 6761 | ||
| 6760 | 6762 | ### Class: `fs.Dirent` | |
| 6761 | 6763 | ||
| 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() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -800,7 +800,7 @@ Socket.prototype[SymbolAsyncDispose] = async function() { | |||
| 800 | 800 | if (!this[kStateSymbol].handle) { | |
| 801 | 801 | return; | |
| 802 | 802 | } | |
| 803 | - return FunctionPrototypeCall(promisify(this.close), this); | ||
| 803 | + await FunctionPrototypeCall(promisify(this.close), this); | ||
| 804 | 804 | }; | |
| 805 | 805 | ||
| 806 | 806 | ||
| 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 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,12 @@ const { | |||
| 21 | 21 | } = require('internal/errors'); | |
| 22 | 22 | ||
| 23 | 23 | const { FSReqCallback } = binding; | |
| 24 | - const internalUtil = require('internal/util'); | ||
| 24 | + const { | ||
| 25 | + assignFunctionName, | ||
| 26 | + promisify, | ||
| 27 | + SymbolAsyncDispose, | ||
| 28 | + SymbolDispose, | ||
| 29 | + } = require('internal/util'); | ||
| 25 | 30 | const { | |
| 26 | 31 | getDirent, | |
| 27 | 32 | getOptions, | |
@@ -31,10 +36,6 @@ const { | |||
| 31 | 36 | validateFunction, | |
| 32 | 37 | validateUint32, | |
| 33 | 38 | } = require('internal/validators'); | |
| 34 | - const { | ||
| 35 | - SymbolAsyncDispose, | ||
| 36 | - SymbolDispose, | ||
| 37 | - } = internalUtil; | ||
| 38 | 39 | ||
| 39 | 40 | class Dir { | |
| 40 | 41 | #handle; | |
@@ -61,9 +62,9 @@ class Dir { | |||
| 61 | 62 | validateUint32(this.#options.bufferSize, 'options.bufferSize', true); | |
| 62 | 63 | ||
| 63 | 64 | this.#readPromisified = FunctionPrototypeBind( | |
| 64 | - internalUtil.promisify(this.#readImpl), this, false); | ||
| 65 | + promisify(this.#readImpl), this, false); | ||
| 65 | 66 | this.#closePromisified = FunctionPrototypeBind( | |
| 66 | - internalUtil.promisify(this.close), this); | ||
| 67 | + promisify(this.close), this); | ||
| 67 | 68 | } | |
| 68 | 69 | ||
| 69 | 70 | get path() { | |
@@ -306,12 +307,16 @@ ObjectDefineProperties(Dir.prototype, { | |||
| 306 | 307 | [SymbolDispose]: { | |
| 307 | 308 | __proto__: null, | |
| 308 | 309 | ...nonEnumerableDescriptor, | |
| 309 | - value: Dir.prototype.closeSync, | ||
| 310 | + value: assignFunctionName(SymbolDispose, function() { | ||
| 311 | + this.closeSync(); | ||
| 312 | + }), | ||
| 310 | 313 | }, | |
| 311 | 314 | [SymbolAsyncDispose]: { | |
| 312 | 315 | __proto__: null, | |
| 313 | 316 | ...nonEnumerableDescriptor, | |
| 314 | - value: Dir.prototype.close, | ||
| 317 | + value: assignFunctionName(SymbolAsyncDispose, function() { | ||
| 318 | + this.close(); | ||
| 319 | + }), | ||
| 315 | 320 | }, | |
| 316 | 321 | [SymbolAsyncIterator]: { | |
| 317 | 322 | __proto__: null, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -272,7 +272,7 @@ class FileHandle extends EventEmitter { | |||
| 272 | 272 | }; | |
| 273 | 273 | ||
| 274 | 274 | async [SymbolAsyncDispose]() { | |
| 275 | - return this.close(); | ||
| 275 | + await this.close(); | ||
| 276 | 276 | } | |
| 277 | 277 | ||
| 278 | 278 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3342,7 +3342,7 @@ class Http2Server extends NETServer { | |||
| 3342 | 3342 | } | |
| 3343 | 3343 | ||
| 3344 | 3344 | async [SymbolAsyncDispose]() { | |
| 3345 | - return promisify(super.close).call(this); | ||
| 3345 | + await promisify(super.close).call(this); | ||
| 3346 | 3346 | } | |
| 3347 | 3347 | } | |
| 3348 | 3348 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,11 @@ const { | |||
| 47 | 47 | validateString, | |
| 48 | 48 | validateUint32, | |
| 49 | 49 | } = require('internal/validators'); | |
| 50 | - const { SymbolDispose, kEmptyObject } = require('internal/util'); | ||
| 50 | + const { | ||
| 51 | + assignFunctionName, | ||
| 52 | + kEmptyObject, | ||
| 53 | + SymbolDispose, | ||
| 54 | + } = require('internal/util'); | ||
| 51 | 55 | const { | |
| 52 | 56 | inspect, | |
| 53 | 57 | getStringWidth, | |
@@ -1370,7 +1374,9 @@ class Interface extends InterfaceConstructor { | |||
| 1370 | 1374 | return this[kLineObjectStream]; | |
| 1371 | 1375 | } | |
| 1372 | 1376 | } | |
| 1373 | - Interface.prototype[SymbolDispose] = Interface.prototype.close; | ||
| 1377 | + Interface.prototype[SymbolDispose] = assignFunctionName(SymbolDispose, function() { | ||
| 1378 | + this.close(); | ||
| 1379 | + }); | ||
| 1374 | 1380 | ||
| 1375 | 1381 | module.exports = { | |
| 1376 | 1382 | Interface, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -371,13 +371,13 @@ Readable.prototype[EE.captureRejectionSymbol] = function(err) { | |||
| 371 | 371 | this.destroy(err); | |
| 372 | 372 | }; | |
| 373 | 373 | ||
| 374 | - Readable.prototype[SymbolAsyncDispose] = function() { | ||
| 374 | + Readable.prototype[SymbolAsyncDispose] = async function() { | ||
| 375 | 375 | let error; | |
| 376 | 376 | if (!this.destroyed) { | |
| 377 | 377 | error = this.readableEnded ? null : new AbortError(); | |
| 378 | 378 | this.destroy(error); | |
| 379 | 379 | } | |
| 380 | - return new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null)))); | ||
| 380 | + await new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null)))); | ||
| 381 | 381 | }; | |
| 382 | 382 | ||
| 383 | 383 | // Manually shove something into the read() buffer. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1151,13 +1151,13 @@ Writable.toWeb = function(streamWritable) { | |||
| 1151 | 1151 | return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable); | |
| 1152 | 1152 | }; | |
| 1153 | 1153 | ||
| 1154 | - Writable.prototype[SymbolAsyncDispose] = function() { | ||
| 1154 | + Writable.prototype[SymbolAsyncDispose] = async function() { | ||
| 1155 | 1155 | let error; | |
| 1156 | 1156 | if (!this.destroyed) { | |
| 1157 | 1157 | error = this.writableFinished ? null : new AbortError(); | |
| 1158 | 1158 | this.destroy(error); | |
| 1159 | 1159 | } | |
| 1160 | - return new Promise((resolve, reject) => | ||
| 1160 | + await new Promise((resolve, reject) => | ||
| 1161 | 1161 | eos(this, (err) => (err && err.name !== 'AbortError' ? reject(err) : resolve(null))), | |
| 1162 | 1162 | ); | |
| 1163 | 1163 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments