Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify toHexString logic #14

Closed
wants to merge 1 commit into from
Closed

Conversation

DemoYeti
Copy link

Using reduce is more efficient than map + join

Copy link
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 92.85% (🎯 50%) 13 / 14
🟢 Statements 93.33% (🎯 50%) 14 / 15
🟢 Functions 100% (🎯 50%) 5 / 5
🟢 Branches 75% (🎯 50%) 3 / 4
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/utils/index.ts 100% 100% 100% 100%
Generated in workflow #37 for commit 9cadd28 by the Vitest Coverage Report Action

Comment on lines +2 to +3
return Array.from(byteArray)
.reduce((hex, byte) => hex + ((byte & 0xff).toString(16).padStart(2, '0')), '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [eslint] <prettier/prettier> reported by reviewdog 🐶
Replace ⏎····.reduce((hex,·byte)·=>·hex·+·((byte·&·0xff).toString(16).padStart(2,·'0')),·'' with .reduce((hex,·byte)·=>·hex·+·(byte·&·0xff).toString(16).padStart(2,·"0"),·""

Suggested change
return Array.from(byteArray)
.reduce((hex, byte) => hex + ((byte & 0xff).toString(16).padStart(2, '0')), '');
return Array.from(byteArray).reduce((hex, byte) => hex + (byte & 0xff).toString(16).padStart(2, "0"), "");

@DemoYeti DemoYeti closed this Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant