From 104d59e1d6acab0750dc6626ff770f618436863f Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Tue, 22 Nov 2016 12:34:32 -0600 Subject: [PATCH] Simplify event filter logic --- lib/workflow.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/workflow.js b/lib/workflow.js index 3668a5e3..4d2de511 100644 --- a/lib/workflow.js +++ b/lib/workflow.js @@ -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); } }