forked from enviPath/enviPy
Current Dev State
This commit is contained in:
24
static/js/ketcher2/node_modules/redux/src/compose.js
generated
vendored
Normal file
24
static/js/ketcher2/node_modules/redux/src/compose.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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))).
|
||||
*/
|
||||
|
||||
export default function compose(...funcs) {
|
||||
if (funcs.length === 0) {
|
||||
return arg => arg
|
||||
}
|
||||
|
||||
if (funcs.length === 1) {
|
||||
return funcs[0]
|
||||
}
|
||||
|
||||
const last = funcs[funcs.length - 1]
|
||||
const rest = funcs.slice(0, -1)
|
||||
return (...args) => rest.reduceRight((composed, f) => f(composed), last(...args))
|
||||
}
|
||||
Reference in New Issue
Block a user