Skip to content

Commit

Permalink
fix: filters are used individually for events #1
Browse files Browse the repository at this point in the history
Fixed the filter code
  • Loading branch information
Tapppi authored Mar 29, 2017
2 parents 501df6a + a9cd05f commit 03235c8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var called = false;
var waitingFor = 0;
var asyncTimeoutMs = 10000;

var events = [];
var filters = [];
var events = {};
var filters = {};

function exit(exit, code, err) {
// Only execute hooks once
Expand Down Expand Up @@ -106,8 +106,9 @@ function add(hook) {
// New signal / event to hook
add.hookEvent = function (event, code, filter) {
events[event] = function () {
for (var i = 0; i < filters.length; i++) {
if (filters[i].apply(this, arguments)) {
const eventFilters = filters[event];
for (var i = 0; i < eventFilters.length; i++) {
if (eventFilters[i].apply(this, arguments)) {
return;
}
}
Expand Down

0 comments on commit 03235c8

Please sign in to comment.