Skip to content

Commit a89eeca

Browse files
targosrvagg
authored andcommitted
console: rename argument of time and timeEnd
Name it timerName instead of label. It is clearer that way and matches the description in the doc. It is also how it's named in MDN. PR-URL: #3166 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent f6ebc82 commit a89eeca

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(label)
75+
### console.time(timerName)
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_label) to stop the timer and
79+
[`console.timeEnd()`](#console_console_timeend_timername) 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(label)
83+
### console.timeEnd(timerName)
8484

8585
Stops a timer that was previously started by calling
86-
[`console.time()`](#console_console_time_label) and prints the result to the
86+
[`console.time()`](#console_console_time_timername) 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(label) {
59-
this._times.set(label, process.hrtime());
58+
Console.prototype.time = function(timerName) {
59+
this._times.set(timerName, process.hrtime());
6060
};
6161

6262

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

7373

0 commit comments

Comments
 (0)