| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -228,8 +228,9 @@ function newStreamWritableFromWritableStream(writableStream, options = {}) { | |||
| 228 | 228 | ||
| 229 | 229 | writev(chunks, callback) { | |
| 230 | 230 | function done(error) { | |
| 231 | + error = error.filter((e) => e); | ||
| 231 | 232 | try { | |
| 232 | - callback(error); | ||
| 233 | + callback(error.length === 0 ? undefined : error); | ||
| 233 | 234 | } catch (error) { | |
| 234 | 235 | // In a next tick because this is happening within | |
| 235 | 236 | // a promise context, and if there are any errors | |
@@ -247,7 +248,7 @@ function newStreamWritableFromWritableStream(writableStream, options = {}) { | |||
| 247 | 248 | PromiseAll( | |
| 248 | 249 | ArrayPrototypeMap( | |
| 249 | 250 | chunks, | |
| 250 | - (chunk) => writer.write(chunk))), | ||
| 251 | + (data) => writer.write(data.chunk))), | ||
| 251 | 252 | done, | |
| 252 | 253 | done); | |
| 253 | 254 | }, | |
@@ -633,8 +634,9 @@ function newStreamDuplexFromReadableWritablePair(pair = {}, options = {}) { | |||
| 633 | 634 | ||
| 634 | 635 | writev(chunks, callback) { | |
| 635 | 636 | function done(error) { | |
| 637 | + error = error.filter((e) => e); | ||
| 636 | 638 | try { | |
| 637 | - callback(error); | ||
| 639 | + callback(error.length === 0 ? undefined : error); | ||
| 638 | 640 | } catch (error) { | |
| 639 | 641 | // In a next tick because this is happening within | |
| 640 | 642 | // a promise context, and if there are any errors | |
@@ -652,7 +654,7 @@ function newStreamDuplexFromReadableWritablePair(pair = {}, options = {}) { | |||
| 652 | 654 | PromiseAll( | |
| 653 | 655 | ArrayPrototypeMap( | |
| 654 | 656 | chunks, | |
| 655 | - (chunk) => writer.write(chunk))), | ||
| 657 | + (data) => writer.write(data.chunk))), | ||
| 656 | 658 | done, | |
| 657 | 659 | done); | |
| 658 | 660 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,3 +147,20 @@ const { | |||
| 147 | 147 | finished(duplex, common.mustCall()); | |
| 148 | 148 | pipeline(readable, duplex, writable, common.mustCall()); | |
| 149 | 149 | } | |
| 150 | + | ||
| 151 | + { | ||
| 152 | + const transform = new TransformStream(); | ||
| 153 | + const duplex = newStreamDuplexFromReadableWritablePair(transform); | ||
| 154 | + duplex.setEncoding('utf-8'); | ||
| 155 | + duplex.on('data', common.mustCall((data) => { | ||
| 156 | + assert.strictEqual(data, 'hello'); | ||
| 157 | + }, 5)); | ||
| 158 | + | ||
| 159 | + duplex.write(Buffer.from('hello')); | ||
| 160 | + duplex.write(Buffer.from('hello')); | ||
| 161 | + duplex.write(Buffer.from('hello')); | ||
| 162 | + duplex.write(Buffer.from('hello')); | ||
| 163 | + duplex.write(Buffer.from('hello')); | ||
| 164 | + | ||
| 165 | + duplex.end(); | ||
| 166 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,14 +200,17 @@ class TestSource { | |||
| 200 | 200 | ||
| 201 | 201 | { | |
| 202 | 202 | const writableStream = new WritableStream({ | |
| 203 | - write: common.mustCall(2), | ||
| 203 | + write: common.mustCall(5), | ||
| 204 | 204 | close: common.mustCall(), | |
| 205 | 205 | }); | |
| 206 | 206 | const writable = newStreamWritableFromWritableStream(writableStream); | |
| 207 | 207 | ||
| 208 | 208 | finished(writable, common.mustCall()); | |
| 209 | 209 | ||
| 210 | 210 | writable.write('hello'); | |
| 211 | + writable.write('hello'); | ||
| 212 | + writable.write('hello'); | ||
| 213 | + writable.write('world'); | ||
| 211 | 214 | writable.write('world'); | |
| 212 | 215 | writable.end(); | |
| 213 | 216 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments