-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: some fixes in repl.md #10160
doc: some fixes in repl.md #10160
Conversation
Add an infix space in an argument list. Change `>` into `> ` in code bits and output examples. Explicitly clarify that default REPL prompt contains a trailing space.
Make `_` reassignment example match more with the current output. Extend the example for more clarity.
`eval` => `myEval` to not shadow the global `eval`
`options` in the `repl.start([options])` can be a string.
The current autoinserted link leads to 404 page.
/cc @nodejs/documentation |
replServer.defineCommand('sayhello', { | ||
help: 'Say hello', | ||
action: function(name) { | ||
action: function sayHello(name) { |
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.
doesn't add any value. I'd rather just leave at is it, but do action: function (name) {
for coding style's sake
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.
I've just thought the docs should promote the style appropriate for the code base:
https://github.com/nodejs/node/pulls?q=is%3Apr+name+anonymous+functions+is%3Aclosed
But if I'm wrong, I'll roll back these two with just space insertion.
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.
I understand. Also I do not have strong feelings about this, but in the /lib
case it would hae value since stack traces might look nicer. Here showing APIs is the prime thing to do. E.g. you will never see full error handling in programming books. Again. I don't mind that's why I left it as a comment.
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.
I see. Well, if nobody will support the additions, I will change as you advise.
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.
Yeah, but I think we only try to do that in cases where the name is not inferred (well) by V8. Here, .name
would just be action
without the hint, I think that’s okay.
If you want to change style here, I’d be +1 on just the action(name) {
shorthand notation
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.
Consider also a method shorthand.
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.
O, I have not seen @addaleax comment)
this.lineParser.reset(); | ||
this.bufferedCommand = ''; | ||
console.log(`Hello, ${name}!`); | ||
this.displayPrompt(); | ||
} | ||
}); | ||
replServer.defineCommand('saybye', function() { | ||
replServer.defineCommand('saybye', function sayBye() { |
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.
same as above
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.
Consider also an arrow function.
* `prompt` {String} The input prompt to display. Defaults to `> `. | ||
* `options` {Object | String} | ||
* `prompt` {String} The input prompt to display. Defaults to `> ` | ||
(with a trailing space). |
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.
(...)-content doesn't add any value.
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.
The trailing space is not shown in the rendered page, it is wiped out. Is this not somehow confusing?
@@ -411,6 +417,8 @@ added: v0.1.91 | |||
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together | |||
with a custom `eval` function. Defaults to `false`. |
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.
maybe add reference to your new name 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.
This eval
is used in multiple places as an abstraction. It is just in the code that it shadows global.
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.
LGTM, with comments, minus one content issue I would rather want to check or in a separate PR.
@@ -411,6 +417,8 @@ added: v0.1.91 | |||
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together | |||
with a custom `eval` function. Defaults to `false`. | |||
|
|||
If `options` is a string, then it specifies the input prompt. | |||
|
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.
Don't know whether this is true. If so it would be a major change in documentation, since also the type is just displaying <Object>
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.
Well, it is almost documented in some examples. See:
https://github.com/nodejs/node/blame/master/doc/api/repl.md#L101
https://github.com/nodejs/node/blame/master/doc/api/repl.md#L120
If it is not official API, maybe we should change these fragments too?
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.
This is actually how it works, although I don't know how "official" it is. See repl.start
and the REPLServer
constructor. I do see examples of this usage all over the place. In addition to what @vsemozhetbyt referenced there is another example here.
Thanks for the PR in any case, since there are apparently still a lot things to do in this file. |
Replaced with an object shorthand and an arrow function.
I've replaced the anonymous functions in more concise ways, maybe they are better now. As to |
test-buffer-creation-regression is flaky on some SmartOS hosts in CI, timing out. Move to sequential so it does not compete with other tests for resources. Reduce three test cases to just the one needed to identify the regression. PR-URL: #10161 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
- changes var to const/let - changes assert.equal to assert.strictEqual PR-URL: #9947 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Currently when running make node_g the following error is displayed: if [ ! -r node -o ! -L ]; then ln -fs out/Debug/node node_g; fi /bin/sh: line 0: [: argument expected It looks like there was a typo for the NODE_EXE where node became lowercase instead of uppercase. Ref: #9827 PR-URL: #10153 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
`global` scope. | ||
declared either implicitly or using the `const` or `let` keywords | ||
are declared at the `global` scope (as well as with the `var` keyword | ||
outside of functions). | ||
|
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.
This seems like a cumbersome distinction between const
and var
, and `let. Couldn't it just be something like this?
"variables declared either implicitly, or using the
const
,let
, orvar
keywords are declared at theglobal
scope."
Especially since the phrase is immediately preceded by "Unless otherwise scoped within blocks or functions".
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.
@lance But it is exactly this remark — "Unless otherwise scoped within blocks or functions" — that prevents placing const
, var
, and let
in the same list: var
is not block scoped. Maybe you or somebody else could propose the whole clear concise sentence there? I am not a native speaker, so I am a bit clumsy there.
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.
var is not block scoped
The const
and let
declarations are block scoped, and the var
declaration is function scoped. I think this sentence covers both. I'm not sure if I have a wording that is clearer.
Unless otherwise scoped within blocks or functions, variables declared either implicitly, or using the
const
,let
, orvar
keywords are declared at the global scope.
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.
Thank you. Done.
Silence coverity warnings about the return value not being checked. PR-URL: #10126 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@chromium.org> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #9899 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Make URLSearchParams constructor spec-compliant - Strip leading `?` in URL#search's setter - Spec-compliant iterable interface - More precise handling of update steps as mandated by the spec - Add class strings to URLSearchParams objects and their prototype - Make sure `this instanceof URLSearchParams` in methods Also included are relevant tests from W3C's Web Platform Tests (https://github.com/w3c/web-platform-tests/tree/master/url). Fixes: #9302 PR-URL: #9484 Reviewed-By: James M Snell <jasnell@gmail.com>
setTimeout at 49:5 requires two arguments. On lines 72 and 73 changed assert.equal() to assert.strictEqual(). PR-URL: #10003 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
In this change, the setTimeout needed a second argument, so I set that value to 1. In addition, I changed the assertion to be a strictEquals instead of equals. I changed the var declarations to const in this test. PR-URL: #9889 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #10168 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
LGTM |
- use const and let for variables - replace assert.equal with assert.strictEqual PR-URL: #10167 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
* use common.mustCall() to confirm number of uncaught exceptions * var -> const * specify duration of 1ms for setTimeout() and setInterval() PR-URL: #10188 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
In test-http-incoming-pipelined-socket-destory: * setTimeout() with no duration -> setImmediate() * eliminate unneeded exit listener * use common.mustCall() * var -> const/let PR-URL: #10189 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #10190 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Oh, I am sorry. It seems I've caused a merge conflict by #10221. What should I do now? |
* use common.mustCall() where appropriate * Buffer.allocUnsafe() -> Buffer.alloc() * do crypto check before loading any additional modules * specify 1ms duration for `setTimeout()` PR-URL: #10225 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@vsemozhetbyt you should rebase this PR and push those changes. This happened because I landed #10221. |
Add an infix space in an argument list. Change `>` into `> ` in code bits and output examples. Explicitly clarify that default REPL prompt contains a trailing space.
Make `_` reassignment example match more with the current output. Extend the example for more clarity.
`eval` => `myEval` to not shadow the global `eval`
`options` in the `repl.start([options])` can be a string.
The current autoinserted link leads to 404 page.
Replaced with an object shorthand and an arrow function.
It will be postponed for more careful evaluating in a separate PR.
Sorry, it seems I've messed this up. I will close now and will redo from scratch( |
`options` in the `repl.start([options])` can be a string. Ref: nodejs#10160 PR-URL: nodejs#10221 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
`options` in the `repl.start([options])` can be a string. Ref: nodejs#10160 PR-URL: nodejs#10221 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Checklist
Affected core subsystem(s)
doc, repl
Description of change
var
=>let
/const
.White space unification (add an infix space in an argument list; change
>
into>
(with a trailing space) in code bits and output examples; explicitly clarify that default REPL prompt contains a trailing space).Fix an output example (make
_
reassignment example match more with the current output; extend the example for more clarity).Fix a function name (
eval
=>myEval
to not shadow the globaleval
).Name anonymous functions.
Add the valid link for curl(1) (The current autoinserted link leads to 404 page).