diff options
author | Florrie <towerofnix@gmail.com> | 2020-07-11 16:22:01 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2020-07-11 16:22:01 -0300 |
commit | 991b2f0a8280c31b93ad91d6a215b74183417352 (patch) | |
tree | 010b6edb291b6bb9c1689708bc40d9a2f797e91d /general-util.js | |
parent | d00b26b23d9b3fc1e54a4d117366f0f22e664135 (diff) |
support queue controls over socket clients
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 0a81cdc..e352960 100644 --- a/general-util.js +++ b/general-util.js @@ -310,3 +310,17 @@ const parseOptions = async function(options, optionDescriptorMap) { parseOptions.handleDashless = Symbol() module.exports.parseOptions = parseOptions + +module.exports.silenceEvents = function(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 +} |