mirror of
https://github.com/xodio/xod.git
synced 2026-03-22 16:46:54 +01:00
20 lines
422 B
JavaScript
20 lines
422 B
JavaScript
import R from 'ramda';
|
|
|
|
/**
|
|
* Picks a program by command and run it.
|
|
*
|
|
* @function
|
|
* @param {Object.<String, Boolean>} options
|
|
* @param {Object.<String, Function>} programs
|
|
*/
|
|
export const runCommand = R.uncurryN(2, options =>
|
|
R.mapObjIndexed(
|
|
(fn, command) => R.when(
|
|
R.compose(R.equals(true), R.prop(R.__, options)),
|
|
R.tap(() => fn(options))
|
|
)(command)
|
|
)
|
|
);
|
|
|
|
export default { runCommand };
|