fix: Clean up and add Neon DB

This commit is contained in:
Wanjohi
2025-09-20 04:38:16 +03:00
parent df4af84d55
commit a045fc9c91
10 changed files with 329 additions and 272 deletions

View File

@@ -1,5 +1,6 @@
export * from "./id"
export * from "./fn"
export * from "./log"
export * from "./invite"
export * from "./helper"
export * from "./id";
export * from "./fn";
export * from "./log";
export * from "./invite";
export * from "./helper";
export * from "./memo";

View File

@@ -0,0 +1,18 @@
export function memo<T>(fn: () => T, cleanup?: (input: T) => Promise<void>) {
let value: T | undefined;
let loaded = false;
const result = (): T => {
if (loaded) return value as T;
loaded = true;
value = fn();
return value as T;
};
result.reset = async () => {
if (cleanup && value) await cleanup(value);
loaded = false;
value = undefined;
};
return result;
}