diff --git a/bun.lockb b/bun.lockb index 53886e6..2f225b1 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 78e918f..5cc19a7 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@tursodatabase/api": "^1.9.2", "@typeschema/valibot": "^0.13.4", "bcrypt": "^6.0.0", + "es-toolkit": "^1.43.0", "google-auth-library": "^10.5.0", "highlight.js": "^11.11.1", "jose": "^6.1.3", @@ -42,7 +43,7 @@ "zod": "^4.2.1" }, "engines": { - "node": ">=22" + "node": "24.x" }, "devDependencies": { "@tailwindcss/typography": "^0.5.19", diff --git a/src/components/blog/CommentBlock.tsx b/src/components/blog/CommentBlock.tsx index 1e9137b..57cb25e 100644 --- a/src/components/blog/CommentBlock.tsx +++ b/src/components/blog/CommentBlock.tsx @@ -12,7 +12,7 @@ import type { CommentReaction, UserPublicData } from "~/types/comment"; -import { debounce } from "~/lib/comment-utils"; +import { debounce } from "es-toolkit"; import UserDefaultImage from "~/components/icons/UserDefaultImage"; import ReplyIcon from "~/components/icons/ReplyIcon"; import TrashIcon from "~/components/icons/TrashIcon"; diff --git a/src/lib/client-utils.ts b/src/lib/client-utils.ts index 329f2be..1e73669 100644 --- a/src/lib/client-utils.ts +++ b/src/lib/client-utils.ts @@ -100,34 +100,3 @@ export function insertSoftHyphens( }) .join(" "); } - -/** - * Creates a debounced function that delays execution until after specified delay - * @param fn - The function to debounce - * @param delay - Delay in milliseconds - * @returns Debounced function with cancel method - */ -export function debounce any>( - fn: T, - delay: number -): T & { cancel: () => void } { - let timeoutId: ReturnType | undefined; - - const debounced = function (this: any, ...args: Parameters) { - if (timeoutId !== undefined) { - clearTimeout(timeoutId); - } - timeoutId = setTimeout(() => { - fn.apply(this, args); - }, delay); - } as T & { cancel: () => void }; - - debounced.cancel = () => { - if (timeoutId !== undefined) { - clearTimeout(timeoutId); - timeoutId = undefined; - } - }; - - return debounced; -} diff --git a/src/lib/comment-utils.ts b/src/lib/comment-utils.ts index aad26c4..3eedd80 100644 --- a/src/lib/comment-utils.ts +++ b/src/lib/comment-utils.ts @@ -190,33 +190,6 @@ export function sortComments( } } -// ============================================================================ -// Debounce Utility -// ============================================================================ - -/** - * Debounces a function call to limit execution frequency - * Useful for window resize and scroll events - */ -export function debounce any>( - func: T, - wait: number -): (...args: Parameters) => void { - let timeout: ReturnType | null = null; - - return function executedFunction(...args: Parameters) { - const later = () => { - timeout = null; - func(...args); - }; - - if (timeout !== null) { - clearTimeout(timeout); - } - timeout = setTimeout(later, wait); - }; -} - // ============================================================================ // Validation Utilities // ============================================================================ diff --git a/src/routes/blog/create/index.tsx b/src/routes/blog/create/index.tsx index 9d66ea4..fcc9909 100644 --- a/src/routes/blog/create/index.tsx +++ b/src/routes/blog/create/index.tsx @@ -4,7 +4,7 @@ import { Title, Meta } from "@solidjs/meta"; import { createAsync } from "@solidjs/router"; import { getRequestEvent } from "solid-js/web"; import { api } from "~/lib/api"; -import { debounce } from "~/lib/client-utils"; +import { debounce } from "es-toolkit"; import Dropzone from "~/components/blog/Dropzone"; import TextEditor from "~/components/blog/TextEditor"; import TagMaker from "~/components/blog/TagMaker"; diff --git a/src/routes/blog/edit/[id]/index.tsx b/src/routes/blog/edit/[id]/index.tsx index 003e6e8..56e894c 100644 --- a/src/routes/blog/edit/[id]/index.tsx +++ b/src/routes/blog/edit/[id]/index.tsx @@ -4,7 +4,7 @@ import { Title, Meta } from "@solidjs/meta"; import { createAsync } from "@solidjs/router"; import { getRequestEvent } from "solid-js/web"; import { api } from "~/lib/api"; -import { debounce } from "~/lib/client-utils"; +import { debounce } from "es-toolkit"; import Dropzone from "~/components/blog/Dropzone"; import TextEditor from "~/components/blog/TextEditor"; import TagMaker from "~/components/blog/TagMaker";