Last active
September 7, 2023 22:06
-
-
Save NikolaRHristov/c27afa3f18d93f6be34bf99cf5fa988c to your computer and use it in GitHub Desktop.
Checks if function returns void. Basically Wrap()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// rome-ignore lint/suspicious/noExplicitAny: | |
export default <T extends (...args: any[]) => any>( | |
Fn: T, | |
With?: Parameters<T>[0] | |
): ReturnType<T> | boolean => { | |
try { | |
const Return = typeof With !== "undefined" ? Fn(With) : Fn(); | |
if (typeof Return !== "undefined") { | |
return Return; | |
} | |
} catch (_Error) { | |
console.log(_Error); | |
return false; | |
} | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment