diff --git a/src/util/Collection.js b/src/util/Collection.js index f33053a3..67168cb2 100644 --- a/src/util/Collection.js +++ b/src/util/Collection.js @@ -77,6 +77,8 @@ class Collection extends Map { * collection.getAll('username', 'Bob'); */ findAll(key, value) { + if (typeof key !== 'string') throw new TypeError('key must be a string'); + if (typeof value === 'undefined') throw new Error('value must be specified'); const results = []; for (const item of this.values()) { if (item[key] === value) { @@ -95,6 +97,8 @@ class Collection extends Map { * collection.get('id', '123123...'); */ find(key, value) { + if (typeof key !== 'string') throw new TypeError('key must be a string'); + if (typeof value === 'undefined') throw new Error('value must be specified'); for (const item of this.values()) { if (item[key] === value) { return item;