Skip to content

Commit 9aee2c0

Browse files
committed
console: use 'label' argument for time and timeEnd
Turns out the argument is actually called label in the console spec, while being wrongly named on MDN. This reverts commit 8c043c1. MDN has been updated in: https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd$compare?locale=en-US&to=947893&from=918571 https://developer.mozilla.org/en-US/docs/Web/API/Console/time$compare?locale=en-US&to=947891&from=896987 PR-URL: #3590 Reviewed-By: targos - Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 1bacf37 commit 9aee2c0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

doc/api/console.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ object. This is useful for inspecting large complicated objects. Defaults to
7272
- `colors` - if `true`, then the output will be styled with ANSI color codes.
7373
Defaults to `false`. Colors are customizable, see below.
7474

75-
### console.time(timerName)
75+
### console.time(label)
7676

7777
Starts a timer that can be used to compute the duration of an operation. Timers
7878
are identified by a unique name. Use the same name when you call
79-
[`console.timeEnd()`](#console_console_timeend_timername) to stop the timer and
79+
[`console.timeEnd()`](#console_console_timeend_label) to stop the timer and
8080
output the elapsed time in milliseconds. Timer durations are accurate to the
8181
sub-millisecond.
8282

83-
### console.timeEnd(timerName)
83+
### console.timeEnd(label)
8484

8585
Stops a timer that was previously started by calling
86-
[`console.time()`](#console_console_time_timername) and prints the result to the
86+
[`console.time()`](#console_console_time_label) and prints the result to the
8787
console.
8888

8989
Example:

lib/console.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ Console.prototype.dir = function(object, options) {
5555
};
5656

5757

58-
Console.prototype.time = function(timerName) {
59-
this._times.set(timerName, process.hrtime());
58+
Console.prototype.time = function(label) {
59+
this._times.set(label, process.hrtime());
6060
};
6161

6262

63-
Console.prototype.timeEnd = function(timerName) {
64-
var time = this._times.get(timerName);
63+
Console.prototype.timeEnd = function(label) {
64+
var time = this._times.get(label);
6565
if (!time) {
66-
throw new Error('No such timer name: ' + timerName);
66+
throw new Error('No such label: ' + label);
6767
}
6868
const duration = process.hrtime(time);
6969
const ms = duration[0] * 1000 + duration[1] / 1e6;
70-
this.log('%s: %sms', timerName, ms.toFixed(3));
70+
this.log('%s: %sms', label, ms.toFixed(3));
7171
};
7272

7373

0 commit comments

Comments
 (0)