Files
memecoin-botV2/.pnpm-store/v10/files/d7/7f2522f0c63bf547502937bde3269bd8982a55e9cbc87d041507eee5ef6cbb5a011117a536b8b7241dcbceb0e74caaf7fd07fd5b49e0e44600cb22d2684c38

20 lines
557 B
Plaintext

'use strict'
/**
* Listens for an event on an object and resolves a promise when the event is emitted.
* @param {Object} emitter - The object to listen to.
* @param {string} event - The name of the event to listen for.
* @param {Function} fn - The function to call when the event is emitted.
* @returns {Promise} A promise that resolves when the event is emitted.
*/
function once (emitter, event, fn) {
return new Promise(resolve => {
emitter.on(event, (...args) => {
fn(...args)
resolve()
})
})
}
module.exports = { once }