-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: simpler stream constructon #697
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
18 changes: 18 additions & 0 deletions
18
test/parallel/test-stream-readable-constructor-set-methods.js
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,18 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
var Readable = require('stream').Readable; | ||
|
||
var _readCalled = false; | ||
function _read(n) { | ||
_readCalled = true; | ||
this.push(null); | ||
} | ||
|
||
var r = new Readable({ read: _read }); | ||
r.resume(); | ||
|
||
process.on('exit', function () { | ||
assert.equal(r._read, _read); | ||
assert(_readCalled); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/parallel/test-stream-transform-constructor-set-methods.js
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,31 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
var Transform = require('stream').Transform; | ||
|
||
var _transformCalled = false; | ||
function _transform(d, e, n) { | ||
_transformCalled = true; | ||
n(); | ||
} | ||
|
||
var _flushCalled = false; | ||
function _flush(n) { | ||
_flushCalled = true; | ||
n(); | ||
} | ||
|
||
var t = new Transform({ | ||
transform: _transform, | ||
flush: _flush | ||
}); | ||
|
||
t.end(new Buffer('blerg')); | ||
t.resume(); | ||
|
||
process.on('exit', function () { | ||
assert.equal(t._transform, _transform); | ||
assert.equal(t._flush, _flush); | ||
assert(_transformCalled); | ||
assert(_flushCalled); | ||
}); |
34 changes: 34 additions & 0 deletions
34
test/parallel/test-stream-writable-constructor-set-methods.js
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,34 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
|
||
var Writable = require('stream').Writable; | ||
|
||
var _writeCalled = false; | ||
function _write(d, e, n) { | ||
_writeCalled = true; | ||
} | ||
|
||
var w = new Writable({ write: _write }); | ||
w.end(new Buffer('blerg')); | ||
|
||
var _writevCalled = false; | ||
var dLength = 0; | ||
function _writev(d, n) { | ||
dLength = d.length; | ||
_writevCalled = true; | ||
} | ||
|
||
var w2 = new Writable({ writev: _writev }); | ||
w2.cork(); | ||
|
||
w2.write(new Buffer('blerg')); | ||
w2.write(new Buffer('blerg')); | ||
w2.end(); | ||
|
||
process.on('exit', function () { | ||
assert.equal(w._write, _write); | ||
assert(_writeCalled); | ||
assert.equal(w._writev, _writev); | ||
assert.equal(dLength, 2); | ||
assert(_writevCalled); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are lovely illustrations of how you no longer need to subclass for simple cases. I might even call that out as an explicit benefit.