mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +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.
|
* @returns {Function} Returns the new flow function.
|
||||||
*/
|
*/
|
||||||
function createFlow(fromRight) {
|
function createFlow(fromRight) {
|
||||||
return function() {
|
return rest(function(funcs) {
|
||||||
var wrapper,
|
funcs = baseFlatten(funcs);
|
||||||
length = arguments.length,
|
|
||||||
index = fromRight ? length : -1,
|
|
||||||
leftIndex = 0,
|
|
||||||
funcs = Array(length);
|
|
||||||
|
|
||||||
while ((fromRight ? index-- : ++index < length)) {
|
var length = funcs.length,
|
||||||
var func = funcs[leftIndex++] = arguments[index];
|
index = length,
|
||||||
|
prereq = LodashWrapper.prototype.thru;
|
||||||
|
|
||||||
|
if (fromRight) {
|
||||||
|
funcs.reverse();
|
||||||
|
}
|
||||||
|
while (index--) {
|
||||||
|
var func = funcs[index];
|
||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {
|
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
|
||||||
wrapper = new LodashWrapper([], true);
|
var wrapper = new LodashWrapper([], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index = wrapper ? -1 : length;
|
index = wrapper ? index : length;
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
func = funcs[index];
|
func = funcs[index];
|
||||||
|
|
||||||
@@ -3915,7 +3918,7 @@
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user