Slightly improve some Collection docs

This commit is contained in:
Schuyler Cebulskie
2016-09-22 21:36:06 -04:00
parent edd174a5eb
commit 737ad8e92b
2 changed files with 7 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@@ -107,9 +107,9 @@ class Collection extends Map {
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument * @param {*} [value] The expected value - only applicable and required if using a property for the first argument
* @returns {*} * @returns {*}
* @example * @example
* collection.find('id', '123123...'); * collection.find('username', 'Bob');
* @example * @example
* collection.find(val => val.id === '123123...'); * collection.find(val => val.username === 'Bob');
*/ */
find(propOrFn, value) { find(propOrFn, value) {
if (typeof propOrFn === 'string') { if (typeof propOrFn === 'string') {
@@ -137,9 +137,9 @@ class Collection extends Map {
* @param {*} [value] The expected value - only applicable and required if using a property for the first argument * @param {*} [value] The expected value - only applicable and required if using a property for the first argument
* @returns {*} * @returns {*}
* @example * @example
* collection.find('id', '123123...'); * collection.findKey('username', 'Bob');
* @example * @example
* collection.find(val => val.id === '123123...'); * collection.findKey(val => val.username === 'Bob');
*/ */
/* eslint-enable max-len */ /* eslint-enable max-len */
findKey(propOrFn, value) { findKey(propOrFn, value) {
@@ -165,7 +165,7 @@ class Collection extends Map {
* @param {*} value The expected value * @param {*} value The expected value
* @returns {boolean} * @returns {boolean}
* @example * @example
* if (collection.exists('id', '123123...')) { * if (collection.exists('username', 'Bob')) {
* console.log('user here!'); * console.log('user here!');
* } * }
*/ */
@@ -201,9 +201,7 @@ class Collection extends Map {
if (thisArg) fn = fn.bind(thisArg); if (thisArg) fn = fn.bind(thisArg);
const arr = new Array(this.size); const arr = new Array(this.size);
let i = 0; let i = 0;
for (const [key, val] of this) { for (const [key, val] of this) arr[i++] = fn(val, key, this);
arr[i++] = fn(val, key, this);
}
return arr; return arr;
} }