mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Minor cleanup to createFlow. [closes #2925]
This commit is contained in:
committed by
John-David Dalton
parent
34ca4f3efa
commit
379b7a057c
@@ -9,19 +9,18 @@ function createFlow(fromRight) {
|
|||||||
return (...funcs) => {
|
return (...funcs) => {
|
||||||
const length = funcs.length;
|
const length = funcs.length;
|
||||||
|
|
||||||
let func;
|
|
||||||
let wrapper;
|
|
||||||
let index = length;
|
let index = length;
|
||||||
|
|
||||||
if (fromRight) {
|
if (fromRight) {
|
||||||
funcs.reverse();
|
funcs.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (index--) {
|
while (index--) {
|
||||||
func = funcs[index];
|
if (typeof funcs[index] !== 'function') {
|
||||||
if (typeof func != 'function') {
|
|
||||||
throw new TypeError('Expected a function');
|
throw new TypeError('Expected a function');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
const value = args[0];
|
const value = args[0];
|
||||||
let index = 0;
|
let index = 0;
|
||||||
@@ -30,6 +29,7 @@ function createFlow(fromRight) {
|
|||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
result = funcs[index].call(this, result);
|
result = funcs[index].call(this, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user