| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Per the console spec, the label in console.time() is a string.
Per the console spec, the default value of label is `'default'`.
There was a problem hiding this comment.
1 nit
Sorry, something went wrong.
|
|
||
| Console.prototype.time = function time(label) { | ||
| Console.prototype.time = function time(label = 'default') { | ||
| label = `${label}`; |
There was a problem hiding this comment.
Why not simply String(label)?
Sorry, something went wrong.
There was a problem hiding this comment.
@refack I guess it's because String(Symbol('s')) does not throw.
Sorry, something went wrong.
There was a problem hiding this comment.
What a weird language 😖
Sorry, something went wrong.
There was a problem hiding this comment.
Found the piece I was missing, the console IDL - https://console.spec.whatwg.org/#console-namespace
@jasnell could you find a suitable place to reference that in the code?
Sorry, something went wrong.
There was a problem hiding this comment.
Yep, IDL rules are weird. Before ES6 you could also use label + '' but not anymore due to some @@toPrimitive semantics that wouldn't work with Dates.
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe we can write a line of comment to explain this? Or maybe next time who see it will be confused again.
Sorry, something went wrong.
|
|
||
|
|
||
| Console.prototype.time = function time(label) { | ||
| Console.prototype.time = function time(label = 'default') { |
There was a problem hiding this comment.
This is okay because of the method binding in L62?
Sorry, something went wrong.
There was a problem hiding this comment.
What do you mean? It only binds the this value. And for the strictest compliance method.length === 0 because the IDL specifies label as an optional parameter.
Sorry, something went wrong.
There was a problem hiding this comment.
This would have changed the length unless it was bound, which some (@jasnell) consider semver-major.
It does change console.__proto__.time.length a.k.a. console.Console.prototype.time.length.
Sorry, something went wrong.
There was a problem hiding this comment.
FWIW I do think this is semver-major, but because of the default change not .length.
Sorry, something went wrong.
|
|
||
| Console.prototype.time = function time(label) { | ||
| Console.prototype.time = function time(label = 'default') { | ||
| label = `${label}`; |
There was a problem hiding this comment.
Maybe we can write a line of comment to explain this? Or maybe next time who see it will be confused again.
Sorry, something went wrong.
| Console.prototype.time = function time(label) { | ||
| Console.prototype.time = function time(label = 'default') { | ||
| label = `${label}`; | ||
| this._times.set(label, process.hrtime()); |
There was a problem hiding this comment.
Personally, I would just use the template literal in this line and spare the assignment above.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Per the console spec, the label in console.time() is a string. Per the console spec, the default value of label is `'default'`. PR-URL: #14643 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Added assertions to verify that console.time() coerces labels to strings correctly, by comparing against the expected output values of console.timeEnd(). This helps resolve nodejs#14544 but will not address the whole thing. Refs: nodejs#14643
Added assertions to verify that console.time() coerces labels to strings correctly, by comparing against the expected output values of console.timeEnd(). This helps resolve #14544 but will not address the whole thing. PR-URL: #17368 Refs: #14643 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Added assertions to verify that console.time() coerces labels to strings correctly, by comparing against the expected output values of console.timeEnd(). This helps resolve #14544 but will not address the whole thing. PR-URL: #17368 Refs: #14643 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Added assertions to verify that console.time() coerces labels to strings correctly, by comparing against the expected output values of console.timeEnd(). This helps resolve #14544 but will not address the whole thing. PR-URL: #17368 Refs: #14643 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
| Back | FazBrowse Home | New Git URL |
Per the console spec, the label in console.time() is a string. Change is made for consistency with browser behavior.
Checklist
Affected core subsystem(s)
console