Uh oh!
There was an error while loading. Please reload this page.
doc: explain differences in console.assert between node and browsers - #6169
doc: explain differences in console.assert between node and browsers#6169jasnell wants to merge 2 commits into
Conversation
jasnell
commented
Apr 13, 2016
@nodejs/documentation |
There was a problem hiding this comment.
Why do we need a setPrototypeOf call here?
There was a problem hiding this comment.
actually, the example is incomplete... just noticed... it should be:
constmyConsole=Object.setPrototypeOf({assert(assertion,message, ...args){try{console.assert(assertion,message, ...args);}catch(err){console.error(err.stack);}}},console);Essentially, this creates a simple extension of the existing console object without monkey-patching it.
There was a problem hiding this comment.
Fixed the example in updated commit
There was a problem hiding this comment.
Not sure we should be encouraging such liberal use of setPrototypeOf. A lot of people have strong feelings against it and it sort of lumped in the language by mistake (it's a funny story really).
If we are using it though, why not just:
const myConsole = { __proto__: console,
assert: ... }
There was a problem hiding this comment.
Not sure encouraging use of __proto__ is any better.
Provide an example for implementing browser like behavior for console.assert. This "fixes" nodejs#5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: nodejs#5340
b74e791 to
4c5a6c3Comparejasnell
commented
Apr 18, 2016
ping @nodejs/documentation |
| ``` | ||
| It is important to note that the `console.assert()` method in Node.js is | ||
| implemented differently than the `console.assert()` method available in |
There was a problem hiding this comment.
perhaps a link to https://developer.mozilla.org/en-US/docs/Web/API/Console
eljefedelrodeodeljefe
commented
Apr 18, 2016
LGTM with a nit. |
techjeffharris
commented
Apr 18, 2016
A couple links suggested, but LGTM |
jasnell
commented
Apr 18, 2016
@eljefedelrodeodeljefe@techjeffharris ... updated, PTAL! |
techjeffharris
commented
Apr 18, 2016
Though this PR is only targeting a clarification of console.assert, as log as there's a link to the browser console.assert maybe we should have a link to the general browser console API in the following section: (sorry, not in a place to easily see which line)
Might be more appropriate in another PR...? |
techjeffharris
commented
Apr 18, 2016
The most recent changes LGTM, regardless. |
eljefedelrodeodeljefe
commented
Apr 18, 2016
LGTM. Thx @jasnell. @techjeffharris let's collect those in the wake of nodejs/docs#100 (?) |
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
jasnell
commented
Apr 18, 2016
Landed in 40a5761 |
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
qfox
commented
Apr 20, 2016
This definitely NOT fixes #5340. Sad news everyone. |
jasnell
commented
Apr 20, 2016
The way browsers implement |
qfox
commented
Apr 20, 2016
Thank you. |
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" nodejs#5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: nodejs#5340 PR-URL: nodejs#6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Provide an example for implementing browser like behavior for console.assert. This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired. Fixes: #5340 PR-URL: #6169 Reviewed-By: Robert Jefe Lindstädt <robert.lindstaedt@gmail.com> Reviewed-By: Jeff Harris <@techjeffharris>
Checklist
Affected core subsystem(s)
doc, console
Description of change
Provide an example for implementing browser like behavior for console.assert.
This "fixes" #5340 by providing an alternative to changing Node.js' implemented behavior. Instead, we document the differences and show how to work around them if browser like semantics are desired.
Fixes: #5340