UNPKG

leap-node

Version:

[![codecov](https://codecov.io/gh/leapdao/leap-node/branch/master/graph/badge.svg)](https://codecov.io/gh/leapdao/leap-node) [![Docker Repository on Quay](https://quay.io/repository/leapdao/leap-node/status "Docker Repository on Quay")](https://quay.io/re

24 lines (21 loc) 676 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) { // istanbul ignore next if (event.event === undefined) { console.warn('Unknown event. ABI can be outdated'); // eslint-disable-line no-console } 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 } } } }; };