@explita/utils
v0.3.0
Published
A lightweight and versatile collection of TypeScript utility functions designed for everyday development needs. Streamline your Node.js, React, and Next.js projects with a powerful set of well-organized helpers for strings, arrays, dates, objects, and mor
Maintainers
Keywords
Readme
@explita/utils
A lightweight, high-performance collection of TypeScript utility functions and React hooks designed for everyday development.
Explore Full Documentation & Examples →
📦 Installation
# npm
npm install @explita/utils
# pnpm
pnpm add @explita/utils
# yarn
yarn add @explita/utils⚡ Quick Start
import {
formatDate,
formatRelative,
timeAgo,
keyBy,
sortBy,
clamp,
formatCurrency,
truncate,
deepMerge,
get,
tryCatch,
} from "@explita/utils";
// 📅 Date Helpers
formatDate(new Date(), "YYYY-MM-DD"); // "2026-08-31"
timeAgo(Date.now() - 5 * 60 * 1000); // "5 minutes ago"
// 🗂️ Array Helpers
keyBy([{ id: "u_1", name: "Alice" }], "id"); // { "u_1": { id: "u_1", name: "Alice" } }
sortBy([{ price: 20 }, { price: 10 }], "price"); // [{ price: 10 }, { price: 20 }]
// 🔢 Numbers & Strings
clamp(105, 0, 100); // 100
formatCurrency(1234.56, "$"); // "$1,234.56"
truncate("The quick brown fox jumps", 15); // "The quick..."
// 📦 Objects & Async
get({ user: { name: "Sarah" } }, "user.name"); // "Sarah"
const [data, error] = await tryCatch(fetchUser());🎣 React Hooks
Import from @explita/utils/react:
import {
useLocalStorage,
useList,
useClipboard,
useOnClickOutside,
useMediaQuery,
useDisclosure,
} from "@explita/utils/react";
function ProfileWidget() {
const [theme, setTheme] = useLocalStorage("theme", "dark");
const { copy, copied } = useClipboard(2000);
const [isOpen, { toggle, close }] = useDisclosure(false);
const isMobile = useMediaQuery("(max-width: 768px)");
return (
<div>
<button onClick={() => copy("api_key_123")}>
{copied ? "Copied!" : "Copy API Key"}
</button>
</div>
);
}📚 Entry Points & Modules
| Entry Point | Description | Key Helpers |
| :--- | :--- | :--- |
| @explita/utils | Core utilities for dates, arrays, strings, objects, numbers, and async | formatDate, timeAgo, keyBy, sortBy, clamp, get, deepMerge, tryCatch, timeout, memoize |
| @explita/utils/react | React hooks with SSR safety | useLocalStorage, useList, useClipboard, useOnClickOutside, useMediaQuery, useIntersectionObserver, usePrevious, useIsMounted |
| @explita/utils/axios | Normalized Axios error handling | tryAxios (typed schemas with kind, meta, original) |
| @explita/utils/zod | Zod schema & form helpers | validateForm, mapZodIssues, createDefaultValues, isZodIssue |
| @explita/utils/file | Browser file exporters | saveCSVToFile, saveJSONToFile, saveXMLToFile |
📖 Detailed Documentation
For comprehensive API signatures, interactive examples, and guides, visit the documentation site:
- String Utilities
- Object Utilities
- Date Utilities
- Number & Array Utilities
- React Hooks
- Advanced Utilities (Async, Axios, File, Zod)
- Full API Reference
💖 Support & Community
- Star on GitHub: Give us a ⭐ on GitHub to help others discover the project.
- Report Issues: Found a bug or need a helper? Open an issue or start a discussion.
- Sponsor: Support continued development via GitHub Sponsors or Ko-fi.
📄 License
MIT © Explita
