Skip to content
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: use nop as write() callback if omitted #564

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const debug = util.debuglog('stream');

util.inherits(Writable, Stream);

function nop() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nop/noop/ ? I have only ever seen the latter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both exist in core.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I personally prefer noop, but nop seems to be used in core too.


function WriteReq(chunk, encoding, cb) {
this.chunk = chunk;
this.encoding = encoding;
Expand Down Expand Up @@ -189,7 +191,7 @@ Writable.prototype.write = function(chunk, encoding, cb) {
encoding = state.defaultEncoding;

if (!util.isFunction(cb))
cb = function() {};
cb = nop;

if (state.ended)
writeAfterEnd(this, state, cb);
Expand Down