From 379b7a057ce64e8f81734bd4c0766eb5292f235f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjarne=20=C3=98verli?= Date: Wed, 11 Jan 2017 16:53:29 +0100 Subject: [PATCH] Minor cleanup to `createFlow`. [closes #2925] --- .internal/createFlow.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.internal/createFlow.js b/.internal/createFlow.js index f371de724..2897c82e2 100644 --- a/.internal/createFlow.js +++ b/.internal/createFlow.js @@ -9,19 +9,18 @@ function createFlow(fromRight) { return (...funcs) => { const length = funcs.length; - let func; - let wrapper; let index = length; if (fromRight) { funcs.reverse(); } + while (index--) { - func = funcs[index]; - if (typeof func != 'function') { + if (typeof funcs[index] !== 'function') { throw new TypeError('Expected a function'); } } + return function(...args) { const value = args[0]; let index = 0; @@ -30,6 +29,7 @@ function createFlow(fromRight) { while (++index < length) { result = funcs[index].call(this, result); } + return result; }; };