Finish adding comment blocks to creator function. [ci skip]

This commit is contained in:
jdalton
2015-03-17 13:54:33 -07:00
parent 82c5d8ed28
commit 1aea5bcd50

View File

@@ -3090,6 +3090,10 @@
* object composed from the results of running each element in the collection * object composed from the results of running each element in the collection
* through an iteratee. * through an iteratee.
* *
* **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`,
* and `_.partition`.
*
*
* @private * @private
* @param {Function} setter The function to set keys and values of the accumulator object. * @param {Function} setter The function to set keys and values of the accumulator object.
* @param {Function} [initializer] The function to initialize the accumulator object. * @param {Function} [initializer] The function to initialize the accumulator object.
@@ -3121,6 +3125,8 @@
* Creates a function that assigns properties of source object(s) to a given * Creates a function that assigns properties of source object(s) to a given
* destination object. * destination object.
* *
* **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
*
* @private * @private
* @param {Function} assigner The function to assign values. * @param {Function} assigner The function to assign values.
* @returns {Function} Returns the new assigner function. * @returns {Function} Returns the new assigner function.
@@ -3256,7 +3262,7 @@
} }
/** /**
* Creates a function to curry other functions. * Creates a `_.curry` or `_.curryRight` function.
* *
* @private * @private
* @param {boolean} flag The curry bit flag. * @param {boolean} flag The curry bit flag.
@@ -3275,7 +3281,7 @@
} }
/** /**
* Creates a function that gets the extremum value of a collection. * Creates a `_.max` or `_.min` function.
* *
* @private * @private
* @param {Function} arrayFunc The function to get the extremum value from an array. * @param {Function} arrayFunc The function to get the extremum value from an array.
@@ -3308,8 +3314,7 @@
} }
/** /**
* Creates a function to find the first element in a collection a predicate * Creates a `_.find` or `_.findLast` function.
* returns truthy for.
* *
* @private * @private
* @param {Function} eachFunc The function to iterate over a collection. * @param {Function} eachFunc The function to iterate over a collection.
@@ -3328,8 +3333,7 @@
} }
/** /**
* Creates a function to find the index of the first element in an array a * Creates a `_.findIndex` or `_.findLastIndex` function.
* predicate returns truthy for.
* *
* @private * @private
* @param {boolean} [fromRight] Specify iterating from right to left. * @param {boolean} [fromRight] Specify iterating from right to left.
@@ -3346,22 +3350,21 @@
} }
/** /**
* Creates a function to find the key of the first element in an object a * Creates a `_.findKey` or `_.findLastKey` function.
* predicate returns truthy for.
* *
* @private * @private
* @param {Function} eachFunc The function to iterate over an object. * @param {Function} objectFunc The function to iterate over an object.
* @returns {Function} Returns the new find function. * @returns {Function} Returns the new find function.
*/ */
function createFindKey(eachFunc) { function createFindKey(objectFunc) {
return function(object, predicate, thisArg) { return function(object, predicate, thisArg) {
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
return baseFind(object, predicate, eachFunc, true); return baseFind(object, predicate, objectFunc, true);
}; };
} }
/** /**
* Creates a function to combine other functions into a single function. * Creates a `_.flow` or `_.flowRight` function.
* *
* @private * @private
* @param {boolean} [fromRight] Specify iterating from right to left. * @param {boolean} [fromRight] Specify iterating from right to left.
@@ -3395,32 +3398,61 @@
}; };
} }
function createForEach(arrayFunc, baseFunc) { /**
* Creates a function for `_.forEach` or `_.forEachRight`.
*
* @private
* @param {Function} arrayFunc The function to iterate over an array.
* @param {Function} eachFunc The function to iterate over a collection.
* @returns {Function} Returns the new each function.
*/
function createForEach(arrayFunc, eachFunc) {
return function(collection, iteratee, thisArg) { return function(collection, iteratee, thisArg) {
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
? arrayFunc(collection, iteratee) ? arrayFunc(collection, iteratee)
: baseFunc(collection, bindCallback(iteratee, thisArg, 3)); : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
}; };
} }
function createForIn(baseFunc) { /**
* Creates a function for `_.forIn` or `_.forInRight`.
*
* @private
* @param {Function} objectFunc The function to iterate over an object.
* @returns {Function} Returns the new each function.
*/
function createForIn(objectFunc) {
return function(object, iteratee, thisArg) { return function(object, iteratee, thisArg) {
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
iteratee = bindCallback(iteratee, thisArg, 3); iteratee = bindCallback(iteratee, thisArg, 3);
} }
return baseFunc(object, iteratee, keysIn); return objectFunc(object, iteratee, keysIn);
}; };
} }
function createForOwn(baseFunc) { /**
* Creates a function for `_.forOwn` or `_.forOwnRight`.
*
* @private
* @param {Function} objectFunc The function to iterate over an object.
* @returns {Function} Returns the new each function.
*/
function createForOwn(objectFunc) {
return function(object, iteratee, thisArg) { return function(object, iteratee, thisArg) {
if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
iteratee = bindCallback(iteratee, thisArg, 3); iteratee = bindCallback(iteratee, thisArg, 3);
} }
return baseFunc(object, iteratee); return objectFunc(object, iteratee);
}; };
} }
/**
* Creates a function for `_.padLeft` or `_.padRight`.
*
* @private
* @param {boolean} [fromRight] Specify padding from the right.
* @returns {Function} Returns the new pad function.
*/
function createPadDir(fromRight) { function createPadDir(fromRight) {
return function(string, length, chars) { return function(string, length, chars) {
string = baseToString(string); string = baseToString(string);
@@ -3428,6 +3460,13 @@
}; };
} }
/**
* Creates a `_.partial` or `_.partialRight` function.
*
* @private
* @param {boolean} flag The partial bit flag.
* @returns {Function} Returns the new partial function.
*/
function createPartial(flag) { function createPartial(flag) {
var partialFunc = restParam(function(func, partials) { var partialFunc = restParam(function(func, partials) {
var holders = replaceHolders(partials, partialFunc.placeholder); var holders = replaceHolders(partials, partialFunc.placeholder);
@@ -3436,6 +3475,14 @@
return partialFunc; return partialFunc;
} }
/**
* Creates a function for `_.reduce` or `_.reduceRight`.
*
* @private
* @param {Function} arrayFunc The function to iterate over an array.
* @param {Function} eachFunc The function to iterate over a collection.
* @returns {Function} Returns the new each function.
*/
function createReduce(arrayFunc, eachFunc) { function createReduce(arrayFunc, eachFunc) {
return function(collection, iteratee, accumulator, thisArg) { return function(collection, iteratee, accumulator, thisArg) {
var initFromArray = arguments.length < 3; var initFromArray = arguments.length < 3;