Skip to content

Commit

Permalink
docs(Collection): Adjust exists documentation (discordjs#1876)
Browse files Browse the repository at this point in the history
Since the return value of Collection#exists is basically just a boolean of Collection#find's result, the same documentation and arguments can and should be applied.
  • Loading branch information
Robin B authored and iCrawl committed Sep 3, 2017
1 parent 39013b1 commit efbde07
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/util/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,23 @@ class Collection extends Map {

/**
* Searches for the existence of a single item where its specified property's value is identical to the given value
* (`item[prop] === value`).
* (`item[prop] === value`), or the given function returns a truthy value.
* <warn>Do not use this to check for an item by its ID. Instead, use `collection.has(id)`. See
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details.</warn>
* @param {string} prop The property to test against
* @param {*} value The expected value
* @param {string|Function} propOrFn The property to test against, or the function to test with
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument
* @returns {boolean}
* @example
* if (collection.exists('username', 'Bob')) {
* console.log('user here!');
* }
* @example
* if (collection.exists(user => user.username === 'Bob')) {
* console.log('user here!');
* }
*/
exists(prop, value) {
return Boolean(this.find(prop, value));
exists(propOrFn, value) {
return Boolean(this.find(propOrFn, value));
}

/**
Expand Down

0 comments on commit efbde07

Please sign in to comment.