| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe28128 commit 6350213
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,11 +6,13 @@ const { | |||
| 6 | 6 | } = primordials; | |
| 7 | 7 | ||
| 8 | 8 | function isReadable(obj) { | |
| 9 | - return !!(obj && typeof obj.pipe === 'function'); | ||
| 9 | + return !!(obj && typeof obj.pipe === 'function' && | ||
| 10 | + typeof obj.on === 'function'); | ||
| 10 | 11 | } | |
| 11 | 12 | ||
| 12 | 13 | function isWritable(obj) { | |
| 13 | - return !!(obj && typeof obj.write === 'function'); | ||
| 14 | + return !!(obj && typeof obj.write === 'function' && | ||
| 15 | + typeof obj.on === 'function'); | ||
| 14 | 16 | } | |
| 15 | 17 | ||
| 16 | 18 | function isStream(obj) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1247,3 +1247,19 @@ const net = require('net'); | |||
| 1247 | 1247 | () => common.mustNotCall(), | |
| 1248 | 1248 | ); | |
| 1249 | 1249 | } | |
| 1250 | + | ||
| 1251 | + { | ||
| 1252 | + const content = 'abc'; | ||
| 1253 | + pipeline(Buffer.from(content), PassThrough({ objectMode: true }), | ||
| 1254 | + common.mustSucceed(() => {})); | ||
| 1255 | + | ||
| 1256 | + let res = ''; | ||
| 1257 | + pipeline(Buffer.from(content), async function*(previous) { | ||
| 1258 | + for await (const val of previous) { | ||
| 1259 | + res += String.fromCharCode(val); | ||
| 1260 | + yield val; | ||
| 1261 | + } | ||
| 1262 | + }, common.mustSucceed(() => { | ||
| 1263 | + assert.strictEqual(res, content); | ||
| 1264 | + })); | ||
| 1265 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments