← Back to all products
$29
TypeScript Utility Library
Type-safe utility functions, custom hooks, generic patterns, and advanced TypeScript techniques with full test coverage.
JSONMarkdownTypeScriptReact
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 22 files
typescript-utility-library/
├── LICENSE
├── README.md
├── examples/
│ └── real-world.ts
├── free-sample.zip
├── guide/
│ └── type-patterns.md
├── guides/
│ └── type-patterns.md
├── index.html
├── package.json
├── src/
│ ├── array.ts
│ ├── async.ts
│ ├── branded.ts
│ ├── guards.ts
│ ├── hooks/
│ │ └── index.ts
│ ├── index.ts
│ ├── object.ts
│ ├── patterns/
│ │ └── index.ts
│ ├── result.ts
│ └── string.ts
├── tests/
│ ├── array.test.ts
│ └── result.test.ts
├── tsconfig.json
└── vitest.config.ts
📖 Documentation Preview README excerpt
TypeScript Utility Library
A collection of type-safe utilities, custom hooks, and advanced TypeScript patterns for modern React/TypeScript applications. Everything is thoroughly typed with generics, and every function includes JSDoc documentation.
What's Included
Core Utilities (`src/`)
| Module | Functions | Description |
|---|---|---|
array.ts | 12 functions | Type-safe array operations (chunk, unique, groupBy, partition, zip, etc.) |
object.ts | 10 functions | Deep clone, pick, omit, merge, diff, flatten nested objects |
string.ts | 10 functions | slugify, truncate, template literals, case conversion, fuzzy match |
async.ts | 8 functions | retry, debounce, throttle, timeout, queue, parallel limit |
result.ts | 15 methods | Result and Option monads for error handling without try/catch |
branded.ts | 8 types | Branded/nominal types for domain-safe IDs, emails, URLs |
guards.ts | 12 guards | Runtime type guards with type narrowing (isString, isNonEmpty, etc.) |
Custom Hooks (`src/hooks/`)
| Hook | Description |
|---|---|
useLocalStorage | Persistent state with JSON serialization and SSR safety |
useDebounce | Debounced value with configurable delay |
usePrevious | Track the previous value of any variable |
useMediaQuery | Reactive CSS media query matching |
useEventListener | Type-safe event listener with automatic cleanup |
useInterval | setInterval with pause/resume and React-safe cleanup |
useOnClickOutside | Detect clicks outside a ref element |
useIsomorphicLayoutEffect | SSR-safe useLayoutEffect |
Advanced Patterns (`src/patterns/`)
| Pattern | Description |
|---|---|
Builder | Type-safe builder pattern with method chaining |
EventEmitter | Typed event system with subscribe/unsubscribe |
StateMachine | Finite state machine with typed transitions |
Registry | Type-safe service/component registry |
Pipeline | Composable data transformation pipelines |
Quick Start
# Copy the files you need into your project
cp -r typescript-utility-library/src/ your-project/src/utils/
# Or cherry-pick individual modules
cp typescript-utility-library/src/result.ts your-project/src/utils/
// Import what you need
import { Result, Ok, Err } from "./utils/result";
import { chunk, unique, groupBy } from "./utils/array";
import { useDebounce, useLocalStorage } from "./utils/hooks";
import type { Email, UserId } from "./utils/branded";
Running Tests
... continues with setup instructions, usage examples, and more.
📄 Code Sample .ts preview
vitest.config.ts
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
globals: true,
environment: "node",
include: ["tests/**/*.test.ts"],
coverage: {
provider: "v8",
include: ["src/**/*.ts"],
exclude: ["src/hooks/**"],
},
},
});