@discordjs/collection 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,111 +1,115 @@
1
- export interface CollectionConstructor {
1
+ /**
2
+ * @internal
3
+ */
4
+ interface CollectionConstructor {
2
5
  new (): Collection<unknown, unknown>;
3
6
  new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): Collection<K, V>;
4
7
  new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
5
8
  readonly prototype: Collection<unknown, unknown>;
6
9
  readonly [Symbol.species]: CollectionConstructor;
7
10
  }
11
+ /**
12
+ * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
13
+ *
14
+ * @internal
15
+ */
16
+ interface Collection<K, V> extends Map<K, V> {
17
+ constructor: CollectionConstructor;
18
+ }
8
19
  /**
9
20
  * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
10
21
  * an ID, for significantly improved performance and ease-of-use.
11
- * @extends {Map}
12
- * @property {number} size - The amount of elements in this collection.
13
22
  */
14
- export declare class Collection<K, V> extends Map<K, V> {
23
+ declare class Collection<K, V> extends Map<K, V> {
15
24
  static readonly default: typeof Collection;
16
- ['constructor']: CollectionConstructor;
17
- /**
18
- * Identical to [Map.get()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get).
19
- * Gets an element with the specified key, and returns its value, or `undefined` if the element does not exist.
20
- * @param {*} key - The key to get from this collection
21
- * @returns {* | undefined}
22
- */
23
- get(key: K): V | undefined;
24
- /**
25
- * Identical to [Map.set()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set).
26
- * Sets a new element in the collection with the specified key and value.
27
- * @param {*} key - The key of the element to add
28
- * @param {*} value - The value of the element to add
29
- * @returns {Collection}
30
- */
31
- set(key: K, value: V): this;
32
- /**
33
- * Identical to [Map.has()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has).
34
- * Checks if an element exists in the collection.
35
- * @param {*} key - The key of the element to check for
36
- * @returns {boolean} `true` if the element exists, `false` if it does not exist.
37
- */
38
- has(key: K): boolean;
39
- /**
40
- * Identical to [Map.delete()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete).
41
- * Deletes an element from the collection.
42
- * @param {*} key - The key to delete from the collection
43
- * @returns {boolean} `true` if the element was removed, `false` if the element does not exist.
44
- */
45
- delete(key: K): boolean;
46
- /**
47
- * Identical to [Map.clear()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear).
48
- * Removes all elements from the collection.
49
- * @returns {undefined}
50
- */
51
- clear(): void;
52
25
  /**
53
26
  * Checks if all of the elements exist in the collection.
54
- * @param {...*} keys - The keys of the elements to check for
55
- * @returns {boolean} `true` if all of the elements exist, `false` if at least one does not exist.
27
+ *
28
+ * @param keys - The keys of the elements to check for
29
+ *
30
+ * @returns `true` if all of the elements exist, `false` if at least one does not exist.
56
31
  */
57
32
  hasAll(...keys: K[]): boolean;
58
33
  /**
59
34
  * Checks if any of the elements exist in the collection.
60
- * @param {...*} keys - The keys of the elements to check for
61
- * @returns {boolean} `true` if any of the elements exist, `false` if none exist.
35
+ *
36
+ * @param keys - The keys of the elements to check for
37
+ *
38
+ * @returns `true` if any of the elements exist, `false` if none exist.
62
39
  */
63
40
  hasAny(...keys: K[]): boolean;
64
41
  /**
65
42
  * Obtains the first value(s) in this collection.
66
- * @param {number} [amount] Amount of values to obtain from the beginning
67
- * @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the end if
68
- * amount is negative
43
+ *
44
+ * @param amount Amount of values to obtain from the beginning
45
+ *
46
+ * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
69
47
  */
70
48
  first(): V | undefined;
71
49
  first(amount: number): V[];
72
50
  /**
73
51
  * Obtains the first key(s) in this collection.
74
- * @param {number} [amount] Amount of keys to obtain from the beginning
75
- * @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the end if
52
+ *
53
+ * @param amount Amount of keys to obtain from the beginning
54
+ *
55
+ * @returns A single key if no amount is provided or an array of keys, starting from the end if
76
56
  * amount is negative
77
57
  */
78
58
  firstKey(): K | undefined;
79
59
  firstKey(amount: number): K[];
80
60
  /**
81
61
  * Obtains the last value(s) in this collection.
82
- * @param {number} [amount] Amount of values to obtain from the end
83
- * @returns {*|Array<*>} A single value if no amount is provided or an array of values, starting from the start if
62
+ *
63
+ * @param amount Amount of values to obtain from the end
64
+ *
65
+ * @returns A single value if no amount is provided or an array of values, starting from the start if
84
66
  * amount is negative
85
67
  */
86
68
  last(): V | undefined;
87
69
  last(amount: number): V[];
88
70
  /**
89
71
  * Obtains the last key(s) in this collection.
90
- * @param {number} [amount] Amount of keys to obtain from the end
91
- * @returns {*|Array<*>} A single key if no amount is provided or an array of keys, starting from the start if
72
+ *
73
+ * @param amount Amount of keys to obtain from the end
74
+ *
75
+ * @returns A single key if no amount is provided or an array of keys, starting from the start if
92
76
  * amount is negative
93
77
  */
94
78
  lastKey(): K | undefined;
95
79
  lastKey(amount: number): K[];
80
+ /**
81
+ * Identical to [Array.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).
82
+ * Returns the item at a given index, allowing for positive and negative integers.
83
+ * Negative integers count back from the last item in the collection.
84
+ *
85
+ * @param index The index of the element to obtain
86
+ */
87
+ at(index?: number): V | undefined;
88
+ /**
89
+ * Identical to [Array.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).
90
+ * Returns the key at a given index, allowing for positive and negative integers.
91
+ * Negative integers count back from the last item in the collection.
92
+ *
93
+ * @param index The index of the key to obtain
94
+ */
95
+ keyAt(index?: number): K | undefined;
96
96
  /**
97
97
  * Obtains unique random value(s) from this collection.
98
- * @param {number} [amount] Amount of values to obtain randomly
99
- * @returns {*|Array<*>} A single value if no amount is provided or an array of values
98
+ *
99
+ * @param amount Amount of values to obtain randomly
100
+ *
101
+ * @returns A single value if no amount is provided or an array of values
100
102
  */
101
- random(): V;
103
+ random(): V | undefined;
102
104
  random(amount: number): V[];
103
105
  /**
104
106
  * Obtains unique random key(s) from this collection.
105
- * @param {number} [amount] Amount of keys to obtain randomly
106
- * @returns {*|Array<*>} A single key if no amount is provided or an array
107
+ *
108
+ * @param amount Amount of keys to obtain randomly
109
+ *
110
+ * @returns A single key if no amount is provided or an array
107
111
  */
108
- randomKey(): K;
112
+ randomKey(): K | undefined;
109
113
  randomKey(amount: number): K[];
110
114
  /**
111
115
  * Searches for a single item where the given function returns a truthy value. This behaves like
@@ -113,10 +117,12 @@ export declare class Collection<K, V> extends Map<K, V> {
113
117
  * <warn>All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
114
118
  * should use the `get` method. See
115
119
  * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
116
- * @param {Function} fn The function to test with (should return boolean)
117
- * @param {*} [thisArg] Value to use as `this` when executing function
118
- * @returns {*}
119
- * @example collection.find(user => user.username === 'Bob');
120
+ *
121
+ * @param fn The function to test with (should return boolean)
122
+ * @param thisArg Value to use as `this` when executing function
123
+ *
124
+ * @example
125
+ * collection.find(user => user.username === 'Bob');
120
126
  */
121
127
  find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
122
128
  find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
@@ -126,10 +132,12 @@ export declare class Collection<K, V> extends Map<K, V> {
126
132
  * Searches for the key of a single item where the given function returns a truthy value. This behaves like
127
133
  * [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex),
128
134
  * but returns the key rather than the positional index.
129
- * @param {Function} fn The function to test with (should return boolean)
130
- * @param {*} [thisArg] Value to use as `this` when executing function
131
- * @returns {*}
132
- * @example collection.findKey(user => user.username === 'Bob');
135
+ *
136
+ * @param fn The function to test with (should return boolean)
137
+ * @param thisArg Value to use as `this` when executing function
138
+ *
139
+ * @example
140
+ * collection.findKey(user => user.username === 'Bob');
133
141
  */
134
142
  findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
135
143
  findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
@@ -137,9 +145,11 @@ export declare class Collection<K, V> extends Map<K, V> {
137
145
  findKey<This>(fn: (this: This, value: V, key: K, collection: this) => boolean, thisArg: This): K | undefined;
138
146
  /**
139
147
  * Removes items that satisfy the provided filter function.
140
- * @param {Function} fn Function used to test (should return a boolean)
141
- * @param {*} [thisArg] Value to use as `this` when executing function
142
- * @returns {number} The number of removed entries
148
+ *
149
+ * @param fn Function used to test (should return a boolean)
150
+ * @param thisArg Value to use as `this` when executing function
151
+ *
152
+ * @returns The number of removed entries
143
153
  */
144
154
  sweep(fn: (value: V, key: K, collection: this) => boolean): number;
145
155
  sweep<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): number;
@@ -147,10 +157,12 @@ export declare class Collection<K, V> extends Map<K, V> {
147
157
  * Identical to
148
158
  * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
149
159
  * but returns a Collection instead of an Array.
150
- * @param {Function} fn The function to test with (should return boolean)
151
- * @param {*} [thisArg] Value to use as `this` when executing function
152
- * @returns {Collection}
153
- * @example collection.filter(user => user.username === 'Bob');
160
+ *
161
+ * @param fn The function to test with (should return boolean)
162
+ * @param thisArg Value to use as `this` when executing function
163
+ *
164
+ * @example
165
+ * collection.filter(user => user.username === 'Bob');
154
166
  */
155
167
  filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
156
168
  filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
@@ -161,10 +173,12 @@ export declare class Collection<K, V> extends Map<K, V> {
161
173
  /**
162
174
  * Partitions the collection into two collections where the first collection
163
175
  * contains the items that passed and the second contains the items that failed.
164
- * @param {Function} fn Function used to test (should return a boolean)
165
- * @param {*} [thisArg] Value to use as `this` when executing function
166
- * @returns {Collection[]}
167
- * @example const [big, small] = collection.partition(guild => guild.memberCount > 250);
176
+ *
177
+ * @param fn Function used to test (should return a boolean)
178
+ * @param thisArg Value to use as `this` when executing function
179
+ *
180
+ * @example
181
+ * const [big, small] = collection.partition(guild => guild.memberCount > 250);
168
182
  */
169
183
  partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
170
184
  partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
@@ -175,50 +189,60 @@ export declare class Collection<K, V> extends Map<K, V> {
175
189
  /**
176
190
  * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
177
191
  * [Array.flatMap()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
178
- * @param {Function} fn Function that produces a new Collection
179
- * @param {*} [thisArg] Value to use as `this` when executing function
180
- * @returns {Collection}
181
- * @example collection.flatMap(guild => guild.members.cache);
192
+ *
193
+ * @param fn Function that produces a new Collection
194
+ * @param thisArg Value to use as `this` when executing function
195
+ *
196
+ * @example
197
+ * collection.flatMap(guild => guild.members.cache);
182
198
  */
183
199
  flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
184
200
  flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
185
201
  /**
186
202
  * Maps each item to another value into an array. Identical in behavior to
187
203
  * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
188
- * @param {Function} fn Function that produces an element of the new array, taking three arguments
189
- * @param {*} [thisArg] Value to use as `this` when executing function
190
- * @returns {Array}
191
- * @example collection.map(user => user.tag);
204
+ *
205
+ * @param fn Function that produces an element of the new array, taking three arguments
206
+ * @param thisArg Value to use as `this` when executing function
207
+ *
208
+ * @example
209
+ * collection.map(user => user.tag);
192
210
  */
193
211
  map<T>(fn: (value: V, key: K, collection: this) => T): T[];
194
212
  map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
195
213
  /**
196
214
  * Maps each item to another value into a collection. Identical in behavior to
197
215
  * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
198
- * @param {Function} fn Function that produces an element of the new collection, taking three arguments
199
- * @param {*} [thisArg] Value to use as `this` when executing function
200
- * @returns {Collection}
201
- * @example collection.mapValues(user => user.tag);
216
+ *
217
+ * @param fn Function that produces an element of the new collection, taking three arguments
218
+ * @param thisArg Value to use as `this` when executing function
219
+ *
220
+ * @example
221
+ * collection.mapValues(user => user.tag);
202
222
  */
203
223
  mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
204
224
  mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
205
225
  /**
206
226
  * Checks if there exists an item that passes a test. Identical in behavior to
207
227
  * [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
208
- * @param {Function} fn Function used to test (should return a boolean)
209
- * @param {*} [thisArg] Value to use as `this` when executing function
210
- * @returns {boolean}
211
- * @example collection.some(user => user.discriminator === '0000');
228
+ *
229
+ * @param fn Function used to test (should return a boolean)
230
+ * @param thisArg Value to use as `this` when executing function
231
+ *
232
+ * @example
233
+ * collection.some(user => user.discriminator === '0000');
212
234
  */
213
235
  some(fn: (value: V, key: K, collection: this) => boolean): boolean;
214
236
  some<T>(fn: (this: T, value: V, key: K, collection: this) => boolean, thisArg: T): boolean;
215
237
  /**
216
238
  * Checks if all items passes a test. Identical in behavior to
217
239
  * [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
218
- * @param {Function} fn Function used to test (should return a boolean)
219
- * @param {*} [thisArg] Value to use as `this` when executing function
220
- * @returns {boolean}
221
- * @example collection.every(user => !user.bot);
240
+ *
241
+ * @param fn Function used to test (should return a boolean)
242
+ * @param thisArg Value to use as `this` when executing function
243
+ *
244
+ * @example
245
+ * collection.every(user => !user.bot);
222
246
  */
223
247
  every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
224
248
  every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
@@ -229,20 +253,23 @@ export declare class Collection<K, V> extends Map<K, V> {
229
253
  /**
230
254
  * Applies a function to produce a single value. Identical in behavior to
231
255
  * [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
232
- * @param {Function} fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
256
+ *
257
+ * @param fn Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
233
258
  * and `collection`
234
- * @param {*} [initialValue] Starting value for the accumulator
235
- * @returns {*}
236
- * @example collection.reduce((acc, guild) => acc + guild.memberCount, 0);
259
+ * @param initialValue Starting value for the accumulator
260
+ *
261
+ * @example
262
+ * collection.reduce((acc, guild) => acc + guild.memberCount, 0);
237
263
  */
238
264
  reduce<T>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
239
265
  /**
240
266
  * Identical to
241
267
  * [Map.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach),
242
268
  * but returns the collection instead of undefined.
243
- * @param {Function} fn Function to execute for each element
244
- * @param {*} [thisArg] Value to use as `this` when executing function
245
- * @returns {Collection}
269
+ *
270
+ * @param fn Function to execute for each element
271
+ * @param thisArg Value to use as `this` when executing function
272
+ *
246
273
  * @example
247
274
  * collection
248
275
  * .each(user => console.log(user.username))
@@ -253,9 +280,10 @@ export declare class Collection<K, V> extends Map<K, V> {
253
280
  each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
254
281
  /**
255
282
  * Runs a function on the collection and returns the collection.
256
- * @param {Function} fn Function to execute
257
- * @param {*} [thisArg] Value to use as `this` when executing function
258
- * @returns {Collection}
283
+ *
284
+ * @param fn Function to execute
285
+ * @param thisArg Value to use as `this` when executing function
286
+ *
259
287
  * @example
260
288
  * collection
261
289
  * .tap(coll => console.log(coll.size))
@@ -266,61 +294,73 @@ export declare class Collection<K, V> extends Map<K, V> {
266
294
  tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
267
295
  /**
268
296
  * Creates an identical shallow copy of this collection.
269
- * @returns {Collection}
270
- * @example const newColl = someColl.clone();
297
+ *
298
+ * @example
299
+ * const newColl = someColl.clone();
271
300
  */
272
301
  clone(): Collection<K, V>;
273
302
  /**
274
303
  * Combines this collection with others into a new collection. None of the source collections are modified.
275
- * @param {...Collection} collections Collections to merge
276
- * @returns {Collection}
277
- * @example const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
304
+ *
305
+ * @param collections Collections to merge
306
+ *
307
+ * @example
308
+ * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
278
309
  */
279
310
  concat(...collections: Collection<K, V>[]): Collection<K, V>;
280
311
  /**
281
312
  * Checks if this collection shares identical items with another.
282
313
  * This is different to checking for equality using equal-signs, because
283
314
  * the collections may be different objects, but contain the same data.
284
- * @param {Collection} collection Collection to compare with
285
- * @returns {boolean} Whether the collections have identical contents
315
+ *
316
+ * @param collection Collection to compare with
317
+ *
318
+ * @returns Whether the collections have identical contents
286
319
  */
287
320
  equals(collection: Collection<K, V>): boolean;
288
321
  /**
289
322
  * The sort method sorts the items of a collection in place and returns it.
290
323
  * The sort is not necessarily stable in Node 10 or older.
291
324
  * The default sort order is according to string Unicode code points.
292
- * @param {Function} [compareFunction] Specifies a function that defines the sort order.
293
- * If omitted, the collection is sorted according to each character's Unicode code point value,
294
- * according to the string conversion of each element.
295
- * @returns {Collection}
296
- * @example collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
325
+ *
326
+ * @param compareFunction Specifies a function that defines the sort order.
327
+ * If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
328
+ *
329
+ * @example
330
+ * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
297
331
  */
298
332
  sort(compareFunction?: Comparator<K, V>): this;
299
333
  /**
300
334
  * The intersect method returns a new structure containing items where the keys are present in both original structures.
301
- * @param {Collection} other The other Collection to filter against
302
- * @returns {Collection}
335
+ *
336
+ * @param other The other Collection to filter against
303
337
  */
304
338
  intersect(other: Collection<K, V>): Collection<K, V>;
305
339
  /**
306
340
  * The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
307
- * @param {Collection} other The other Collection to filter against
308
- * @returns {Collection}
341
+ *
342
+ * @param other The other Collection to filter against
309
343
  */
310
344
  difference(other: Collection<K, V>): Collection<K, V>;
311
345
  /**
312
346
  * The sorted method sorts the items of a collection and returns it.
313
347
  * The sort is not necessarily stable in Node 10 or older.
314
348
  * The default sort order is according to string Unicode code points.
315
- * @param {Function} [compareFunction] Specifies a function that defines the sort order.
349
+ *
350
+ * @param compareFunction Specifies a function that defines the sort order.
316
351
  * If omitted, the collection is sorted according to each character's Unicode code point value,
317
352
  * according to the string conversion of each element.
318
- * @returns {Collection}
319
- * @example collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
353
+ *
354
+ * @example
355
+ * collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
320
356
  */
321
357
  sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
322
358
  toJSON(): V[];
323
359
  private static defaultSort;
324
360
  }
325
- export declare type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
326
- export default Collection;
361
+ /**
362
+ * @internal
363
+ */
364
+ declare type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
365
+
366
+ export { Collection, CollectionConstructor, Comparator, Collection as default };