Skip to content

Commit

Permalink
perf(basic): refactor getWriteMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 18, 2018
1 parent c953c77 commit c52db69
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/reporters/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,11 @@ export default class BasicReporter {
}

getWriteMethod (isError, async) {
return 'write' + (isError ? 'Error' : '') +
(
async === true
? 'Async'
: (
async === false
? 'Sync'
: ''
)
)
if (isError) {
return async ? this.writeErrorAsync : this.writeError
} else {
return async ? this.write : this.writeAsync
}
}

prepareWrite (logObj, fields) {
Expand All @@ -155,6 +150,6 @@ export default class BasicReporter {

const { format, argv } = this.prepareWrite(logObj, fields)

return this[writeMethod](vsprintf(format, argv))
return writeMethod(vsprintf(format, argv))
}
}

0 comments on commit c52db69

Please sign in to comment.