GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: explain differences in console.assert between node and browsers by jasnell · Pull Request #6169 · nodejs/node

Conversation

@jasnell

@jasnell jasnell commented Apr 12, 2016

Copy link
Copy Markdown
Member
Checklist
  • documentation is changed or added
  • the commit message follows commit guidelines
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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

stevemao and eljefedelrodeodeljefe reacted with thumbs up emoji qfox and blond reacted with thumbs down emoji blond reacted with confused emoji
All reactions
  • 👍 2 reactions
  • 👎 2 reactions
  • 😕 1 reaction
@jasnell jasnell added doc Issues and PRs related to Node.js documentation. console Issues and PRs related to the console subsystem. labels Apr 12, 2016
@jasnell

jasnell commented Apr 13, 2016

Copy link
Copy Markdown
Member Author

@nodejs/documentation

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr reviewed Apr 13, 2016
View reviewed changes
Comment thread doc/api/console.markdown Outdated

@benjamingr benjamingr Apr 13, 2016

Copy link
Copy Markdown
Member

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 do we need a setPrototypeOf call here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jasnell jasnell Apr 13, 2016

Copy link
Copy Markdown
Member Author

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.

actually, the example is incomplete... just noticed... it should be:

const myConsole = 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jasnell jasnell Apr 13, 2016

Copy link
Copy Markdown
Member Author

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.

Fixed the example in updated commit

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@benjamingr benjamingr Apr 13, 2016

Copy link
Copy Markdown
Member

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.

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: ... }

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jasnell jasnell Apr 18, 2016

Copy link
Copy Markdown
Member Author

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.

Not sure encouraging use of __proto__ is any better.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jasnell
doc: explain differences in console.assert between node and browsers
4c5a6c3
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
@jasnell
jasnell force-pushed the doc-console-assert branch from b74e791 to 4c5a6c3 Compare April 13, 2016 16:10
@jasnell

jasnell commented Apr 18, 2016

Copy link
Copy Markdown
Member Author

ping @nodejs/documentation

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

techjeffharris
techjeffharris reviewed Apr 18, 2016
View reviewed changes
Comment thread doc/api/console.markdown Outdated
```

It is important to note that the `console.assert()` method in Node.js is
implemented differently than the `console.assert()` method available in

@techjeffharris techjeffharris Apr 18, 2016

Copy link
Copy Markdown
Contributor

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.

perhaps a link to https://developer.mozilla.org/en-US/docs/Web/API/Console

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eljefedelrodeodeljefe

eljefedelrodeodeljefe commented Apr 18, 2016

Copy link
Copy Markdown
Contributor

LGTM with a nit.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@techjeffharris

techjeffharris commented Apr 18, 2016

Copy link
Copy Markdown
Contributor

A couple links suggested, but LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell
Address nits
1d55036
@jasnell

jasnell commented Apr 18, 2016

Copy link
Copy Markdown
Member Author

@eljefedelrodeodeljefe @techjeffharris ... updated, PTAL!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@techjeffharris

techjeffharris commented Apr 18, 2016

Copy link
Copy Markdown
Contributor

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)

While the API for the Console class is designed fundamentally around the browser console object, the Console in Node.js is not intended to duplicate the browser's functionality exactly.

Might be more appropriate in another PR...?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@techjeffharris

techjeffharris commented Apr 18, 2016

Copy link
Copy Markdown
Contributor

The most recent changes LGTM, regardless.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eljefedelrodeodeljefe

eljefedelrodeodeljefe commented Apr 18, 2016

Copy link
Copy Markdown
Contributor

LGTM. Thx @jasnell. @techjeffharris let's collect those in the wake of nodejs/docs#100 (?)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell added a commit that referenced this pull request Apr 18, 2016
@jasnell
doc: explain differences in console.assert between node and browsers
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
@jasnell

jasnell commented Apr 18, 2016

Copy link
Copy Markdown
Member Author

Landed in 40a5761

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Apr 18, 2016
@jasnell jasnell added the lts-watch-v4.x label Apr 18, 2016
MylesBorins pushed a commit that referenced this pull request Apr 19, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
8fd0bc0
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
2190fcb
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
46f774f
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
@MylesBorins MylesBorins mentioned this pull request Apr 20, 2016
V5.10.2 proposal #6311
Closed
@qfox

qfox commented Apr 20, 2016

Copy link
Copy Markdown

This definitely NOT fixes #5340. Sad news everyone.
Can you please explain why you prefer non-standard behaviour?

blond reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Apr 20, 2016

Copy link
Copy Markdown
Member Author

The way browsers implement console is not standard (see: https://developer.mozilla.org/en-US/docs/Web/API/Console). This has been discussed before and it has been decided that it is not a priority for Node.js to align with the browsers on the non-standardized behavior of console.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@qfox

qfox commented Apr 20, 2016

Copy link
Copy Markdown

Thank you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
3bc3152
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
This was referenced Apr 21, 2016
V5.11.0 proposal #6321
Closed
V5.11.0 proposal #6322
Closed
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
@jasnell @MylesBorins
doc: explain differences in console.assert between node and browsers
5c4395b
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request Apr 25, 2016
@jasnell @joelostrowski
doc: explain differences in console.assert between node and browsers
070acff
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
jasnell added a commit that referenced this pull request Apr 26, 2016
@jasnell
doc: explain differences in console.assert between node and browsers
ebf20ed
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
MylesBorins pushed a commit that referenced this pull request May 3, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
ad91bed
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
@MylesBorins MylesBorins added land-on-v4.x and removed lts-watch-v4.x labels May 3, 2016
MylesBorins pushed a commit that referenced this pull request May 6, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
909390e
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
MylesBorins pushed a commit that referenced this pull request May 18, 2016
@jasnell Myles Borins
doc: explain differences in console.assert between node and browsers
4ec9ae8
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 <[email protected]>
Reviewed-By: Jeff Harris <@techjeffharris>
@MylesBorins MylesBorins mentioned this pull request May 18, 2016
v4.4.5 proposal #6824
Merged
@blond blond mentioned this pull request Jun 2, 2016
Init implementation blond/teamcity-build-queue#1
Merged
@BridgeAR BridgeAR mentioned this pull request Dec 16, 2017
console: make .assert standard compliant #17706
Closed
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

console Issues and PRs related to the console subsystem. doc Issues and PRs related to Node.js documentation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

console.assert throwing behaviour and Console object

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@jasnell @eljefedelrodeodeljefe @techjeffharris @qfox @benjamingr @MylesBorins
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.