Class: Collector

Collector

Abstract class for defining a new Collector.

Constructor

(abstract) new Collector()

Source:

Members

(private, nullable) _idletimeout :Timeout

Timeout for cleanup due to inactivity
Type:
  • Timeout
Source:

(private, nullable) _timeout :Timeout

Timeout for cleanup
Type:
  • Timeout
Source:

(readonly) client :Client

The client that instantiated this Collector
Type:
Source:

collected :Collection

The items collected by this collector
Type:
  • Collection
Source:

ended :boolean

Whether this collector has finished collecting
Type:
  • boolean
Source:

filter :CollectorFilter

The filter applied to this collector
Type:
Source:

(readonly) next :Promise

Returns a promise that resolves with the next collected element; rejects with collected elements if the collector finishes without receiving a next element
Type:
  • Promise
Source:

options :CollectorOptions

The options of this collector
Type:
Source:

Methods

checkEnd()

Checks whether the collector should end, and if so, ends it.
Source:

(abstract) collect(…args) → {Object}

Handles incoming events from the `handleCollect` function. Returns null if the event should not be collected, or returns an object describing the data that should be stored.
Parameters:
Name Type Attributes Description
args * <repeatable>
Any args the event listener emits
Source:
See:
Returns:
Data to insert into collection, if any
Type
Object

(abstract) dispose(…args) → {*}

Handles incoming events from the `handleDispose`. Returns null if the event should not be disposed, or returns the key that should be removed.
Parameters:
Name Type Attributes Description
args * <repeatable>
Any args the event listener emits
Source:
See:
Returns:
Key to remove from the collection, if any
Type
*

(abstract) endReason() → {string}

The reason this collector has ended or will end with.
Source:
Returns:
Reason to end the collector, if any
Type
string

handleCollect(…args)

Call this to handle an event as a collectable element. Accepts any event data as parameters.
Parameters:
Name Type Attributes Description
args * <repeatable>
The arguments emitted by the listener
Source:
Fires:

handleDispose(…args)

Call this to remove an element from the collection. Accepts any event data as parameters.
Parameters:
Name Type Attributes Description
args * <repeatable>
The arguments emitted by the listener
Source:
Fires:

resetTimer(optionsopt)

Resets the collectors timeout and idle timer.
Parameters:
Name Type Attributes Description
options Object <optional>
Options
Properties
Name Type Attributes Description
time number <optional>
How long to run the collector for in milliseconds
idle number <optional>
How long to stop the collector after inactivity in milliseconds
Source:

stop(reasonopt)

Stops this collector and emits the `end` event.
Parameters:
Name Type Attributes Default Description
reason string <optional>
'user' The reason this collector is ending
Source:
Fires:

Events

collect

Emitted whenever an element is collected.
Parameters:
Name Type Attributes Description
args * <repeatable>
The arguments emitted by the listener
Source:

dispose

Emitted whenever an element is disposed of.
Parameters:
Name Type Attributes Description
args * <repeatable>
The arguments emitted by the listener
Source:

end

Emitted when the collector is finished collecting.
Parameters:
Name Type Description
collected Collection The elements collected by the collector
reason string The reason the collector ended
Source: