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

feat(encoding/unstable): add options argument to hex streaming & performance #6453

Merged
merged 33 commits into from
Mar 21, 2025

Conversation

BlackAsLight
Copy link
Contributor

Jumping from: #6442

Pulling the unstable hex content out into a separate pull request

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
- Bring performance to stable packages
- Change how the Raw encoders and decoders work to encode inline in an existing buffer
- Merged Base32, Base32Hex, and Base32Crockford into one file.
- Merged Base64, and Base64Url into one file.
- Added Tests for 100% coverage.
- Added JSDocs

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 92.85714% with 3 lines in your changes missing coverage. Please review.

Project coverage is 95.32%. Comparing base (85d136a) to head (64d9a76).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
encoding/unstable_hex_stream.ts 92.85% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6453   +/-   ##
=======================================
  Coverage   95.32%   95.32%           
=======================================
  Files         577      576    -1     
  Lines       43417    43430   +13     
  Branches     6485     6487    +2     
=======================================
+ Hits        41386    41400   +14     
+ Misses       1992     1991    -1     
  Partials       39       39           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BlackAsLight BlackAsLight changed the title BREAKING(encoding) add code consistency and performance for unstable hex BREAKING(encoding): add code consistency and performance for unstable hex Feb 27, 2025
@BlackAsLight BlackAsLight marked this pull request as draft March 3, 2025 01:31

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@BlackAsLight BlackAsLight changed the title BREAKING(encoding): add code consistency and performance for unstable hex feat(encoding/unstable): add options argument to hex streaming & performance Mar 20, 2025
@BlackAsLight BlackAsLight marked this pull request as ready for review March 20, 2025 04:56

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
import type { Uint8Array_ } from "./_types.ts";
export type { Uint8Array_ };
import {
calcMax,
Copy link
Member

Choose a reason for hiding this comment

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

I missed this in #6480, but I don't think calcMax should be a part of public API. What do you think?

Copy link
Contributor Author

@BlackAsLight BlackAsLight Mar 21, 2025

Choose a reason for hiding this comment

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

It's a utility function for the raw encode functions. Without it people would need to be familiar with the ratio between the different bases.

The name though could be better. Essentially you'd use it to calculate the minimum size your buffer needs to be when passing it to encodeRawBase64

Comment on lines +76 to +77
const decoder = new TextDecoder();
return (x) => decoder.decode(x) as Expect<T>;
Copy link
Member

Choose a reason for hiding this comment

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

We can save some memory allocation by moving const decoder = new TextDecoder(); outside of decode arrow function.

Also I think we need to pass stream: true option to decoder.decode call to allow partial data passed to it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With moving decoder out to the top level scope, I think it would be better done in a separate pull request since this is the last one of the lot for streaming.

With the stream option, we're only sending it acsii bytes so there won't be any partial data.

Copy link
Member

Choose a reason for hiding this comment

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

With moving decoder out to the top level scope, I think it would be better done in a separate pull request since this is the last one of the lot for streaming.

Fair enough

With the stream option, we're only sending it acsii bytes so there won't be any partial data.

Ok. Thanks for the clarification

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@kt3k kt3k merged commit 48fae8f into denoland:main Mar 21, 2025
18 checks passed
@BlackAsLight BlackAsLight deleted the encoding_hex_refactor branch March 21, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants