Thank you for your interest in contributing! This document provides guidelines for contributing to node-accelerate.
- macOS (Apple Silicon or Intel)
- Node.js >= 18.0.0
- Xcode Command Line Tools
- Git
-
Fork the repository
-
Clone your fork:
git clone https://github.com/Digital-Defiance/node-accelerate.git cd node-accelerate -
Install dependencies:
npm install
-
Build the addon:
npm run build
-
Run tests:
npm test
node-accelerate/
├── accelerate.cc # C++ implementation
├── binding.gyp # Build configuration
├── index.js # JavaScript wrapper
├── index.d.ts # TypeScript definitions
├── test.js # Test suite
├── benchmark.js # Performance benchmarks
└── README.md # Documentation
C++ Code:
- Follow Google C++ Style Guide
- Use 2-space indentation
- Add comments for complex operations
- Include error handling
JavaScript Code:
- Use 2-space indentation
- Use
constandlet, notvar - Add JSDoc comments for functions
- Follow Node.js best practices
-
Add C++ implementation in
accelerate.cc:Napi::Value YourFunction(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); // Validate arguments if (info.Length() < 1) { Napi::TypeError::New(env, "Expected 1 argument").ThrowAsJavaScriptException(); return env.Null(); } // Your implementation using Accelerate framework return result; }
-
Export the function in
Init():exports.Set("yourFunction", Napi::Function::New(env, YourFunction)); -
Add TypeScript definition in
index.d.ts:export function yourFunction(arg: Float64Array): number;
-
Add tests in
test.js:console.log('Testing your function...'); const result = accelerate.yourFunction(testData); assertClose(result, expectedValue, 1e-10, 'Your function test');
-
Update documentation in
README.md
Run the test suite:
npm testAdd tests for:
- Correct results with known inputs
- Edge cases (empty arrays, single elements)
- Large inputs (performance validation)
- Error handling (invalid arguments)
Run benchmarks:
npm run benchmarkWhen adding new functions, include benchmarks comparing:
- Pure JavaScript implementation
- Accelerate-based implementation
- Speedup factor
-
Create a branch for your feature:
git checkout -b feature/your-feature-name
-
Make your changes following the code style guidelines
-
Add tests for new functionality
-
Run tests to ensure everything works:
npm test npm run benchmark -
Commit your changes with clear messages:
git commit -m "Add feature: description" -
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request with:
- Clear description of changes
- Test results
- Benchmark results (if applicable)
- Documentation updates
- More BLAS operations: Matrix-vector multiply, triangular solve, etc.
- More vDSP operations: Convolution, correlation, windowing
- Float32 support: Add single-precision variants
- Error handling: Improve validation and error messages
- Documentation: More examples and use cases
- Performance optimizations: Reduce overhead, optimize memory usage
- Additional tests: Edge cases, stress tests
- CI/CD: GitHub Actions for automated testing
- Benchmarks: More comprehensive performance tests
- Additional platforms: Explore other ARM64 platforms
- Advanced features: Sparse matrices, complex numbers
- Utilities: Helper functions for common patterns
All submissions require review. We'll look for:
- Correctness: Does it work as intended?
- Performance: Does it maintain or improve performance?
- Tests: Are there adequate tests?
- Documentation: Is it well-documented?
- Style: Does it follow the style guide?
When reporting issues, include:
-
Environment:
- macOS version
- Node.js version
- Chip (M1/M2/M3/M4/Intel)
-
Description: Clear description of the issue
-
Reproduction: Minimal code to reproduce
-
Expected vs Actual: What you expected vs what happened
-
Logs: Any error messages or logs
- Open an issue for questions
- Check existing issues first
- Be respectful and constructive
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to node-accelerate! Your efforts help make high-performance numerical computing accessible to the Node.js community.