feat(console): countReset

This commit is contained in:
surunzi
2019-09-27 16:18:03 +08:00
parent de76c097a6
commit 2e3a0bb795
4 changed files with 10 additions and 5 deletions

View File

@@ -318,6 +318,7 @@ const CONSOLE_METHOD = [
'table',
'assert',
'count',
'countReset',
'debug',
'group',
'groupCollapsed',

View File

@@ -225,7 +225,6 @@ export default class Log {
msg = formatDir(args)
break
case 'info':
icon = 'info'
msg = formatMsg(args)
break
case 'warn':

View File

@@ -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()

View File

@@ -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() {