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
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 |
Generate beautiful, memorable, and poetic API keys and unique identifiers for your applications.
Keyfleur creates human-readable, aesthetically pleasing API keys and unique identifiers inspired by natural language patterns and poetry. Unlike traditional random strings, Keyfleur keys are designed to be both functional and beautiful.
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(); | |
}); |
We first define a generic MinHeap class with the following operations:
- size(): Returns the number of elements in the heap.
- peek(): Returns the minimum (root) without removing it.
- push(value): Inserts a value, keeping the heap structure.
- pop(): Removes and returns the minimum (root).
- heapifyUp() and heapifyDown(): Internal methods to maintain heap order.
NewerOlder