FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

stream: name anonymous functions by maasencioh · Pull Request #9130 · nodejs/node · GitHub

/ node Public

stream: name anonymous functions - #9130

Closed
maasencioh wants to merge 2 commits into
nodejs:masterfrom
maasencioh:name_stream
Closed

stream: name anonymous functions#9130
maasencioh wants to merge 2 commits into
nodejs:masterfrom
maasencioh:name_stream

Conversation

maasencioh commented Oct 17, 2016
edited
Loading

Copy link
Copy Markdown
Contributor
Checklist
  • make -j8 test
  • commit message follows commit guidelines
Description of change

Ref: #8913

For some callbacks I made a change to arrow funtions and for _stream_readable there was a change in Readable.prototype.wrap that I would like some opinions because I'm not sure if it's going to work as spected

nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Oct 17, 2016
mscdex added stream Issues and PRs related to the stream subsystem. and removed lib / src Issues and PRs related to general changes in the lib or src directory. labels Oct 17, 2016
Comment thread lib/_stream_transform.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why add the _ prefix?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is to avoid conflict with afterTransform that is called on next line.

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

since these are being changed to arrow functions, the self can be switched to this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

oups, you're right, thanks

Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe use a camel case name like readableResume ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I was thinking to change it to _resume, in order to be consistent

Comment thread lib/_stream_transform.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is to avoid conflict with afterTransform that is called on next line.

lpinca commented Oct 17, 2016
edited
Loading

Copy link
Copy Markdown
Member

I wonder if some of these changes, like _afterTransform, conflict with #9113.

Copy link
Copy Markdown
Contributor Author

@lpinca I just look at those and we both change _stream_wrap.js but in different lines, so it shouldn't conflict, but thank for pointing it out, I didn't review other PRs

lpinca commented Oct 17, 2016

Copy link
Copy Markdown
Member

@maasencioh my bad, I thought #9113 was proposing an eslint rule to check if names matched. Ignore me.

maasencioh force-pushed the name_stream branch 3 times, most recently from 2d4565b to 5a04861 Compare October 18, 2016 13:31

maasencioh commented Oct 18, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

@jasnell not all the self were removed, because in some cases the arrow funtion was inside a regular function, I run the tests and everithing it's currently passing

rvagg force-pushed the master branch 2 times, most recently from c133999 to 83c7a88 Compare October 18, 2016 17:02
Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Maybe call this one resume and rename the local function to resumeReadable ?

jasnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM if CI is green

targos previously approved these changes Oct 24, 2016

targos commented Oct 24, 2016

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Contributor Author

I'm not sure that the CI failures are related to the changes

Copy link
Copy Markdown
Contributor Author

@jasnell sorry it's anything else needed in this PR?

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Some nits.

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you please revert all of those to function and name them?

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can you please name this one?

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can you please convert this forEach in a for loop, it can probably save us a couple of ticks.

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can you please name this?

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this should be named as well, also can you make this function top level, so that the for loop under can be optimized.

Copy link
Copy Markdown
Member

@maasencioh would you mind addressing the comments above? We can land this!

mcollina added the stalled Issues and PRs that are stalled. label Jan 26, 2017

Copy link
Copy Markdown
Contributor Author

Hello @mcollina, I thought that this was forgotten, but here I just added the new nits

Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why not name this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

sorry I miss that one, I'll check on the other ones

Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Feel free to ignore, but I prefer naming handlers like onEnd, onData, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I wasn't sure which name could be more useful, so this comments are great, thanks

mcollina removed the stalled Issues and PRs that are stalled. label Jan 29, 2017

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

A couple of nits and we are good to go.

Can you squash the commits as well?

Comment thread lib/_stream_writable.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can this have a different name? Like _hasInstancePolyfill?

Comment thread lib/_stream_writable.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can we name this writableHasInstance?

Copy link
Copy Markdown
Contributor Author

how does it looks now @mcollina?

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

are you sure you can use this here?

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

self is not defined anymore in this function.

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why this?

Comment thread lib/_stream_wrap.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can you please revert this to self?

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member

@maasencioh can you swash all the streams commit into one? I think it'd be easier to move around.

Copy link
Copy Markdown
Contributor Author

@mcollina I took my time to make it completely like it should be, I changed everything, but I hope that all it's correct now

Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think the norm is to omit the space after the function name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@TimothyGu any tip to run the linter and test only on this files? thanks

Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you restore these spaces?

Copy link
Copy Markdown
Contributor Author

@mcollina what do you think now? any tip to run the linter and test only on this files? thanks

targos commented Feb 21, 2017

Copy link
Copy Markdown
Member

@maasencioh run make jslint to run the linter. It will check all files the first time but the results are cached so subsequent runs should only check modified files.

Copy link
Copy Markdown
Member

LGTM if ci is green.

Copy link
Copy Markdown
Contributor Author

@jasnell @mcollina @targos could you please help me whith this doubt?

I renamed a function as proposed like this:

Object.defineProperty(Writable, Symbol.hasInstance, {
  value: function writableHasInstance(object) {
    if (realHasInstance.call(this, object))
      return true;

    return object && object._writableState instanceof WritableState;
  }
});

But currently this throws a jslint error

137:5  error  Function name `writableHasInstance` should match property name `value`             func-name-matching

Should I follow the func-name-matching rule? because this will force me to rename several functions to avoid conflicts

Copy link
Copy Markdown
Member

@maasencioh I think you can go ahead and leave that function anonymous.

Copy link
Copy Markdown
Member

@maasencioh, alternatively, you can use an ESLint annotation to suppress that error. See this example in lib/internal/url.js.

jasnell added the stalled Issues and PRs that are stalled. label Mar 24, 2017

fhinkel commented May 26, 2017

Copy link
Copy Markdown
Contributor

There hasn't been any activity here. I'm closing this. Feel free to reopen (or ping a collaborator) if I closed this in error.

fhinkel closed this May 26, 2017
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stalled Issues and PRs that are stalled. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants


Back | FazBrowse Home | New Git URL