@rezzon8/math-utils 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# @rezzon8/math-utils
|
|
2
|
+
|
|
3
|
+
Basic math utility functions with TypeScript support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @rezzon8/math-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { add, subtract, multiply, divide } from '@rezzon8/math-utils'
|
|
15
|
+
|
|
16
|
+
// Addition
|
|
17
|
+
const sum = add(5, 3) // 8
|
|
18
|
+
|
|
19
|
+
// Subtraction
|
|
20
|
+
const difference = subtract(10, 4) // 6
|
|
21
|
+
|
|
22
|
+
// Multiplication
|
|
23
|
+
const product = multiply(6, 7) // 42
|
|
24
|
+
|
|
25
|
+
// Division
|
|
26
|
+
const quotient = divide(20, 5) // 4
|
|
27
|
+
|
|
28
|
+
// Division by zero throws an error
|
|
29
|
+
try {
|
|
30
|
+
divide(10, 0)
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(error.message) // "Division by zero is not allowed"
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
### `add(a: number, b: number): number`
|
|
39
|
+
|
|
40
|
+
Returns the sum of two numbers.
|
|
41
|
+
|
|
42
|
+
**Parameters:**
|
|
43
|
+
|
|
44
|
+
- `a` - First number
|
|
45
|
+
- `b` - Second number
|
|
46
|
+
|
|
47
|
+
**Returns:** The sum of `a` and `b`
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### `subtract(a: number, b: number): number`
|
|
52
|
+
|
|
53
|
+
Returns the difference of two numbers.
|
|
54
|
+
|
|
55
|
+
**Parameters:**
|
|
56
|
+
|
|
57
|
+
- `a` - First number
|
|
58
|
+
- `b` - Second number
|
|
59
|
+
|
|
60
|
+
**Returns:** The difference (`a - b`)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### `multiply(a: number, b: number): number`
|
|
65
|
+
|
|
66
|
+
Returns the product of two numbers.
|
|
67
|
+
|
|
68
|
+
**Parameters:**
|
|
69
|
+
|
|
70
|
+
- `a` - First number
|
|
71
|
+
- `b` - Second number
|
|
72
|
+
|
|
73
|
+
**Returns:** The product of `a` and `b`
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
### `divide(a: number, b: number): number`
|
|
78
|
+
|
|
79
|
+
Returns the quotient of two numbers.
|
|
80
|
+
|
|
81
|
+
**Parameters:**
|
|
82
|
+
|
|
83
|
+
- `a` - Dividend
|
|
84
|
+
- `b` - Divisor
|
|
85
|
+
|
|
86
|
+
**Returns:** The quotient (`a / b`)
|
|
87
|
+
|
|
88
|
+
**Throws:** Error if `b` is zero
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Development
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Install dependencies
|
|
96
|
+
npm install
|
|
97
|
+
|
|
98
|
+
# Run tests
|
|
99
|
+
npm test
|
|
100
|
+
|
|
101
|
+
# Run tests in watch mode
|
|
102
|
+
npm run test:watch
|
|
103
|
+
|
|
104
|
+
# Build the package
|
|
105
|
+
npm run build
|
|
106
|
+
|
|
107
|
+
# Lint code
|
|
108
|
+
npm run lint
|
|
109
|
+
|
|
110
|
+
# Fix linting issues
|
|
111
|
+
npm run lint:fix
|
|
112
|
+
|
|
113
|
+
# Format code
|
|
114
|
+
npm run format
|
|
115
|
+
|
|
116
|
+
# Check formatting
|
|
117
|
+
npm run format:check
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Features
|
|
121
|
+
|
|
122
|
+
- ✅ TypeScript support with full type definitions
|
|
123
|
+
- ✅ ESM modules
|
|
124
|
+
- ✅ Comprehensive test coverage with Vitest
|
|
125
|
+
- ✅ Modern ESLint + Prettier configuration
|
|
126
|
+
- ✅ Source maps included
|
|
127
|
+
|
|
128
|
+
## Repository
|
|
129
|
+
|
|
130
|
+
[https://github.com/rezzon8/npm-package](https://github.com/rezzon8/npm-package)
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
ISC © 2025
|