diff options
Diffstat (limited to 'general-util.js')
-rw-r--r-- | general-util.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/general-util.js b/general-util.js index b767a1b..b4491de 100644 --- a/general-util.js +++ b/general-util.js @@ -335,3 +335,17 @@ export async function parseOptions(options, optionDescriptorMap) { } parseOptions.handleDashless = Symbol() + +export function silenceEvents(emitter, eventsToSilence, callback) { + const oldEmit = emitter.emit + + emitter.emit = function(event, ...data) { + if (!eventsToSilence.includes(event)) { + oldEmit.apply(emitter, [event, ...data]) + } + } + + callback() + + emitter.emit = oldEmit +} |