← Back to all products

TypeScript Utility Library

$29

Type-safe utility functions, custom hooks, generic patterns, and advanced TypeScript techniques with full test coverage.

📁 22 files
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/`)

ModuleFunctionsDescription
array.ts12 functionsType-safe array operations (chunk, unique, groupBy, partition, zip, etc.)
object.ts10 functionsDeep clone, pick, omit, merge, diff, flatten nested objects
string.ts10 functionsslugify, truncate, template literals, case conversion, fuzzy match
async.ts8 functionsretry, debounce, throttle, timeout, queue, parallel limit
result.ts15 methodsResult and Option monads for error handling without try/catch
branded.ts8 typesBranded/nominal types for domain-safe IDs, emails, URLs
guards.ts12 guardsRuntime type guards with type narrowing (isString, isNonEmpty, etc.)

Custom Hooks (`src/hooks/`)

HookDescription
useLocalStoragePersistent state with JSON serialization and SSR safety
useDebounceDebounced value with configurable delay
usePreviousTrack the previous value of any variable
useMediaQueryReactive CSS media query matching
useEventListenerType-safe event listener with automatic cleanup
useIntervalsetInterval with pause/resume and React-safe cleanup
useOnClickOutsideDetect clicks outside a ref element
useIsomorphicLayoutEffectSSR-safe useLayoutEffect

Advanced Patterns (`src/patterns/`)

PatternDescription
BuilderType-safe builder pattern with method chaining
EventEmitterTyped event system with subscribe/unsubscribe
StateMachineFinite state machine with typed transitions
RegistryType-safe service/component registry
PipelineComposable 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/**"], }, }, });
Buy Now — $29 Back to Products