Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
48 lines
1.2 KiB
Plaintext
48 lines
1.2 KiB
Plaintext
import { DEBUG_BUILD } from './debug-build.js';
|
|
import { debug } from './utils/debug-logger.js';
|
|
import { isThenable } from './utils/is.js';
|
|
import { resolvedSyncPromise, rejectedSyncPromise } from './utils/syncpromise.js';
|
|
|
|
/**
|
|
* Process an array of event processors, returning the processed event (or `null` if the event was dropped).
|
|
*/
|
|
function notifyEventProcessors(
|
|
processors,
|
|
event,
|
|
hint,
|
|
index = 0,
|
|
) {
|
|
try {
|
|
const result = _notifyEventProcessors(event, hint, processors, index);
|
|
return isThenable(result) ? result : resolvedSyncPromise(result);
|
|
} catch (error) {
|
|
return rejectedSyncPromise(error);
|
|
}
|
|
}
|
|
|
|
function _notifyEventProcessors(
|
|
event,
|
|
hint,
|
|
processors,
|
|
index,
|
|
) {
|
|
const processor = processors[index];
|
|
|
|
if (!event || !processor) {
|
|
return event;
|
|
}
|
|
|
|
const result = processor({ ...event }, hint);
|
|
|
|
DEBUG_BUILD && result === null && debug.log(`Event processor "${processor.id || '?'}" dropped event`);
|
|
|
|
if (isThenable(result)) {
|
|
return result.then(final => _notifyEventProcessors(final, hint, processors, index + 1));
|
|
}
|
|
|
|
return _notifyEventProcessors(result, hint, processors, index + 1);
|
|
}
|
|
|
|
export { notifyEventProcessors };
|
|
//# sourceMappingURL=eventProcessors.js.map
|