| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent af7047a commit a6d50a1
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1966,6 +1966,34 @@ added: REPLACEME | |||
| 1966 | 1966 | ||
| 1967 | 1967 | Returns whether the stream has been read from or cancelled. | |
| 1968 | 1968 | ||
| 1969 | + ### `stream.Duplex.from(src)` | ||
| 1970 | + <!-- YAML | ||
| 1971 | + added: REPLACEME | ||
| 1972 | + --> | ||
| 1973 | + | ||
| 1974 | + * `src` {Stream|Blob|ArrayBuffer|string|Iterable|AsyncIterable| | ||
| 1975 | + AsyncGeneratorFunction|AsyncFunction|Promise|Object} | ||
| 1976 | + | ||
| 1977 | + A utility method for creating duplex streams. | ||
| 1978 | + | ||
| 1979 | + * `Stream` converts writable stream into writable `Duplex` and readable stream | ||
| 1980 | + to `Duplex`. | ||
| 1981 | + * `Blob` converts into readable `Duplex`. | ||
| 1982 | + * `string` converts into readable `Duplex`. | ||
| 1983 | + * `ArrayBuffer` converts into readable `Duplex`. | ||
| 1984 | + * `AsyncIterable` converts into a readable `Duplex`. Cannot yield | ||
| 1985 | + `null`. | ||
| 1986 | + * `AsyncGeneratorFunction` converts into a readable/writable transform | ||
| 1987 | + `Duplex`. Must take a source `AsyncIterable` as first parameter. Cannot yield | ||
| 1988 | + `null`. | ||
| 1989 | + * `AsyncFunction` converts into a writable `Duplex`. Must return | ||
| 1990 | + either `null` or `undefined` | ||
| 1991 | + * `Object ({ writable, readable })` converts `readable` and | ||
| 1992 | + `writable` into `Stream` and then combines them into `Duplex` where the | ||
| 1993 | + `Duplex` will write to the `writable` and read from the `readable`. | ||
| 1994 | + * `Promise` converts into readable `Duplex`. Value `null` is ignored. | ||
| 1995 | + * Returns: {stream.Duplex} | ||
| 1996 | + | ||
| 1969 | 1997 | ### `stream.addAbortSignal(signal, stream)` | |
| 1970 | 1998 | <!-- YAML | |
| 1971 | 1999 | added: v15.4.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -307,6 +307,7 @@ function isRequest(stream) { | |||
| 307 | 307 | ||
| 308 | 308 | // Normalize destroy for legacy. | |
| 309 | 309 | function destroyer(stream, err) { | |
| 310 | + if (!stream) return; | ||
| 310 | 311 | if (isRequest(stream)) return stream.abort(); | |
| 311 | 312 | if (isRequest(stream.req)) return stream.req.abort(); | |
| 312 | 313 | if (typeof stream.destroy === 'function') return stream.destroy(err); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,3 +108,12 @@ ObjectDefineProperties(Duplex.prototype, { | |||
| 108 | 108 | } | |
| 109 | 109 | } | |
| 110 | 110 | }); | |
| 111 | + | ||
| 112 | + let duplexify; | ||
| 113 | + | ||
| 114 | + Duplex.from = function(body) { | ||
| 115 | + if (!duplexify) { | ||
| 116 | + duplexify = require('internal/streams/duplexify'); | ||
| 117 | + } | ||
| 118 | + return duplexify(body, 'body'); | ||
| 119 | + }; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments