Snippets
Ready-to-use code snippets
Async & Promises
sleep
Pause execution for a specified duration using a Promise-based delay.
debounce
Limit function execution rate by delaying until calls stop.
throttle
Limit function execution to at most once per interval.
memoize
Cache function results to avoid redundant computations.
once
Ensure a function is only called once, returning the cached result.
retry
Retry an async operation with exponential backoff on failure.
withTimeout
Add a timeout to any Promise, rejecting if it takes too long.
Array Utilities
last
Get the last element of an array safely.
chunk
Split an array into smaller arrays of a specified size.
uniqueBy
Remove duplicates from an array based on a key selector function.
groupBy
Group array items by a key into an object of arrays.
partition
Split an array into two based on a predicate function.
shuffle
Randomly shuffle array elements using Fisher-Yates algorithm.
Math & Numbers
Data & Validation
String Manipulation
Internationalization
Browser APIs
storage
Type-safe localStorage wrapper with JSON serialization.
copyToClipboard
Copy text to clipboard with fallback for older browsers.
waitForElement
Wait for a DOM element to appear using MutationObserver.
scrollToId
Smoothly scroll to an element by its ID.
onResize
Subscribe to window resize events with automatic cleanup.
URL & Query Strings
Functional Programming
TypeScript Types
ValueOf
Extract the union of all value types from an object type.
Prettify
Expand and flatten complex TypeScript intersection types for readability.
DeepPartial
Make all properties in an object optional recursively.
Brand
Create nominal/branded types for type-safe IDs and primitives.
assertNever
Exhaustiveness checker for TypeScript discriminated unions.
KeysOfUnion
Get all keys from a union of object types.
Merge
Merge two object types with B overriding A's properties.
hasType
Type guard for discriminated unions based on type property.