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

console: minor timeLogImpl() refactor #29100

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ const consoleMethods = {
timeEnd(label = 'default') {
// Coerces everything other than Symbol to a string
label = `${label}`;
const hasWarned = timeLogImpl(this, 'timeEnd', label);
const found = timeLogImpl(this, 'timeEnd', label);
trace(kTraceEnd, kTraceConsoleCategory, `time::${label}`, 0);
if (!hasWarned) {
if (found) {
this._times.delete(label);
}
},
Expand Down Expand Up @@ -509,12 +509,12 @@ const consoleMethods = {
},
};

// Returns true if label was not found
// Returns true if label was found
function timeLogImpl(self, name, label, data) {
const time = self._times.get(label);
if (!time) {
if (time === undefined) {
cjihrig marked this conversation as resolved.
Show resolved Hide resolved
process.emitWarning(`No such label '${label}' for console.${name}()`);
return true;
return false;
cjihrig marked this conversation as resolved.
Show resolved Hide resolved
}
const duration = process.hrtime(time);
const ms = duration[0] * 1000 + duration[1] / 1e6;
Expand All @@ -523,7 +523,7 @@ function timeLogImpl(self, name, label, data) {
} else {
self.log('%s: %sms', label, ms.toFixed(3), ...data);
}
return false;
return true;
}

const keyKey = 'Key';
Expand Down