A shadcn-style utility library for TypeScript - copy utilities into your project
عون (Awn, meaning "help" in Arabic) is a collection of TypeScript utility functions that you can copy directly into your project, inspired by the shadcn/ui approach. Instead of installing a heavy dependency, you get clean, typed utility functions that live in your codebase.
npm install -g awn
# Create utils.json configuration file
npx awn init
This creates a utils.json
file similar to shadcn's components.json
:
{
"$schema": "https://awn.dev/schema.json",
"utils": {
"path": "./src/utils"
},
"aliases": {
"utils": "~/utils"
}
}
# Add a utility function (uses config path)
npx awn add debounce
# Override with custom path
npx awn add chunk --path ./src/lib/utils
# List all available utilities
npx awn search
# Search with fuzzy matching
npx awn search array
npx awn search case
npx awn search random
chunk
- Split array into chunks of specified sizeuniq
- Remove duplicates from arrayuniqBy
- Remove duplicates using iteratee functionflatten
- Flatten array one level deepflattenDeep
- Recursively flatten arraysample
- Get random element from arraysampleSize
- Get n random elements from array
camelCase
- Convert to camelCase formatpascalCase
- Convert to PascalCase formatkebabCase
- Convert to kebab-case formatsnakeCase
- Convert to snake_case formatdebounce
- Create debounced functionthrottle
- Create throttled functiontruncate
- Truncate string with optionscapitalize
- Capitalize first characterstartCase
- Convert to Start Case (Title Case)
clamp
- Clamp number within boundsinRange
- Check if number is in rangerandom
- Generate random numbers with optionsrandomInt
- Generate random integersround
- Round number to precisionceil
- Ceil number to precisionfloor
- Floor number to precisionpercentage
- Calculate percentage with precision
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Format code
npm run format
# Lint
npm run lint
# Type check
npm run typecheck
This project uses Changesets for version management:
# Add a changeset (describes your changes)
npm run changeset
# Version packages (consumes changesets and updates versions)
npm run version
# Publish to NPM (builds and publishes)
npm run release
The GitHub Actions workflow will automatically:
- Create release PRs when changesets are added
- Publish to NPM when release PRs are merged
Awn maintains a registry of utility functions with embedded manifests. When you run npx awn add <utility>
, it copies only the function code (without metadata) directly into your project. This means:
- ✅ No runtime dependencies
- ✅ Full TypeScript support with strict typing
- ✅ You own the code
- ✅ Easy to customize
- ✅ Tree-shakeable by default
- ✅ Fuzzy search to discover utilities
- ✅ Each utility in its own file
- 24 utilities across 3 categories (Array, String, Number)
- Individual test files for each utility (95 tests total)
- Fuzzy search with
npx awn search
- Embedded manifests with examples and tags
- Prettier formatting and ESLint rules
- GitHub Actions CI/CD pipeline
- TypeScript strict mode with comprehensive types
// After running: npx awn add chunk
import { chunk } from './utils/chunk';
chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
// After running: npx awn add debounce
import { debounce } from './utils/debounce';
const debouncedFn = debounce(fn, 300);
// After running: npx awn add clamp
import { clamp } from './utils/clamp';
clamp(5, 1, 10); // 5
clamp(-5, 1, 10); // 1
The utils.json
file allows you to customize how Awn works in your project:
{
"$schema": "https://awn.dev/schema.json",
"utils": {
"path": "./src/utils"
},
"aliases": {
"utils": "~/utils",
"~": "./src",
"@": "./src"
}
}
Configuration Options:
utils.path
- Where utilities will be stored (default:./src/utils
)aliases
- Path aliases for import statementsaliases.utils
- Alias shown in import suggestions (default:~/utils
)
Creating Configuration:
npx awn init # Creates utils.json with defaults
The configuration is optional. Without it, Awn will use ./src/utils
as the default path.
MIT