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

refactor code #188

Merged
merged 1 commit into from Sep 16, 2022
Merged

refactor code #188

merged 1 commit into from Sep 16, 2022

Conversation

alphmt
Copy link
Contributor

@alphmt alphmt commented Sep 15, 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, ...)
Refactor code to have cacheable.request() instead of cacheable.createCacheableRequest()

@@ -224,7 +224,7 @@ test('cacheableRequest does not cache response if request is aborted after recei
response_.end('i');
}, 50);
});
const cacheableRequest = new CacheableRequest(request).createCacheableRequest();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaredwray @szmarczak is this now ok?

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #188 (1c0ff13) into main (01224b8) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #188   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          158       158           
  Branches        39        39           
=========================================
  Hits           158       158           
Impacted Files Coverage Δ
src/index.ts 100.00% <100.00%> (ø)

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

@jaredwray jaredwray merged commit f2d7bdc into jaredwray:main Sep 16, 2022
@szmarczak
Copy link
Contributor

Sorry for late response. This is not what I meant. I meant that the cacheableRequest should be cached and exposed as request. Meaning, this should work:

const cacheableRequest = new CacheableRequest(http.request);
const cacheReq = cacheableRequest.request('http://example.com', cb);
cacheReq.on('request', req => req.end());

I'd make request bound to the current instance, so it would be backwards compatible:

const request = new CacheableRequest(http.request).request;
const cacheReq = request('http://example.com', cb);
cacheReq.on('request', req => req.end());

Anyway, it might be too late for this change. I'm ok with the current solution.

@jaredwray
Copy link
Owner

@szmarczak - sorry for the confusion and I will look at what it would take to do that.

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.

None yet

3 participants