Fragmen

Copy‑paste TypeScript utilities into your project.

Browse 50+ focused fragments across 9 categories. Own the code, adapt it freely, and ship without extra dependencies.

npx fragmen add promise/delay
Utilities
Categories
Test Coverage
Dependencies

See It In Action

Real utilities solving real problems. Here's how chunk splits an array into smaller pieces.

Input Array

A list of 10 items to split

const items = [
1, 2, 3, 4, 5,
6, 7, 8, 9, 10
]
Length: 10

chunk(items, 3)

Split into groups of 3

Result:
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
[10]
Chunks: 4

Implementation

import { chunk } from '@/lib/chunk';

const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const chunks = chunk(items, 3);

console.log(chunks);
// [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]

// Perfect for pagination
const paginatedData = chunk(allProducts, 20);
// Display page 1: paginatedData[0]

Own Your Code

Utilities are copied into your codebase so you can inspect, adapt, and learn from them.

Zero Dependencies

Each fragment is self‑contained. Adding a utility won't bloat your project.

TypeScript First

Written in TypeScript with strong types and clear JSDoc.

Why Fragmen?

How Fragmen compares to other approaches

npm Packages

Install full libraries for small utilities

Large bundle sizes
Security vulnerabilities
Breaking changes in updates
Easy to install

Stack Overflow

Copy-paste random code snippets

No TypeScript types
Untested code
Inconsistent quality
Free to use

Fragmen

Best

Battle-tested, typed utilities you own

Full code ownership
TypeScript first
100% test coverage
Zero dependencies

Frequently Asked Questions

Everything you need to know about Fragmen

How is Fragmen different from lodash or other utility libraries?

Unlike traditional npm packages, Fragmen copies utilities directly into your codebase. This means you own the code completely, can modify it freely, and don't add dependencies to your project. Each utility is self-contained with no external dependencies.

Do I need to credit Fragmen in my project?

No attribution required! Fragmen is MIT licensed. Once you copy a utility, it's yours to use, modify, and distribute however you like. We only ask that you keep the MIT license notice in the code.

Can I modify the utilities after copying them?

Absolutely! That's the whole point. The code is now part of your project. Adapt it to your specific needs, add features, optimize for your use case, or learn from it. You have complete freedom.

How do updates work if I copy code into my project?

Since the code lives in your project, updates are manual. You can check the registry for improvements and copy new versions when needed. This gives you control over when and what to update, avoiding breaking changes.

Are the utilities tested?

Yes! Every utility has comprehensive test coverage with multiple test cases. You can view the tests in the registry alongside the source code. Tests are written using Vitest.

Can I use Fragmen in commercial projects?

Yes! Fragmen is MIT licensed, which means you can use it freely in both personal and commercial projects without any restrictions or fees.

Quick Start

1

Initialize

npx fragmen init
2

Browse Utilities

npx fragmen browse
3

Add to Your Project

npx fragmen add promise/delay string/capitalize