From ac543c4456443bfa6f044edcfbff2f214e04996b Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 11 Apr 2024 12:17:02 -0700 Subject: [PATCH] fix: switch to traditional functions They are marginally faster and this is a very hot path --- lib/index.js | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/lib/index.js b/lib/index.js index c400465..2a049e6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,9 +5,15 @@ module.exports = { 'error', 'buffer', ], - standard: (...args) => process.emit('output', 'standard', ...args), - error: (...args) => process.emit('output', 'error', ...args), - buffer: (...args) => process.emit('output', 'buffer', ...args), + standard: function (...args) { + return process.emit('output', 'standard', ...args) + }, + error: function (...args) { + return process.emit('output', 'error', ...args) + }, + buffer: function (...args) { + return process.emit('output', 'buffer', ...args) + }, }, log: { LEVELS: [ @@ -22,15 +28,35 @@ module.exports = { 'pause', 'resume', ], - error: (...args) => process.emit('log', 'error', ...args), - notice: (...args) => process.emit('log', 'notice', ...args), - warn: (...args) => process.emit('log', 'warn', ...args), - info: (...args) => process.emit('log', 'info', ...args), - verbose: (...args) => process.emit('log', 'verbose', ...args), - http: (...args) => process.emit('log', 'http', ...args), - silly: (...args) => process.emit('log', 'silly', ...args), - timing: (...args) => process.emit('log', 'timing', ...args), - pause: (...args) => process.emit('log', 'pause', ...args), - resume: (...args) => process.emit('log', 'resume', ...args), + error: function (...args) { + return process.emit('log', 'error', ...args) + }, + notice: function (...args) { + return process.emit('log', 'notice', ...args) + }, + warn: function (...args) { + return process.emit('log', 'warn', ...args) + }, + info: function (...args) { + return process.emit('log', 'info', ...args) + }, + verbose: function (...args) { + return process.emit('log', 'verbose', ...args) + }, + http: function (...args) { + return process.emit('log', 'http', ...args) + }, + silly: function (...args) { + return process.emit('log', 'silly', ...args) + }, + timing: function (...args) { + return process.emit('log', 'timing', ...args) + }, + pause: function (...args) { + return process.emit('log', 'pause', ...args) + }, + resume: function (...args) { + return process.emit('log', 'resume', ...args) + }, }, }