EventFilter(type, criteria, priorityopt)

A filter that detects if an event should be allowed or denied based on some criteria.

new EventFilter(type, criteria, priorityopt)

Creates a new filter for an event. The filter is a simple detecter for a single set of criteria, but can be chained together into a firewall-like set of policies as a EventListener filterList.

Parameters:
Name Type Attributes Default Description
type "allow" | "deny"

Whether this filter is allowing or denying a specific event.

criteria object

An Object describing the filter rules

Properties
Name Type Description
sourceType string

Matches the sourceType of the EventBase

sourceName string

Matches the sourceName of the EventBase

eventType string

Matches the eventType of the EventBase

fn function

A custom function for making complex filtering decisions. Receives a single EventBase parameter and returns true for match and false for non-match.

any boolean

This filter is true if any criteria are true.

all boolean

This filter is true if all criteria are true.

none boolean

This filter is true if none of criteria are true.

priority number <optional>
100

The priority of this specific filter. Not useful for a single filter, but used as part of an EventListener filterList.

Properties:
Name Type Description
allow boolean

true if this EventFilter is intended to allow an event

deny boolean

true if this EventFilter is intended to deny an event

priority number

The relative priority of this filter. Used when part of a EventListener filterList.

criteria object

The original criteria object passed to the constructor

Methods

static buildTestFn(criteria) → {function}

Builds a test function for the specified criteria

Parameters:
Name Type Description
criteria object

The criteria object. See EventFilter constructor for details.

Returns:
function -

A function that recieves a single EventBase parameter and returns true if the event matches the criteria, false otherwise

allowEvent(event) → {boolean}

Indicates whether this event should be allowed or not

Parameters:
Name Type Description
event boolean

The event to evaluate against the criteria

Returns:
boolean -

Returns true if the event matches the criteria and should be allowed, false otherwise

denyEvent(event) → {boolean}

Indicates whether this event should be denied or not

Parameters:
Name Type Description
event boolean

The event to evaluate against the criteria

Returns:
boolean -

Returns true if the event matches the criteria and should be denied, false otherwise

matchEvent(event) → {boolean}

Indicates whether the event matches the criteria or not

Parameters:
Name Type Description
event EventBase

The event to evaluate against the criteria

Returns:
boolean -

Returns true if the specified event matches the criteria specified in the constructor, false otherwise