|
4 | 4 | [](https://jsrepo.dev/registry?url=github/rafifos/bits) |
5 | 5 | [](https://jsrepo.dev/registry?url=github/rafifos/bits) |
6 | 6 | [](https://jsrepo.dev/registry?url=github/rafifos/bits) |
| 7 | + |
| 8 | +A collection of reusable TypeScript utility functions and helpers that are too small to be their own libraries. |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +This repository contains small, focused utility functions that can be easily imported into your projects using [jsrepo](https://jsrepo.dev). Each utility is thoroughly tested and follows modern TypeScript best practices. |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +This library is distributed via jsrepo, which allows you to import just the specific utilities you need without any additional dependencies. |
| 17 | + |
| 18 | +1. Setup jsrepo if you haven't already: |
| 19 | + |
| 20 | +```bash |
| 21 | +npx jsrepo init --project |
| 22 | +``` |
| 23 | + |
| 24 | +2. Use any utility directly in your project: |
| 25 | + |
| 26 | +```bash |
| 27 | +npx jsrepo add github/rafifos/bits/utils/handle-async |
| 28 | +``` |
| 29 | + |
| 30 | +## Available Utilities |
| 31 | + |
| 32 | +- [handle-async](src/utils/handle-async.ts): A utility for handling async functions with proper error handling. |
| 33 | +- [should-never-happen](src/utils//should-never-happen.ts): A utility for handling cases that should never occur in your application flow. |
| 34 | + |
| 35 | +## Development |
| 36 | + |
| 37 | +### Prerequisites |
| 38 | + |
| 39 | +- Node.js ≥ 22 |
| 40 | +- pnpm ≥ 10 |
| 41 | + |
| 42 | +### Setup |
| 43 | + |
| 44 | +1. Clone the repository: |
| 45 | + |
| 46 | +```bash |
| 47 | +git clone https://github.com/rafifos/bits.git |
| 48 | +cd bits |
| 49 | +``` |
| 50 | + |
| 51 | +2. Install dependencies: |
| 52 | + |
| 53 | +```bash |
| 54 | +pnpm install |
| 55 | +``` |
| 56 | + |
| 57 | +### Commands |
| 58 | + |
| 59 | +- `pnpm build` - Builds the jsrepo registry |
| 60 | +- `pnpm test` - Runs tests with Jest |
| 61 | +- `pnpm lint` - Runs Biome linter and formatter |
| 62 | + |
| 63 | +### Adding a New Utility |
| 64 | + |
| 65 | +1. Create a new file in the appropriate category directory (e.g., `src/utils/my-utility.ts`) |
| 66 | +2. Add tests in a corresponding `my-utility.test.ts` file |
| 67 | +3. Run `pnpm build` to update the jsrepo manifest |
| 68 | +4. Run `pnpm test` to ensure everything works correctly |
| 69 | + |
| 70 | +### Commit Guidelines |
| 71 | + |
| 72 | +This project uses [Conventional Commits](https://www.conventionalcommits.org/) for commit messages, enforced by commitlint. |
| 73 | + |
| 74 | +Examples: |
| 75 | + |
| 76 | +- `feat: add new handle-error utility` |
| 77 | +- `fix: correct type definition in handle-async` |
| 78 | +- `docs: update usage examples` |
| 79 | +- `test: add more test cases for should-never-happen` |
| 80 | + |
| 81 | +## CI/CD |
| 82 | + |
| 83 | +This project uses GitHub Actions for continuous integration: |
| 84 | + |
| 85 | +- Code quality checks with Biome |
| 86 | +- Unit tests with Jest |
| 87 | +- Commit message validation with commitlint |
| 88 | +- Automatic jsrepo manifest updates |
| 89 | + |
| 90 | +## License |
| 91 | + |
| 92 | +MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments