@prishelets/utils
Version:
A modern utility library for strings, numbers, and general data types β fully typed, tested, and built for Node.js and TypeScript.
265 lines (169 loc) β’ 5.48 kB
Plain Text
@prishelets/utils
[](https://www.npmjs.com/package/@prishelets/utils)
[](https://github.com/Curslo/prishelets/actions)
[](https://github.com/Curslo/prishelets/blob/main/LICENSE)
π¦ Description
**@prishelets/utils** is a modern, type-safe utility library for working with strings, numbers, and general data types. Itβs fully typed, tested, and optimized for Node.js and TypeScript projects.
β¨ Features
- π§ Fully typed with TypeScript
- π§ͺ Tested with Jest
- β‘ Lightweight and modular
- π Useful for everyday string and number manipulation
- π§ Tree-shakable and ESM/CommonJS compatible
π₯ Installation
npm install @prishelets/utils
or
pnpm add @prishelets/utils
or
yarn add @prishelets/utils
π Usage
import { clamp, isEven, roundTo, randomInRange } from '@prishelets/utils';
clamp(5, 0, 10); // 5
isEven(4); // true
roundTo(3.14159, 2); // 3.14
randomInRange(1, 5); // e.g., 3
π’ Number Utilities
clamp(value, min, max)
Clamp a number between a min and max range.
clamp(5, 0, 10); // 5
clamp(-1, 0, 10); // 0
clamp(15, 0, 10); // 10
isEven(value)
Check if a number is even.
isEven(4); // true
isEven(3); // false
roundTo(value, decimals)
Round a number to a specific number of decimal places.
roundTo(3.14159, 2); // 3.14
roundTo(1.005, 2); // 1.01
randomInRange(min, max)
Generate a random integer between min and max (inclusive).
randomInRange(1, 3); // e.g., 2
π Roadmap
String utilities
Array helpers
Object type guards
Functional programming tools
Performance benchmarks
TypeScript documentation generator
π Project Structure
βββ src/
β βββ numbers/
β βββ clamp.ts
β βββ isEven.ts
β βββ randomInRange.ts
β βββ roundTo.ts
βββ dist/ (compiled output)
βββ .github/workflows/ (CI)
βββ package.json
π§ͺ Testing
npm run test
This runs all tests via Jest. Test files are colocated with source files or kept in a __tests__ directory.
π§Ύ License
ISC Β© Curslo
π¬ Feedback & Contributions
Feel free to open issues or pull requests. Ideas, bug reports, and feature requests are welcome!
π GitHub: github.com/Curslo/prishelets
# @prishelets/utils
[](https://www.npmjs.com/package/@prishelets/utils)
[](https://github.com/Curslo/prishelets/actions)
[](https://github.com/Curslo/prishelets/blob/main/LICENSE)
## π¦ Description
**@prishelets/utils** is a modern, type-safe utility library for working with strings, numbers, and general data types. Itβs fully typed, tested, and optimized for Node.js and TypeScript projects.
## β¨ Features
- π§ Fully typed with TypeScript
- π§ͺ Tested with Jest
- β‘ Lightweight and modular
- π Useful for everyday string and number manipulation
- π§ Tree-shakable and ESM/CommonJS compatible
## π₯ Installation
```bash
npm install @prishelets/utils
### or
pnpm add @prishelets/utils
### or
yarn add @prishelets/utils
````
## π Usage
```ts
import { clamp, isEven, roundTo, randomInRange } from '@prishelets/utils';
```
```ts
clamp(5, 0, 10); // 5
isEven(4); // true
roundTo(3.14159, 2); // 3.14
randomInRange(1, 5); // e.g., 3
```
## π’ Number Utilities
### `clamp(value, min, max)`
Clamp a number between a min and max range.
```ts
clamp(5, 0, 10); // 5
clamp(-1, 0, 10); // 0
clamp(15, 0, 10); // 10
```
### `isEven(value)`
Check if a number is even.
```ts
isEven(4); // true
isEven(3); // false
```
### `roundTo(value, decimals)`
Round a number to a specific number of decimal places.
```ts
roundTo(3.14159, 2); // 3.14
roundTo(1.005, 2); // 1.01
```
### `randomInRange(min, max)`
Generate a random integer between `min` and `max` (inclusive).
```ts
randomInRange(1, 3); // e.g., 2
```
## π Roadmap
* [ ] String utilities
* [ ] Array helpers
* [ ] Object type guards
* [ ] Functional programming tools
* [ ] Performance benchmarks
* [ ] TypeScript documentation generator
## π Project Structure
```
βββ src/
β βββ numbers/
β βββ clamp.ts
β βββ isEven.ts
β βββ randomInRange.ts
β βββ roundTo.ts
βββ dist/ (compiled output)
βββ .github/workflows/ (CI)
βββ package.json
```
## π§ͺ Testing
```bash
npm run test
```
This runs all tests via **Jest**. Test files are colocated with source files or kept in a `__tests__` directory.
## π§Ύ License
**ISC** Β© [Curslo](https://github.com/Curslo)
## π¬ Feedback & Contributions
Feel free to open issues or pull requests. Ideas, bug reports, and feature requests are welcome!
π GitHub: [github.com/Curslo/prishelets](https://github.com/Curslo/prishelets)
```
Let me know if you would like to add badges for test coverage, bundle size, or Prettier/linting.
```