MCPcopy Create free account
hub / github.com/ctrlplusb/react-injectables / compose

Function compose

src/utils.js:15–27  ·  view source on GitHub ↗
(...funcs)

Source from the content-addressed store, hash-verified

13 * Thank you Dan Abramov for this code!
14 */
15export function compose(...funcs) {
16 return (...args) => {
17 /* istanbul ignore next */
18 if (funcs.length === 0) {
19 return args[0];
20 }
21
22 const last = funcs[funcs.length - 1];
23 const rest = funcs.slice(0, -1);
24
25 return rest.reduceRight((composed, f) => f(composed), last(...args));
26 };
27}
28
29// :: (a -> boolean) => [a] => [a]
30export const filter = f => x => x.filter(f);

Callers 1

runInjectionsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected