All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- ✨ Variadic Parameters:
add()andsubtract()now support multiple argumentsHyperMath.add(1, 2, 3, 4, 5)returns15HyperMath.subtract(100, 10, 5, 2)returns83- Minimum 2 parameters required (maintains backward compatibility)
- All values are validated and processed with the same precision handling
- 🔧 API Enhancement: Updated
add()andsubtract()to use rest parameters (...values) - 📝 Documentation: Updated README and JSDoc comments to reflect variadic parameter support
- ✅ Added 19 new tests for variadic parameter functionality
- ✅ Test suite now includes 81 tests (up from 62)
- ✅ Comprehensive coverage of multi-parameter scenarios, edge cases, and error conditions
- Backward Compatibility: Existing two-parameter calls continue to work without changes
- Type Safety: Full TypeScript support with proper type inference for rest parameters
- Performance: Uses efficient
reduce()implementation for processing multiple values
- 🐛 String validation: Changed from
parseFloat()toNumber()for string input validation to properly reject strings with trailing non-numeric characters (e.g.,"3.14abc"now throwsHyperMathErrorinstead of being parsed as3.14)
0.1.0 - 2025-11-04
This release introduces breaking changes that will require code updates for existing users.
Previous Behavior (v0.0.x):
- Invalid inputs (null, undefined, non-numeric strings) were silently handled
- Methods returned
0and logged warnings to console - Division by zero returned
0
New Behavior (v0.1.0+):
- Invalid inputs now throw
HyperMathErrorexceptions - Division by zero throws
DivisionByZeroError(extendsHyperMathError) - No silent failures - all errors must be handled
Before (v0.0.x):
import { HyperMath } from 'hypermath';
// Silent failure - returns 0 on error
const result = HyperMath.multiply(userInput, 5);
const quotient = HyperMath.divide(10, 0); // Returns 0After (v0.1.0+):
import { HyperMath, HyperMathError, DivisionByZeroError } from 'hypermath';
// Proper error handling required
try {
const result = HyperMath.multiply(userInput, 5);
} catch (error) {
if (error instanceof HyperMathError) {
console.error('Invalid input:', error.message);
// Handle error appropriately
}
}
// Division by zero protection
try {
const quotient = HyperMath.divide(10, divisor);
} catch (error) {
if (error instanceof DivisionByZeroError) {
console.error('Cannot divide by zero');
}
}subtract(0, n): Now correctly returns-ninstead of0divide(0, n): Now correctly returns0(unchanged)- Edge case handling: Proper handling of NaN, Infinity, and extreme values
-
✨ Custom Error Classes
HyperMathError: Base error class for all HyperMath errorsDivisionByZeroError: Specific error for division by zero operations
-
📚 Comprehensive Documentation
- JSDoc comments for all public methods
- Detailed parameter and return type documentation
- Error throwing documentation with examples
-
✅ Robust Test Coverage
- Expanded from 4 to 52 unit tests
- Edge case testing (negative numbers, zero handling, precision)
- Invalid input testing for all methods
- All tests passing with 100% coverage of core functionality
-
🛡️ Enhanced Input Validation
- Validates null, undefined, NaN, Infinity
- Trims whitespace from string inputs
- Better error messages with context
- Type checking for unsupported types
-
📦 Package Configuration
- Added
typesfield for TypeScript definitions - Added
filesfield to optimize package size - Only distributes necessary files (dist, README, LICENSE)
- Added
-
🔧 Code Refactoring
- Extracted
processInput()as private helper method - Extracted
formatResult()as private helper method - Cleaner, more maintainable code structure
- Better separation of concerns
- Extracted
-
📖 README Improvements
- Added error handling section with examples
- Enhanced API documentation with parameters and throws
- Added edge cases documentation
- Corrected technical inaccuracies (
.toFixed()vs.toPrecision()) - Added support section with GitHub issues link
- Updated features list with accurate descriptions
- 🐛 Subtract method: Now correctly handles
subtract(0, n)returning-ninstead of0 - 🐛 Precision documentation: Corrected claims about "2 significant digits" to "2 decimal places"
- Error Types: All methods now throw typed errors for better error handling
- Input Processing: Unified input validation across all methods
- TypeScript Support: Full type safety with exported error classes
- Zero Dependencies: Remains lightweight with no external dependencies
0.0.10 - Previous Release
- Basic arithmetic operations (multiply, add, divide, subtract)
- Precision handling up to 2 decimal places
- String and number input support
- Console warnings for invalid inputs
- Silent failure mode (returns 0 on errors)
- Console.warn for invalid inputs
- Limited edge case handling
- Wrap arithmetic operations in try-catch blocks where invalid input is possible
- Import error classes if you need to catch specific error types
- Remove any code that relied on
0being returned for invalid inputs - Update tests to expect thrown errors instead of
0returns
- ✅ Better error visibility and debugging
- ✅ More predictable behavior
- ✅ Proper TypeScript error typing
- ✅ Production-ready error handling
- ✅ Comprehensive test coverage
If you encounter issues upgrading, please:
- Check the README for updated usage examples
- Review the error handling section
- Open an issue on GitHub