Skip to content
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

util: spec of %d specifier #22885

Closed
shisama opened this issue Sep 16, 2018 · 8 comments
Closed

util: spec of %d specifier #22885

shisama opened this issue Sep 16, 2018 · 8 comments
Labels
console Issues and PRs related to the console subsystem. util Issues and PRs related to the built-in util module.

Comments

@shisama
Copy link
Contributor

shisama commented Sep 16, 2018

Due to a comment from whatwg/console#148 (comment) , does %d specifier have better use parseInt? On Node.js, Number constructor is used for %d. So console.log('%d', false) prints 0 on Node.js but it prints 'NaN` on Google Chrome.
Is it okay if the specification is different from whatwg?

Code: https://github.com/nodejs/node/blob/master/lib/util.js#L294
whatwg spec: https://console.spec.whatwg.org/#formatting-specifiers

@shisama shisama changed the title util: spec for %d specifier util: spec of %d specifier Sep 16, 2018
@targos targos added the util Issues and PRs related to the built-in util module. label Sep 16, 2018
@lovinglyy
Copy link
Contributor

Also, in node, by using Number, decimal places differ from Google Chrome too.
Google Chrome:
console.log('%i', 15.1) // outputs 15
console.log('%d', 15.1) // outputs 15
Node.js:
console.log('%i', 15.1) // outputs 15
console.log('%d', 15.1) // outputs 15.1

It is a contradictory behavior imo.

@Trott
Copy link
Member

Trott commented Sep 17, 2018

/ping @silverwind

@Fishrock123
Copy link
Contributor

I'd rather keep the minor difference (which the Node.js ecosystem is probably used to) rather than loose functionality.

@silverwind
Copy link
Contributor

I think we should take the breaking change and be spec-conformant. Formatting specifiers should be a rarely used feature and I guess most people would use template strings nowadays to interpolate data in strings. Any opinions from @nodejs/tsc?

@devsnek
Copy link
Member

devsnek commented Sep 17, 2018

as long as our console claims to be the whatwg console we should make sure it follows spec. +1 from me

@silverwind silverwind added the console Issues and PRs related to the console subsystem. label Sep 17, 2018
@shisama
Copy link
Contributor Author

shisama commented Oct 6, 2018

Hi 👋 Thank you for your commens.
I have been waiting for some days. However, there seems to be no opinion in half a month.
I want to fix this issue. Can I implement this and create Pull Request?
Please add 👍 if you agree.

@Trott
Copy link
Member

Trott commented Nov 18, 2018

PR is blocked and discussion seems to have run its course. Choices at this point are to close (and optionally pursue a spec change) or escalate to TSC. Thoughts? /ping @shisama

@shisama
Copy link
Contributor Author

shisama commented Nov 25, 2018

@Trott Sorry for my late reply. I closed the PR. Also, I close this. Thank you.

@shisama shisama closed this as completed Nov 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console Issues and PRs related to the console subsystem. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants