-
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
doc: improve util._extend
function
#8187
Conversation
044291a
to
a547db8
Compare
// { name: 'Node.js' } | ||
console.log(util._extend({'name': 'Node', 'lang': 'js'}, {'name': 'Node.js'})); | ||
// { name: 'Node.js', lang: 'js' } | ||
``` |
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.
@thefourtheye Do we need an example for deprecated function? its like warn users and teach them how to use it 😄
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.
True. But we have done that in log
too
Thanks for the PR, but I'm not sure that we should improve the docs for this function. |
Although maybe updating the function signature is appropriate :-) |
-1 to all but the function signature change. |
Given the deprecated status, I agree that we likely shouldn't extend the documentation on this. |
a547db8
to
d2c8e9b
Compare
Okay. Fixed the function signature alone now. Hope this is okay. |
@@ -666,7 +666,7 @@ Deprecated predecessor of `console.log`. | |||
|
|||
Deprecated predecessor of `console.log`. | |||
|
|||
### util._extend(obj) | |||
### util._extend(targetObj, sourceObj) |
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.
Should be origin and add to keep consistent with source, see https://github.com/nodejs/node/blob/master/lib/util.js#L976
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.
why not util._extend(target, source)
without obj
suffix ? @yorkie origin/add
combination is confusing.
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.
Both look good to me, but consistence should be considered here.
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.
@yorkie In the case of origin/add
pair, I have code in place to understand what the particular function does. But documentation is the face of the code and we can not expect user to read the code in case of doubt. Its my humble opinion. ( extend the target from source
)
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.
@princejwesley Why do we not change the source to target/source
, too?
LGTM |
@yorkie @princejwesley Renamed the parameter names, for clarity. PTAL. |
LGTM |
LGTM :-) |
LGTM |
@thefourtheye ... can you please rebase and update this? |
5e1a699
to
7aa1e22
Compare
@jasnell Done. I'll land this tomorrow, if there are no other suggestions. |
The function signature of `util._extend` is not intuitive and the documentation doesn't specify the necessary second parameter. This patch changes the parameter names in the code and the function params in doc. PR-URL: nodejs#8187 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: Brian White <[email protected]>
7aa1e22
to
a8c7221
Compare
Landed in b3e7ac2 |
The function signature of `util._extend` is not intuitive and the documentation doesn't specify the necessary second parameter. This patch changes the parameter names in the code and the function params in doc. PR-URL: #8187 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: Brian White <[email protected]>
The function signature of `util._extend` is not intuitive and the documentation doesn't specify the necessary second parameter. This patch changes the parameter names in the code and the function params in doc. PR-URL: nodejs#8187 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: Brian White <[email protected]>
The function signature of `util._extend` is not intuitive and the documentation doesn't specify the necessary second parameter. This patch changes the parameter names in the code and the function params in doc. PR-URL: #8187 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yorkie Liu <[email protected]> Reviewed-By: Brian White <[email protected]>
Checklist
Affected core subsystem(s)
doc, util
Description of change
improve
util._extend
function's documentation