debut des details de la page. Vu que c'est le troisieme (euh quatrieme?) composant, c'etait un peu plus rapide, mais heureusement que claude est la pour repasser derriere mes erreurs prcq en solo je n'y arriverais pas du tout!
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Similar to compose but performs from left-to-right function composition.<br/>
|
||||
* {@link https://30secondsofcode.org/function#composeright see also}
|
||||
* @param {...[function]} fns) - list of unary function
|
||||
* @returns {*} result of the computation
|
||||
*/
|
||||
const composeRight = (...fns) => compose(...fns.reverse());
|
||||
|
||||
/**
|
||||
* Performs right-to-left function composition.<br/>
|
||||
* Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
|
||||
* The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
|
||||
* {@link https://30secondsofcode.org/function#compose original source code}
|
||||
* @param {...[function]} fns) - list of unary function
|
||||
* @returns {*} result of the computation
|
||||
*/
|
||||
function compose(...fns) {
|
||||
return fns.reduce((f, g) => (...args) => f(g(...args)))
|
||||
}
|
||||
|
||||
export { composeRight, compose as default };
|
||||
Reference in New Issue
Block a user