UNPKG

parsec-node

Version:

https://parseclabs.readthedocs.io/en/latest/

19 lines (17 loc) 504 B
module.exports = handlers => { Object.keys(handlers).forEach(key => { if (key[0].toUpperCase() !== key[0]) { throw new Error('Event name should start with a capital letter'); } }); return async events => { for (const event of events) { if (handlers[event.event]) { const result = handlers[event.event](event); if (result && typeof result.then === 'function') { await result; // eslint-disable-line no-await-in-loop } } } }; };