mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Allow _.flow and _.flowRight to accept an array of functions.
This commit is contained in:
27
lodash.js
27
lodash.js
@@ -3871,23 +3871,26 @@
|
||||
* @returns {Function} Returns the new flow function.
|
||||
*/
|
||||
function createFlow(fromRight) {
|
||||
return function() {
|
||||
var wrapper,
|
||||
length = arguments.length,
|
||||
index = fromRight ? length : -1,
|
||||
leftIndex = 0,
|
||||
funcs = Array(length);
|
||||
return rest(function(funcs) {
|
||||
funcs = baseFlatten(funcs);
|
||||
|
||||
while ((fromRight ? index-- : ++index < length)) {
|
||||
var func = funcs[leftIndex++] = arguments[index];
|
||||
var length = funcs.length,
|
||||
index = length,
|
||||
prereq = LodashWrapper.prototype.thru;
|
||||
|
||||
if (fromRight) {
|
||||
funcs.reverse();
|
||||
}
|
||||
while (index--) {
|
||||
var func = funcs[index];
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {
|
||||
wrapper = new LodashWrapper([], true);
|
||||
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
|
||||
var wrapper = new LodashWrapper([], true);
|
||||
}
|
||||
}
|
||||
index = wrapper ? -1 : length;
|
||||
index = wrapper ? index : length;
|
||||
while (++index < length) {
|
||||
func = funcs[index];
|
||||
|
||||
@@ -3915,7 +3918,7 @@
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user