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

Compression Updates #502

Merged
merged 6 commits into from
Oct 1, 2022
Merged

Compression Updates #502

merged 6 commits into from
Oct 1, 2022

Conversation

jaredwray
Copy link
Owner

@jaredwray jaredwray commented Sep 27, 2022

Please check if the PR fulfills these requirements

  • Followed the Contributing guidelines.
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
The goal with this is to update the main Keyv to handle compression in a more scalable manner and not do a ton of overwrites.

  • standardize the compression library with compress(value, options) and decompress(value, options)
  • document a better structure for testing with the main Keyv library
  • Remove anything unnecessary that was implemented
  • Remove compress as it is no longer needed.

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (bd879a6) compared to base (c877fb0).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #502   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines          319       319           
=========================================
  Hits           319       319           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jaredwray jaredwray changed the title removing types as it is no longer needed Compression Updates Sep 29, 2022
@@ -19,12 +19,12 @@ class KeyvBrotli {
};
}

compress(value, options) {
return this.opts.compress(value, options);
compress(value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@jaredwray we need this options argument in compress or decompress methods as brotli and gzip also have those options filed.

https://github.com/Kikobeats/compress-brotli/blob/master/src/index.js#L29
https://github.com/nodeca/pako/blob/master/lib/inflate.js#L101

Copy link
Owner Author

@jaredwray jaredwray Sep 30, 2022

Choose a reason for hiding this comment

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

@alphmth - the goal is that you would pass the options via the constructor for this compression option.

in the constructor we go with

	constructor(options) {
		this.opts = options;
		this.compressBrotli = compressBrotli(options);
	}

then we are able to use that for each of the calls.

	async decompress(value) {
		const {value, expires} = this.compressBrotli.deserialize(data);
		return {value: await this.compressBrotli.decompress(value), expires};
	}

@jaredwray jaredwray merged commit 021c9b0 into main Oct 1, 2022
jaredwray added a commit that referenced this pull request Oct 1, 2022
jaredwray added a commit that referenced this pull request Oct 1, 2022
@jaredwray jaredwray deleted the compression-updates-v2 branch October 17, 2022 14:48
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.

2 participants