You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Composes single-argument functions from right to left. The rightmost * function can take multiple arguments as it provides the signature for * the resulting composite function. * * @param {...Function} funcs The functions to compose. * @returns {Function} A function obtained by composing the argument functions * from right to left. For example, compose(f, g, h) is identical to doing * (...args) => f(g(h(...args))). */exportdefaultfunctioncompose(...funcs){if(funcs.length===0){returnarg=>arg}if(funcs.length===1){returnfuncs[0]}returnfuncs.reduce((a,b)=>(...args)=>a(b(...args)))}
2020-02-26 22:54:15
在阅读某段代码的时候,了解到了
compose
但是似乎不止redux
很多工具库都用到了这个function
code
以前的写法:
现在的写法:
相关链接:
redux
Use function composition in JavaScript
redux之compose
redux compose 详解
The text was updated successfully, but these errors were encountered: