summaryrefslogtreecommitdiff
path: root/lib/console.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-07-12 16:56:15 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-07-16 11:24:34 +0200
commit7eeb7948b3a9f29334612a79f349178888df5f7e (patch)
treef02b116c11c31ad7b141ab2b7da1b4b1cb3d302b /lib/console.js
parentdb495896249b29a93d8013b5ee2067ecf87ed081 (diff)
downloadandroid-node-v8-7eeb7948b3a9f29334612a79f349178888df5f7e.tar.gz
android-node-v8-7eeb7948b3a9f29334612a79f349178888df5f7e.tar.bz2
android-node-v8-7eeb7948b3a9f29334612a79f349178888df5f7e.zip
console: fix timeEnd() not coercing the input
The input of console.timeEnd() was not coerced to a string. That way labels were not found and the entry was not removed anymore. PR-URL: https://github.com/nodejs/node/pull/21779 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib/console.js')
-rw-r--r--lib/console.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/console.js b/lib/console.js
index 92ac64173a..665a2a6a23 100644
--- a/lib/console.js
+++ b/lib/console.js
@@ -236,6 +236,8 @@ Console.prototype.time = function time(label = 'default') {
};
Console.prototype.timeEnd = function timeEnd(label = 'default') {
+ // Coerces everything other than Symbol to a string
+ label = `${label}`;
const hasWarned = timeLogImpl(this, 'timeEnd', label);
if (!hasWarned) {
this._times.delete(label);
@@ -243,13 +245,13 @@ Console.prototype.timeEnd = function timeEnd(label = 'default') {
};
Console.prototype.timeLog = function timeLog(label, ...data) {
+ // Coerces everything other than Symbol to a string
+ label = `${label}`;
timeLogImpl(this, 'timeLog', label, data);
};
// Returns true if label was not found
function timeLogImpl(self, name, label = 'default', data) {
- // Coerces everything other than Symbol to a string
- label = `${label}`;
const time = self._times.get(label);
if (!time) {
process.emitWarning(`No such label '${label}' for console.${name}()`);