Skip to content

Instantly share code, notes, and snippets.

View xzec's full-sized avatar

Juraj Žec xzec

View GitHub Profile
@xzec
xzec / deno-watchfs-debounce.ts
Last active September 23, 2024 17:49
Deno watch file system with debounce
import { debounce } from 'https://deno.land/std@0.224.0/async/debounce.ts'
await Array.fromAsync(
Deno.watchFs('file.txt'),
debounce((event) => console.debug(`[${event.kind}] ${event.paths[0]}`), 50),
)
// Credits: https://github.com/denoland/deno/issues/12874#issuecomment-1935198354
@xzec
xzec / AuthError.ts
Created October 1, 2025 15:25
Simple AuthError
import type { AuthErrorType } from '~/auth/types'
export class AuthError extends Error {
readonly type: AuthErrorType
constructor(
type: AuthErrorType,
{ message, cause }: { message?: string } & ErrorOptions = {},
) {
super(message ?? AuthError.defaultMessage[type], { cause })