mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
27 lines
910 B
JavaScript
27 lines
910 B
JavaScript
define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_baseRest', './_baseUnary', './isArray'], function(apply, arrayMap, baseFlatten, baseIteratee, baseRest, baseUnary, isArray) {
|
|
|
|
/**
|
|
* Creates a function like `_.over`.
|
|
*
|
|
* @private
|
|
* @param {Function} arrayFunc The function to iterate over iteratees.
|
|
* @returns {Function} Returns the new over function.
|
|
*/
|
|
function createOver(arrayFunc) {
|
|
return baseRest(function(iteratees) {
|
|
iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
|
|
? arrayMap(iteratees[0], baseUnary(baseIteratee))
|
|
: arrayMap(baseFlatten(iteratees, 1), baseUnary(baseIteratee));
|
|
|
|
return baseRest(function(args) {
|
|
var thisArg = this;
|
|
return arrayFunc(iteratees, function(iteratee) {
|
|
return apply(iteratee, thisArg, args);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
return createOver;
|
|
});
|