This error occurs when you try to convert a JavaScript object to JSON, but the object contains a circular reference. A circular reference occurs when an object refers to itself, directly or indirectly.
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
| /** | |
| * Generate visual progress bar using ASCII characters | |
| * | |
| * @param value - Current value | |
| * @param max - Maximum value | |
| * @param width - Width of the bar in characters (default: 25) | |
| * @returns ASCII progress bar string (`█` for filled, `░` for empty) | |
| * | |
| * @example | |
| * createProgressBar(75, 100, 20) // "███████████████░░░░░" |
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
| /** | |
| * Converts a string into a file-safe string by replacing or removing | |
| * characters that are not safe for filenames on most filesystems. | |
| * - Replaces spaces and unsafe characters with underscores. | |
| * - Removes or replaces reserved/special characters. | |
| * - Trims leading/trailing underscores and dots. | |
| */ | |
| export function toFileSafeString(input: string): string { | |
| return input | |
| .normalize("NFKD") // Normalize unicode |
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
| const boundaryPrefix = String.raw`(^|\s)` | |
| const boundarySuffix = String.raw`(\s|$)` | |
| /*** Patterns ***/ | |
| // Address patterns | |
| const zipPattern = String.raw`\d{5}(?:-\d{4})?` | |
| const cityPattern = String.raw`(?:[A-Z][a-z.-]+[ ]?){0,20}` | |
| const stateAbbrvPattern = String.raw`AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY` | |
| const cityStateZipPattern = String.raw`${cityPattern},\s*(?:${stateAbbrvPattern}),?\s*${zipPattern}` | |
| const streetSuffixPattern = String.raw`Avenue|Lane|Road|Boulevard|Place|Drive|Street|Ave|Dr|Rd|Blvd|Ln|St|Pl` |
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
| import { get, set, del, setMany, keys } from 'idb-keyval' | |
| export class IDBStore { | |
| private memoryStore: Record<string, string> = {} | |
| private useIndexedDB: boolean | |
| constructor() { | |
| this.useIndexedDB = typeof window !== 'undefined' && !!window.indexedDB | |
| } |
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
| export const playNotificationSound = (audioContext: AudioContext) => { | |
| const oscillator = audioContext.createOscillator(); | |
| const gainNode = audioContext.createGain(); | |
| oscillator.connect(gainNode); | |
| gainNode.connect(audioContext.destination); | |
| const options = { | |
| type: 'sine' as OscillatorType, | |
| freq: [ |
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
| import { useCallback, useEffect } from "react"; | |
| /** | |
| * Represents the parsed details of a keyboard shortcut. | |
| */ | |
| type KeyCombo = { | |
| key: string; // Original key name (e.g., 'e', 'enter') - useful for display | |
| code?: string | null; // Expected KeyboardEvent.code (e.g., 'KeyE', 'Enter') - used for matching | |
| ctrl: boolean; // True if Ctrl key is required | |
| meta: boolean; // True if Meta key (Cmd/Win) is required |
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
| import * as b64ArrBufferConvertor from "base64-arraybuffer"; | |
| const SECRET_HMAC_KEY = | |
| "209C5BBE79E2752FD1E4E687AD410778DD098546CC9B15ECAB1AEB4F21A46EF2"; | |
| async function importHmacSecretKey(secret: string) { | |
| return crypto.subtle.importKey( | |
| "raw", | |
| new TextEncoder().encode(secret), | |
| { name: "HMAC", hash: "SHA-256" }, | |
| false, |
setTimeout
caps out at ~25 days.
If you need a bigger timeout, use setBigTimeout.
import { setBigTimeout } from "./mod.mts";
const FORTY_DAYS_IN_MILLISECONDS = 3.456e9;
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
| document.addEventListener("contextmenu", function(event) { | |
| event.preventDefault(); | |
| alert("Right-click is disabled on this website!"); | |
| }); | |
| // Disable Right-Click for Specific Elements Only | |
| document.getElementById("protected-content").addEventListener("contextmenu", function(event) { | |
| event.preventDefault(); | |
| }); |
NewerOlder