blakejs
blakejs copied to clipboard
Add JSDoc documentation and universal exports
This commit introduces two key improvements to the Blake2B implementation:
- Comprehensive JSDoc Documentation:
- Added JSDoc comments for all functions and classes
- Documented parameters, return values, and exceptions
- Maintained all original inline comments and explanations
- Added type information for better IDE support
- Documented the Blake namespace and its methods
- Improved input parameter documentation for normalizeInput()
- Universal Export Pattern:
- Added robust environment detection for exports
- Supports CommonJS (Node.js), AMD, and browser globals
- Uses globalThis with fallbacks to window/self
- Maintains backward compatibility
- Provides cleaner consumption in all environments
The original functionality remains completely unchanged - these are improvements to documentation and module exports.
All original comments from the reference implementation have been preserved exactly as they were, including:
- RFC reference comments
- Performance optimization notes
- Debugging helper comments
- Example usage in comments
- Core algorithm explanations
The changes make the code:
- Better documented for maintainers
- More tooling-friendly (IDEs, TypeScript)
- Easier to consume in different environments
- More future-proof while maintaining compatibility