diff --git a/src/util/collection.ts b/src/util/collection.ts index 01489432e..78140bf0f 100644 --- a/src/util/collection.ts +++ b/src/util/collection.ts @@ -16,16 +16,17 @@ export class Collection extends Map { return [...this.values()]; } - first(): V { + /** Retrieve the value of the first element in this collection */ + first(): V | undefined { return this.values().next().value; } - last(): V { + last(): V | undefined { return [...this.values()][this.size - 1]; } - random() { - return chooseRandom([...this.values()]); + random(): V | undefined { + return chooseRandom([...this.values()]); } find(callback: (value: V, key: K) => boolean) {