From 2e3a0bb79587e9f37a8bc5c8fd9e091679f09074 Mon Sep 17 00:00:00 2001 From: surunzi Date: Fri, 27 Sep 2019 16:18:03 +0800 Subject: [PATCH] feat(console): countReset --- src/Console/Console.js | 1 + src/Console/Log.js | 1 - src/Console/Logger.js | 9 +++++++-- test/console.js | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Console/Console.js b/src/Console/Console.js index 7bb379d..f8ed690 100644 --- a/src/Console/Console.js +++ b/src/Console/Console.js @@ -318,6 +318,7 @@ const CONSOLE_METHOD = [ 'table', 'assert', 'count', + 'countReset', 'debug', 'group', 'groupCollapsed', diff --git a/src/Console/Log.js b/src/Console/Log.js index 93e16a6..6a347eb 100644 --- a/src/Console/Log.js +++ b/src/Console/Log.js @@ -225,7 +225,6 @@ export default class Log { msg = formatDir(args) break case 'info': - icon = 'info' msg = formatMsg(args) break case 'warn': diff --git a/src/Console/Logger.js b/src/Console/Logger.js index 854624b..c49b15c 100644 --- a/src/Console/Logger.js +++ b/src/Console/Logger.js @@ -74,7 +74,12 @@ export default class Logger extends Emitter { !isUndef(count[label]) ? count[label]++ : (count[label] = 1) - return this.html(`${label}: ${count[label]}`) + return this.info(`${label}: ${count[label]}`) + } + countReset(label = 'default') { + this._count[label] = 0 + + return this } assert(...args) { if (isEmpty(args)) return @@ -117,7 +122,7 @@ export default class Logger extends Emitter { if (!startTime) return delete this._timer[name] - return this.html(`${name}: ${perfNow() - startTime}ms`) + return this.info(`${name}: ${perfNow() - startTime}ms`) } clear() { this.silentClear() diff --git a/test/console.js b/test/console.js index 6cbf9e6..806fd82 100644 --- a/test/console.js +++ b/test/console.js @@ -41,7 +41,7 @@ describe('console', function() { it('timing', function() { tool.time('eruda') tool.timeEnd('eruda') - expect($tool.find('.eruda-html')).toHaveText(/eruda: [.\d]+ms/) + expect($tool.find('.eruda-info')).toHaveText(/eruda: [.\d]+ms/) }) it('error', function() { @@ -61,7 +61,7 @@ describe('console', function() { it('count', function() { tool.count('test').clear() tool.count('test') - expect($tool.find('.eruda-html')).toContainText('test: 2') + expect($tool.find('.eruda-info')).toContainText('test: 2') }) describe('substitution', function() {