Skip to content

Commit

Permalink
fix/docs: Address PR review (backport)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaaz committed Mar 9, 2020
1 parent 2a6f390 commit 420c313
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
32 changes: 18 additions & 14 deletions src/Utility/Discord/Collectors/Collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import TimeoutQueue from './TimeoutQueue';

/**
* @typedef {import('../../../AxonClient').default} AxonClient
* @typedef {import('../../../Libraries/definitions/LibraryInterface').default} LibraryInterface
* @typedef {{
* id: String, collected: Map, options: Object, resolve: () => {}, reject: () => {}),
* }} CollectorContainer
* id: String, collected: Map<String, T>, options: Object, resolve: (T) => Promise<T>, reject: (T) => Promise<T>),
* }} CollectorContainer<T>
*/

/**
Expand All @@ -18,10 +19,12 @@ import TimeoutQueue from './TimeoutQueue';
* It is advised to only use one instance per Collector type.
* This Collector handles using only one Collector instance with many collectors running.
*
* @template T
*
* @class Collector
* @extends {EventEmitter}
* @prop {AxonClient} _client - The AxonClient instance
* @prop {Collection<CollectorContainer>} collectors - Collection of CollectorContainer
* @prop {AxonClient} _axon - The AxonClient instance
* @prop {Collection<CollectorContainer<T>>} collectors - Collection of CollectorContainer
* @prop {TimeoutQueue} timeoutQueue - The current timeout queue sorted with the first timeout due at the top of the queue
* @prop {Number} _INCREMENT - Unique increment count used to generate ids
* @prop {Boolean} running - Whether the Collector is currently running
Expand Down Expand Up @@ -118,9 +121,9 @@ class Collector extends EventEmitter {
* Run this Collector with the given options
*
* @param {Object} [options={}]
* @param {Number} options.timeout - Number of millisecond before timing out
* @param {Number} options.timeout - Number of milliseconds before timing out
* @param {Number} options.count - Number of elements to collect before resolving
* @returns {Promise<Map>} - Collection of elements to resolve
* @returns {Promise<Map<String, T>>} - Map of elements resolved
* @memberof Collector
*/
run(options = {} ) {
Expand All @@ -140,7 +143,7 @@ class Collector extends EventEmitter {
}

/**
* Unset all listeners (strop listening)
* Unset all listeners (stop listening)
*
* @memberof Collector
*/
Expand Down Expand Up @@ -199,7 +202,7 @@ class Collector extends EventEmitter {
* @memberof Collector
*/
timeout() {
if (this.timeoutQueue.empty() ) {
if (this.timeoutQueue.isEmpty() ) {
return;
}

Expand All @@ -214,19 +217,20 @@ class Collector extends EventEmitter {
/**
* Fired to collect an element
* @event Collector#collect
* @param {Array<CollectorContainer>} collectors - The collectors that will collect the element
* @param {Array<CollectorContainer<T>>} collectors - The collectors that will collect the element
* @param {Object} obj
* @param {Object} obj.id - The collected element id
* @param {Object} obj.collected - The collected element
* @param {String} obj.id - The collected element id
* @param {T} obj.collected - The collected element
* @memberof Collector
*/

/**
* Handles on collect action
*
* @param {Array<CollectorContainer>} collectors
* @param {Object} param { id, collected }
* @param {String} param.id
* @param {Object} collected - element collected
* @param {Object} param - { id, collected }
* @param {String} param.id - The collected element id
* @param {T} collected - Element collected
* @memberof Collector
*/
onCollect(collectors, { id, collected } ) {
Expand Down
4 changes: 2 additions & 2 deletions src/Utility/Discord/Collectors/MessageCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Collector from './Collector';
* @author VoidNull, KhaaZ
*
* @class MessageCollector
* @extends Collector
* @extends Collector<Message>
*
* @prop {Object} options
* @prop {Number} options.timeout - Number of ms before timing out
Expand Down Expand Up @@ -67,7 +67,7 @@ class MessageCollector extends Collector {
* @param {Number} [options.count] - The amount of messages to collect before automatically ending
* @param {Boolean} [options.ignoreBots] - Whether or not to ignore bots
* @param {String} [options.userID] - The user id to listen for (listens to all messages if not specified)
* @returns {Promise<Map<Message>>} Map of messages collected.
* @returns {Promise<Map<String, Message>>} Map of messages collected.
* @memberof MessageCollector
* @example
* const messages = await collector.run(msg.channel, { caseInsensitive: false });
Expand Down
4 changes: 2 additions & 2 deletions src/Utility/Discord/Collectors/TimeoutQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class TimeoutQueue {
}

/**
* Wether the queue is empty or not
* Whether the queue is empty or not
*
* @returns {Boolean}
* @memberof TimeoutQueue
*/
empty() {
isEmpty() {
return this.queue.length === 0;
}

Expand Down

0 comments on commit 420c313

Please sign in to comment.