Simplify event filter logic

This commit is contained in:
Brandon Keepers 2016-11-22 12:34:32 -06:00
parent 2d2b8b00f6
commit 104d59e1d6
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
1 changed files with 2 additions and 9 deletions

View File

@ -12,16 +12,9 @@ class WorkflowCore {
}
matches(event) {
const eventWithAction = [event.event, event.payload.action];
return this.events.find(e => {
const parts = e.split('.');
for (let i = 0; i < parts.length; i++) {
if (parts[i] !== eventWithAction[i]) {
return false;
}
}
return true;
const [name, action] = e.split('.');
return name === event.event && (!action || action === event.payload.action);
}) && this.filterFn(event);
}
}