xantiagoma
v0.1.2
Published
Lightweight, type-safe TypeScript utilities
Maintainers
Readme
Install
npm install xantiagomaEntry Points
| Import | Description | Dependencies |
| ----------------------- | -------------------------------------- | -------------------------------- |
| xantiagoma | Core utilities (isomorphic, zero deps) | none |
| xantiagoma/web | Browser/FormData utilities | none |
| xantiagoma/ulid | Prefixed ULID generation + helpers | ulid |
| xantiagoma/temporal | Date/time/duration with Temporal API | temporal-polyfill, itty-time |
| xantiagoma/dataloader | DataLoader factory | dataloader |
| xantiagoma/unstorage | Cache helpers with unstorage | unstorage, ohash |
| xantiagoma/valibot | TimeZone validation schema | valibot |
| xantiagoma/sonner | Toast streaming for iterables | sonner, react |
| xantiagoma/react | React hooks + components | react, @tanstack/react-query |
Sub-entry dependencies are optional peer deps — only install what you use.
Core Utilities (xantiagoma)
Error Handling
| Export | Description | Source | Tests |
| --------------------------- | -------------------------------------- | ------------------------------- | --------------------------------------- |
| tryCatch / tryCatchSync | [data, error] tuples — no try/catch | src | tests |
| assertNotNull | Throws if null/undefined, narrows type | src | tests |
| valueOrThrow | Returns value or throws | src | tests |
| AssertError | Custom error class | src | tests |
Async
| Export | Description | Source | Tests |
| --------------------- | ---------------------------------------- | ------------------------------------- | --------------------------------------------- |
| wait | Typed setTimeout delay | src | tests |
| Completer | Externally resolvable Promise | src | tests |
| collect | Drain AsyncIterable<T> into T[] | src | tests |
| asyncOf | Create AsyncGenerator from values | src | tests |
| AsyncChannel | Push-based AsyncIterable with modes | src | tests |
| resolveMaybePromise | Resolve T \| Promise<T> → Promise<T> | src | tests |
Iterables & Generators
| Export | Description | Source | Tests |
| ------------------------------ | --------------------------------- | --------------------------------- | ----------------------------------------- |
| range / rangeLazy | Numeric range (array / generator) | src | tests |
| enumerate / enumerateAsync | [index, value] tuples | src | tests |
| toIterator | Normalize to Iterator | src | tests |
| toAsyncIterable | Normalize to AsyncGenerator | src | tests |
Type Guards
| Export | Description | Source | Tests |
| --------------------------------------------------------- | ---------------------- | ---------------------------------- | ------------------------------------------ |
| isPromise | Promise-like check | src | tests |
| isIterable | Iterable check | src | tests |
| isAsyncIterable | AsyncIterable check | src | tests |
| isIterator | Iterator check | src | tests |
| isGenerator | Generator check | src | tests |
| isAsyncGenerator | AsyncGenerator check | src | tests |
| isDisposable / isAsyncDisposable / isSyncDisposable | Disposable checks | src | tests |
Disposable Utilities
| Export | Description | Source | Tests |
| --------------------- | --------------------------------------- | ------------------------------- | --------------------------------------- |
| defer / deferSync | Cancellable using/await using | src | tests |
| makeDisposable | Add Symbol.asyncDispose to any object | src | tests |
Strings
| Export | Description | Source | Tests |
| ------------------------------------------------------------- | ---------------- | ---------------------- | ------------------------------ |
| ensureString / naturalSortCompare / jaroWinklerDistance | String utilities | src | tests |
Misc
| Export | Description | Source | Tests |
| ------------------------------------------- | --------------------------------------- | ------------------------------------- | --------------------------------------------- |
| cast<T> | Unsafe as T type cast | src | tests |
| log | console.log that returns its argument | src | tests |
| prepareLoaderResult | Map DB rows to DataLoader key order | src | tests |
| resolveStreamSource | Resolve StreamSource<T> | src | tests |
| secondsToMs / minutesToMs / hoursToMs | Time unit converters | src | tests |
Web Utilities (xantiagoma/web)
| Export | Description | Source | Tests |
| ----------------------- | ----------------------------------- | ----------------------------------------- | ------------------------------------------- |
| formDataToObject | FormData → plain object | src | tests |
| fetchWithProgress | Fetch with upload/download progress | src | tests |
| createHttpInterceptor | Intercept fetch + XHR with rules | src | tests |
React Utilities (xantiagoma/react)
| Export | Description | Source | Tests |
| ------------------------------ | ----------------------------------- | -------------------------------------- | ----------------------------------------------- |
| Providers / provider | Compose providers without nesting | src | tests |
| usePreventAutoFocus | Prevent auto-focus in modals | src | tests |
| useDynamicRefs | Dynamic ref registry by key | src | tests |
| useStream / StreamRenderer | Stream consumption hook + component | src | tests |
Recommended Libraries
These are libraries we use and recommend. They're not re-exported — install them directly:
| Library | Description | | -------------------------------------------------------------------------- | ----------------------------------- | | es-toolkit | Modern lodash alternative | | ohash | Object hashing | | unstorage | Universal key-value storage | | cockatiel | Retry / circuit breaker / bulkhead | | chroma-js | Color manipulation | | xbytes | Byte size formatting | | etiket | Barcode generation | | portakal | Printer / ESC/POS | | hucre | Spreadsheet utilities | | @gobrand/tiempo | Time formatting / parsing | | tactus | Haptic feedback for web | | liveline | Animated line charts (React) | | react-lzy-img | Lazy loading images (React) | | masonic | Virtualized masonry layout (React) | | p-map | Concurrent async mapping | | motion | Animation library (React) | | tailwind-merge | Merge Tailwind classes | | lucide-react | Icon library (React) | | jotai | Atomic state management (React) | | permix | Permission management | | std-env | Runtime environment detection | | ufo | URL utilities | | @total-typescript/ts-reset | Stricter TypeScript defaults | | better-auth | Authentication framework | | drizzle-orm | TypeScript ORM | | drizzle-cursor | Cursor-based pagination for Drizzle | | drizzle-audit | Audit logging for Drizzle | | elysia | Bun-first web framework | | hono | Lightweight web framework | | inngest | Background jobs + durable functions | | stripe | Payment processing | | paykit | Payment toolkit for Stripe | | @tanstack/react-query | Async state management (React) | | @tanstack/react-table | Headless table (React) | | @tanstack/react-form | Form management (React) | | @tanstack/react-virtual | Virtualized lists (React) | | ai | Vercel AI SDK | | graphql-yoga | GraphQL server | | pothos | GraphQL schema builder | | react-router | Routing (React) | | class-variance-authority | Component variant classes | | clsx | Conditional classnames | | next-themes | Theme management (React) | | react-email | Email templates (React) | | @uppy/core | File upload | | dotenv | Environment variables | | citty | CLI framework | | evlog | Event logging | | @electric-sql/pglite | In-memory PostgreSQL | | neverthrow | Type-safe Result type | | ts-pattern | Exhaustive pattern matching | | nanoid | Tiny unique ID generator | | superjson | Serialize Date, Map, Set via JSON | | destr | Safe, fast JSON.parse alternative | | dequal | Tiny deep equality check | | klona | Tiny deep clone | | mutative | Fast immutable updates (like Immer) | | ofetch | Better fetch with retries + parsing | | ky | Tiny fetch-based HTTP client | | consola | Elegant structured logger | | p-queue | Promise queue with concurrency | | croner | Cron scheduler (Node + browser) | | oslo | Auth utilities (TOTP, JWT, hashing) | | arctic | OAuth 2.0 provider integrations | | casl | Isomorphic authorization | | unctx | Composables via AsyncLocalStorage | | execa | Better child_process | | knip | Find unused code + dependencies | | clack | Beautiful CLI prompts + spinners | | sonner | Toast notifications (React) | | vaul | Drawer component (React) | | cmdk | Command menu (React) | | embla-carousel | Lightweight carousel | | dnd-kit | Drag and drop toolkit (React) | | nuqs | Type-safe URL search params (React) | | react-error-boundary | Error boundary component (React) | | react-hotkeys-hook | Keyboard shortcuts hook (React) | | auto-animate | Zero-config DOM animations | | satori | JSX/HTML to SVG (OG images) | | orama | In-memory full-text + vector search | | gql.tada | Typed GraphQL documents at compile | | kysely | Type-safe SQL query builder | | currency.js | Safe currency arithmetic | | thumbhash | Image placeholder algorithm | | noble-hashes | Audited crypto hashes (pure TS) | | better-all | Better Promise.all with named keys | | better-result | Rust-like Result type for TS | | fuse.js | Lightweight fuzzy search | | files-sdk | Unified file storage SDK | | streamdown | Stream Markdown rendering | | ai-elements | AI-powered UI components | | tiptap | Headless rich text editor | | better-notify | Notification management | | @vercel/chat | Chat UI components | | @vercel/workflow | Durable workflow engine | | trigger.dev | Background jobs platform | | temporal | Durable workflow orchestration | | @vercel/sandbox | Code sandbox execution | | reactflow | Node-based graph editor (React) | | date-fns | Modern date utility library | | cheerio | Fast HTML parsing + manipulation | | dexie | IndexedDB wrapper with clean API |
See Also
- drizzle-cursor — Cursor-based pagination for Drizzle ORM
- drizzle-audit — Configurable audit logging for Drizzle ORM
License
MIT
