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

chore: Add prefix in encryptStream #236

Merged
merged 2 commits into from
Oct 31, 2022
Merged

Conversation

dapplion
Copy link
Contributor

Javascript abstractions are not free. While using pipe here looks nice, it adds a non-neglible cost allocating Promises for each extra for await () iteration.

Move code to add prefix into encryptStream. I'll attempt the same for decryptStream but it's a bit more complex so prefer to split in two PRs

@dapplion dapplion requested a review from a team as a code owner October 14, 2022 15:03
@dapplion dapplion changed the title Add prefix in encryptStream chore: Add prefix in encryptStream Oct 14, 2022
@dapplion dapplion force-pushed the dapplion/encryptStreamPrefix branch from 646ef3c to b9568fd Compare October 14, 2022 15:07
@@ -12,7 +12,7 @@ const allocUnsafe = (len: number): Uint8Array => {
return new Uint8Array(len)
}

export const uint16BEEncode: LengthEncoderFunction = (value: number) => {
export const uint16BEEncode = (value: number): Uint8Array => {
Copy link
Member

Choose a reason for hiding this comment

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

why is the type changed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because LengthEncoderFunction is typed are returning either Uint8Array or Uint8Array list, requiring extra code downstream to handle both cases.

@mpetrunic
Copy link
Member

Also there are some lint issues^^

@wemeetagain wemeetagain merged commit db66eeb into master Oct 31, 2022
@wemeetagain wemeetagain deleted the dapplion/encryptStreamPrefix branch October 31, 2022 03:08
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.

3 participants