rsuite-table
Version:
A React table component
20 lines (18 loc) • 386 B
text/typescript
/**
* 根据条件,选择性调用 a 与 b 其中一个方法。
* @param a
* @param b
*/
function toggle(a: Function, b: Function) {
return (target: HTMLElement, value: any[]) => {
const options = [target, ...value];
return condition => {
if (condition) {
a(...options);
} else {
b(...options);
}
};
};
}
export default toggle;