Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let environment = elements.Environment(options);
const emitter = new EventEmitter();
const engine = Object.assign(emitter, {
execute,
logger,
getDefinitionById,
getDefinitions,
getState,
recover,
resume,
stop,
waitFor,
});
const broker = Broker(engine);
broker.assertExchange('event', 'topic', {autoDelete: false});
Object.defineProperty(engine, 'broker', {
enumerable: true,
get() {
return broker;
}
});
Object.defineProperty(engine, 'name', {
enumerable: true,
get() {
return name;
},
set(value) {
name = value;
function EventBroker(brokerOwner, options, onBrokerReturn) {
const broker = Broker(brokerOwner);
const pfx = options.prefix;
broker.assertExchange('event', 'topic', options);
broker.on('return', onBrokerReturn || onBrokerReturnFn);
return {
eventPrefix: pfx,
broker,
on,
once,
waitFor,
emit,
emitFatal,
};
function on(eventName, callback, eventOptions = { once: false }) {