![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/dceprojects.corals.io/node_modules/compose-function/module/ |
import arityN from 'arity-n'; let compose2 = (f, g) => (...args) => f(g(...args)); export default function compose(...functions) { const funcs = functions.filter(fn => typeof fn === 'function'); let lastIdx = funcs.length - 1; let arity = 0; if (funcs.length <= 0) { throw new Error('No funcs passed'); } if (lastIdx >= 0 && funcs[lastIdx]) { arity = funcs[lastIdx].length; } return arityN(funcs.reduce(compose2), arity); }