parent
5b74736769
commit
9268ccbd51
1 changed files with 16 additions and 0 deletions
@ -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…
Reference in new issue