| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dc024d9 commit b8c6ced
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ const { | |||
| 11 | 11 | Symbol, | |
| 12 | 12 | } = primordials; | |
| 13 | 13 | const { | |
| 14 | - kDestroyed, | ||
| 14 | + kIsDestroyed, | ||
| 15 | 15 | isDestroyed, | |
| 16 | 16 | isFinished, | |
| 17 | 17 | isServerRequest, | |
@@ -327,7 +327,7 @@ function destroyer(stream, err) { | |||
| 327 | 327 | } | |
| 328 | 328 | ||
| 329 | 329 | if (!stream.destroyed) { | |
| 330 | - stream[kDestroyed] = true; | ||
| 330 | + stream[kIsDestroyed] = true; | ||
| 331 | 331 | } | |
| 332 | 332 | } | |
| 333 | 333 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,20 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - Symbol, | ||
| 5 | 4 | SymbolAsyncIterator, | |
| 6 | 5 | SymbolIterator, | |
| 7 | 6 | SymbolFor, | |
| 8 | 7 | } = primordials; | |
| 9 | 8 | ||
| 10 | - const kDestroyed = Symbol('kDestroyed'); | ||
| 11 | - const kIsErrored = Symbol('kIsErrored'); | ||
| 12 | - const kIsReadable = Symbol('kIsReadable'); | ||
| 13 | - const kIsDisturbed = Symbol('kIsDisturbed'); | ||
| 9 | + // We need to use SymbolFor to make these globally available | ||
| 10 | + // for interopt with readable-stream, i.e. readable-stream | ||
| 11 | + // and node core needs to be able to read/write private state | ||
| 12 | + // from each other for proper interoperability. | ||
| 13 | + const kIsDestroyed = SymbolFor('nodejs.stream.destroyed'); | ||
| 14 | + const kIsErrored = SymbolFor('nodejs.stream.errored'); | ||
| 15 | + const kIsReadable = SymbolFor('nodejs.stream.readable'); | ||
| 16 | + const kIsWritable = SymbolFor('nodejs.stream.writable'); | ||
| 17 | + const kIsDisturbed = SymbolFor('nodejs.stream.disturbed'); | ||
| 14 | 18 | ||
| 15 | 19 | const kIsClosedPromise = SymbolFor('nodejs.webstream.isClosedPromise'); | |
| 16 | 20 | const kControllerErrorFunction = SymbolFor('nodejs.webstream.controllerErrorFunction'); | |
@@ -104,7 +108,7 @@ function isDestroyed(stream) { | |||
| 104 | 108 | const wState = stream._writableState; | |
| 105 | 109 | const rState = stream._readableState; | |
| 106 | 110 | const state = wState || rState; | |
| 107 | - return !!(stream.destroyed || stream[kDestroyed] || state?.destroyed); | ||
| 111 | + return !!(stream.destroyed || stream[kIsDestroyed] || state?.destroyed); | ||
| 108 | 112 | } | |
| 109 | 113 | ||
| 110 | 114 | // Have been end():d. | |
@@ -162,6 +166,7 @@ function isReadable(stream) { | |||
| 162 | 166 | } | |
| 163 | 167 | ||
| 164 | 168 | function isWritable(stream) { | |
| 169 | + if (stream && stream[kIsWritable] != null) return stream[kIsWritable]; | ||
| 165 | 170 | if (typeof stream?.writable !== 'boolean') return null; | |
| 166 | 171 | if (isDestroyed(stream)) return false; | |
| 167 | 172 | return isWritableNodeStream(stream) && | |
@@ -298,7 +303,8 @@ function isErrored(stream) { | |||
| 298 | 303 | } | |
| 299 | 304 | ||
| 300 | 305 | module.exports = { | |
| 301 | - kDestroyed, | ||
| 306 | + isDestroyed, | ||
| 307 | + kIsDestroyed, | ||
| 302 | 308 | isDisturbed, | |
| 303 | 309 | kIsDisturbed, | |
| 304 | 310 | isErrored, | |
@@ -307,8 +313,8 @@ module.exports = { | |||
| 307 | 313 | kIsReadable, | |
| 308 | 314 | kIsClosedPromise, | |
| 309 | 315 | kControllerErrorFunction, | |
| 316 | + kIsWritable, | ||
| 310 | 317 | isClosed, | |
| 311 | - isDestroyed, | ||
| 312 | 318 | isDuplexNodeStream, | |
| 313 | 319 | isFinished, | |
| 314 | 320 | isIterable, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,9 +51,13 @@ const promises = require('stream/promises'); | |||
| 51 | 51 | const utils = require('internal/streams/utils'); | |
| 52 | 52 | ||
| 53 | 53 | const Stream = module.exports = require('internal/streams/legacy').Stream; | |
| 54 | + | ||
| 55 | + Stream.isDestroyed = utils.isDestroyed; | ||
| 54 | 56 | Stream.isDisturbed = utils.isDisturbed; | |
| 55 | 57 | Stream.isErrored = utils.isErrored; | |
| 56 | 58 | Stream.isReadable = utils.isReadable; | |
| 59 | + Stream.isWritable = utils.isWritable; | ||
| 60 | + | ||
| 57 | 61 | Stream.Readable = require('internal/streams/readable'); | |
| 58 | 62 | for (const key of ObjectKeys(streamReturningOperators)) { | |
| 59 | 63 | const op = streamReturningOperators[key]; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments