|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to this project will be documented in this file. |
| 4 | + |
| 5 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
| 6 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | + |
| 8 | +## [0.1.0] - 2025-11-04 |
| 9 | + |
| 10 | +### ⚠️ BREAKING CHANGES |
| 11 | + |
| 12 | +This release introduces **breaking changes** that will require code updates for existing users. |
| 13 | + |
| 14 | +#### Error Handling Changes |
| 15 | + |
| 16 | +**Previous Behavior (v0.0.x):** |
| 17 | +- Invalid inputs (null, undefined, non-numeric strings) were silently handled |
| 18 | +- Methods returned `0` and logged warnings to console |
| 19 | +- Division by zero returned `0` |
| 20 | + |
| 21 | +**New Behavior (v0.1.0+):** |
| 22 | +- Invalid inputs now throw `HyperMathError` exceptions |
| 23 | +- Division by zero throws `DivisionByZeroError` (extends `HyperMathError`) |
| 24 | +- No silent failures - all errors must be handled |
| 25 | + |
| 26 | +#### Migration Guide |
| 27 | + |
| 28 | +**Before (v0.0.x):** |
| 29 | +```typescript |
| 30 | +import { HyperMath } from 'hypermath'; |
| 31 | + |
| 32 | +// Silent failure - returns 0 on error |
| 33 | +const result = HyperMath.multiply(userInput, 5); |
| 34 | +const quotient = HyperMath.divide(10, 0); // Returns 0 |
| 35 | +``` |
| 36 | + |
| 37 | +**After (v0.1.0+):** |
| 38 | +```typescript |
| 39 | +import { HyperMath, HyperMathError, DivisionByZeroError } from 'hypermath'; |
| 40 | + |
| 41 | +// Proper error handling required |
| 42 | +try { |
| 43 | + const result = HyperMath.multiply(userInput, 5); |
| 44 | +} catch (error) { |
| 45 | + if (error instanceof HyperMathError) { |
| 46 | + console.error('Invalid input:', error.message); |
| 47 | + // Handle error appropriately |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +// Division by zero protection |
| 52 | +try { |
| 53 | + const quotient = HyperMath.divide(10, divisor); |
| 54 | +} catch (error) { |
| 55 | + if (error instanceof DivisionByZeroError) { |
| 56 | + console.error('Cannot divide by zero'); |
| 57 | + } |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +#### Behavior Corrections |
| 62 | + |
| 63 | +- **`subtract(0, n)`**: Now correctly returns `-n` instead of `0` |
| 64 | +- **`divide(0, n)`**: Now correctly returns `0` (unchanged) |
| 65 | +- **Edge case handling**: Proper handling of NaN, Infinity, and extreme values |
| 66 | + |
| 67 | +### Added |
| 68 | + |
| 69 | +- ✨ **Custom Error Classes** |
| 70 | + - `HyperMathError`: Base error class for all HyperMath errors |
| 71 | + - `DivisionByZeroError`: Specific error for division by zero operations |
| 72 | + |
| 73 | +- 📚 **Comprehensive Documentation** |
| 74 | + - JSDoc comments for all public methods |
| 75 | + - Detailed parameter and return type documentation |
| 76 | + - Error throwing documentation with examples |
| 77 | + |
| 78 | +- ✅ **Robust Test Coverage** |
| 79 | + - Expanded from 4 to 52 unit tests |
| 80 | + - Edge case testing (negative numbers, zero handling, precision) |
| 81 | + - Invalid input testing for all methods |
| 82 | + - All tests passing with 100% coverage of core functionality |
| 83 | + |
| 84 | +- 🛡️ **Enhanced Input Validation** |
| 85 | + - Validates null, undefined, NaN, Infinity |
| 86 | + - Trims whitespace from string inputs |
| 87 | + - Better error messages with context |
| 88 | + - Type checking for unsupported types |
| 89 | + |
| 90 | +- 📦 **Package Configuration** |
| 91 | + - Added `types` field for TypeScript definitions |
| 92 | + - Added `files` field to optimize package size |
| 93 | + - Only distributes necessary files (dist, README, LICENSE) |
| 94 | + |
| 95 | +### Changed |
| 96 | + |
| 97 | +- 🔧 **Code Refactoring** |
| 98 | + - Extracted `processInput()` as private helper method |
| 99 | + - Extracted `formatResult()` as private helper method |
| 100 | + - Cleaner, more maintainable code structure |
| 101 | + - Better separation of concerns |
| 102 | + |
| 103 | +- 📖 **README Improvements** |
| 104 | + - Added error handling section with examples |
| 105 | + - Enhanced API documentation with parameters and throws |
| 106 | + - Added edge cases documentation |
| 107 | + - Corrected technical inaccuracies (`.toFixed()` vs `.toPrecision()`) |
| 108 | + - Added support section with GitHub issues link |
| 109 | + - Updated features list with accurate descriptions |
| 110 | + |
| 111 | +### Fixed |
| 112 | + |
| 113 | +- 🐛 **Subtract method**: Now correctly handles `subtract(0, n)` returning `-n` instead of `0` |
| 114 | +- 🐛 **Precision documentation**: Corrected claims about "2 significant digits" to "2 decimal places" |
| 115 | + |
| 116 | +### Technical Details |
| 117 | + |
| 118 | +- **Error Types**: All methods now throw typed errors for better error handling |
| 119 | +- **Input Processing**: Unified input validation across all methods |
| 120 | +- **TypeScript Support**: Full type safety with exported error classes |
| 121 | +- **Zero Dependencies**: Remains lightweight with no external dependencies |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## [0.0.10] - Previous Release |
| 126 | + |
| 127 | +### Features |
| 128 | +- Basic arithmetic operations (multiply, add, divide, subtract) |
| 129 | +- Precision handling up to 2 decimal places |
| 130 | +- String and number input support |
| 131 | +- Console warnings for invalid inputs |
| 132 | + |
| 133 | +### Behavior |
| 134 | +- Silent failure mode (returns 0 on errors) |
| 135 | +- Console.warn for invalid inputs |
| 136 | +- Limited edge case handling |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## Upgrading from v0.0.x to v0.1.0 |
| 141 | + |
| 142 | +### Required Changes |
| 143 | + |
| 144 | +1. **Wrap arithmetic operations in try-catch blocks** where invalid input is possible |
| 145 | +2. **Import error classes** if you need to catch specific error types |
| 146 | +3. **Remove any code** that relied on `0` being returned for invalid inputs |
| 147 | +4. **Update tests** to expect thrown errors instead of `0` returns |
| 148 | + |
| 149 | +### Benefits |
| 150 | + |
| 151 | +- ✅ Better error visibility and debugging |
| 152 | +- ✅ More predictable behavior |
| 153 | +- ✅ Proper TypeScript error typing |
| 154 | +- ✅ Production-ready error handling |
| 155 | +- ✅ Comprehensive test coverage |
| 156 | + |
| 157 | +### Support |
| 158 | + |
| 159 | +If you encounter issues upgrading, please: |
| 160 | +- Check the [README](README.md) for updated usage examples |
| 161 | +- Review the error handling section |
| 162 | +- Open an issue on [GitHub](https://github.com/hyperteksolutions/hypermath/issues) |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +[0.1.0]: https://github.com/hyperteksolutions/hypermath/compare/v0.0.10...v0.1.0 |
| 167 | +[0.0.10]: https://github.com/hyperteksolutions/hypermath/releases/tag/v0.0.10 |
0 commit comments