Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
relay(type, state, action, nextActionId) {
const message = {
type,
id: this.socket.id,
name: this.instanceName,
instanceId: this.appInstanceId,
};
if (state) {
message.payload = type === 'ERROR' ? state :
stringify(filterState(state, type, this.filters, this.stateSanitizer, this.actionSanitizer, nextActionId));
}
if (type === 'ACTION') {
message.action = stringify(
!this.actionSanitizer ? action : this.actionSanitizer(action.action, nextActionId - 1)
);
message.isExcess = this.isExcess;
message.nextActionId = nextActionId;
} else if (action) {
message.action = action;
}
this.socket.emit(this.socket.id ? 'log' : 'log-noid', message);
}
actionSanitizer,
serializeState,
serializeAction,
} = instance;
const message = {
type,
id: instance.id,
name: instance.name,
};
if (state) {
message.payload =
type === 'ERROR'
? state
: stringify(
filterState(
state,
type,
filters,
stateSanitizer,
actionSanitizer,
nextActionId,
predicate
),
serializeState
);
}
if (type === 'ACTION') {
message.action = stringify(
!actionSanitizer ? action : actionSanitizer(action.action, nextActionId - 1),
serializeAction
);