fix(striker-ui): create function based on condition(s)

main
Tsu-ba-me 2 years ago
parent 5b74736769
commit 9268ccbd51
  1. 16
      striker-ui/lib/createFunction.ts

@ -0,0 +1,16 @@
const createFunction = (
{
conditionFn = () => true,
str = '',
condition = conditionFn() && str.length === 0,
}: {
condition?: boolean;
conditionFn?: (...args: unknown[]) => boolean;
str?: string;
},
fn: () => unknown,
...fnArgs: Parameters<typeof fn>
): (() => unknown) | undefined =>
condition ? fn.bind(null, ...fnArgs) : undefined;
export default createFunction;
Loading…
Cancel
Save