Files
e-tib.com/node_modules/.pnpm/pino-pretty@13.1.3/node_modules/pino-pretty/test/helper.js
Marc Mintel d14122005d Initial commit: E-TIB production hardening & E2E foundation
Former-commit-id: ef04fca3d76375630c05aac117bf586953f3b657
2026-04-28 19:11:38 +02:00

20 lines
557 B
JavaScript

'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 }