Skip to content

Instantly share code, notes, and snippets.

View oxwazz's full-sized avatar
🐒

Muhammad Rahmahalim oxwazz

🐒
View GitHub Profile
@oxwazz
oxwazz / update-graphql-schema.md
Last active May 3, 2023 06:31
update graphql schema
@oxwazz
oxwazz / safe-function.ts
Last active September 16, 2022 19:48
[TypeScript] Safe Function
export const safeFunc = <T extends (...args: any[]) => any>(
func: T,
args: Parameters<T>,
defaultValue: ReturnType<T>
): [error: any, data: ReturnType<T>] => {
try {
const data = func(...args)
return [null, data]
} catch (e) {
return [e, defaultValue]