You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
404 B
17 lines
404 B
2 years ago
|
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;
|