A collection of reusable TypeScript utility functions and helpers that are too small to be their own libraries.
This repository contains small, focused utility functions that can be easily imported into your projects using jsrepo. Each utility is thoroughly tested and follows modern TypeScript best practices.
This library is distributed via jsrepo, which allows you to import just the specific utilities you need without any additional dependencies.
- Setup jsrepo if you haven't already:
npx jsrepo init --project
- Use any utility directly in your project:
npx jsrepo add github/rafifos/bits/utils/handle-async
- handle-async: A utility for handling async functions with proper error handling.
- should-never-happen: A utility for handling cases that should never occur in your application flow.
- Node.js ≥ 22
- pnpm ≥ 10
- Clone the repository:
git clone https://github.com/rafifos/bits.git
cd bits
- Install dependencies:
pnpm install
pnpm build
- Builds the jsrepo registrypnpm test
- Runs tests with Jestpnpm lint
- Runs Biome linter and formatter
- Create a new file in the appropriate category directory (e.g.,
src/utils/my-utility.ts
) - Add tests in a corresponding
my-utility.test.ts
file - Run
pnpm build
to update the jsrepo manifest - Run
pnpm test
to ensure everything works correctly
This project uses Conventional Commits for commit messages, enforced by commitlint.
Examples:
feat: add new handle-error utility
fix: correct type definition in handle-async
docs: update usage examples
test: add more test cases for should-never-happen
This project uses GitHub Actions for continuous integration:
- Code quality checks with Biome
- Unit tests with Jest
- Commit message validation with commitlint
- Automatic jsrepo manifest updates
MIT License - see the LICENSE file for details.