Skip to content

Commit c52db69

Browse files
committed
perf(basic): refactor getWriteMethod
1 parent c953c77 commit c52db69

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/reporters/basic.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,11 @@ export default class BasicReporter {
123123
}
124124

125125
getWriteMethod (isError, async) {
126-
return 'write' + (isError ? 'Error' : '') +
127-
(
128-
async === true
129-
? 'Async'
130-
: (
131-
async === false
132-
? 'Sync'
133-
: ''
134-
)
135-
)
126+
if (isError) {
127+
return async ? this.writeErrorAsync : this.writeError
128+
} else {
129+
return async ? this.write : this.writeAsync
130+
}
136131
}
137132

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

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

158-
return this[writeMethod](vsprintf(format, argv))
153+
return writeMethod(vsprintf(format, argv))
159154
}
160155
}

0 commit comments

Comments
 (0)