-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: proper
instanceof
for Writable
s
Use `[Symbol.hasInstance]()` to return `true` when asking for `new Duplex() instanceof Writable`. PR-URL: #8834 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
- Loading branch information
1 parent
1a4207d
commit 4e7c67c
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const { Readable, Writable, Duplex, Transform } = require('stream'); | ||
|
||
const readable = new Readable({ read() {} }); | ||
const writable = new Writable({ write() {} }); | ||
const duplex = new Duplex({ read() {}, write() {} }); | ||
const transform = new Transform({ transform() {} }); | ||
|
||
assert.ok(readable instanceof Readable); | ||
assert.ok(!(writable instanceof Readable)); | ||
assert.ok(duplex instanceof Readable); | ||
assert.ok(transform instanceof Readable); | ||
|
||
assert.ok(!(readable instanceof Writable)); | ||
assert.ok(writable instanceof Writable); | ||
assert.ok(duplex instanceof Writable); | ||
assert.ok(transform instanceof Writable); | ||
|
||
assert.ok(!(readable instanceof Duplex)); | ||
assert.ok(!(writable instanceof Duplex)); | ||
assert.ok(duplex instanceof Duplex); | ||
assert.ok(transform instanceof Duplex); | ||
|
||
assert.ok(!(readable instanceof Transform)); | ||
assert.ok(!(writable instanceof Transform)); | ||
assert.ok(!(duplex instanceof Transform)); | ||
assert.ok(transform instanceof Transform); |