A collection of useful web development utilities, snippets, and tools for frontend developers.
Built with β€οΈ by AliMahmoudDev and contributors.
| Utility | Description |
|---|---|
debounce |
Creates a debounced version of a function that delays invocation |
throttle |
Creates a throttled version of a function that limits invocation rate |
deepClone |
Creates a deep clone of an object using structuredClone |
formatDate |
Formats a date using Intl.DateTimeFormat |
debounceAsync |
Async version of debounce |
isEmpty |
Checks if a value is empty (null, string, array, object) |
classNames |
Conditionally joins class names together |
sleep |
Promise-based setTimeout wrapper |
randomId |
Generates a random ID with optional prefix |
clamp |
Clamps a number between min and max values |
copyToClipboard |
Copies text to clipboard with fallback |
generateGradient |
Generates CSS gradient strings |
truncateText |
Truncates text to a max length with suffix |
parseQueryString |
Parses query strings into objects |
formatBytes |
Formats bytes into human-readable sizes |
omit |
Creates object without specified keys |
pick |
Creates object with only specified keys |
slugify |
Converts text to URL-friendly slugs |
import { debounce, throttle, formatBytes } from './src/utils';
// Debounce a search input
const debouncedSearch = debounce((query) => {
console.log('Searching for:', query);
}, 300);
// Throttle scroll events
const throttledScroll = throttle(() => {
console.log('Scroll position:', window.scrollY);
}, 100);
// Format file sizes
console.log(formatBytes(1024 * 1024)); // "1 MB"Contributions are welcome! Feel free to:
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
MIT License - feel free to use in your projects!
β If you find this useful, please consider giving it a star!