v10.0.0
Breaking Change with v10.0.0
This release contains breaking changes as we are now using class
to handle instances and hooks better. This is the new way to use this package.
Usage Before v10
import http from 'http';
import CacheableRequest from 'cacheable-request';
// Then instead of
const req = http.request('http://example.com', cb);
req.end();
// You can do
const cacheableRequest = new CacheableRequest(http.request);
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid
// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request);
const cacheableRequest = new CacheableRequest(electron.net);
Usage After v10
import CacheableRequest from 'cacheable-request';
// Now You can do
const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();
const cacheReq = cacheableRequest('http://example.com', cb);
cacheReq.on('request', req => req.end());
// Future requests to 'example.com' will be returned from cache if still valid
// You pass in any other http.request API compatible method to be wrapped with cache support:
const cacheableRequest = new CacheableRequest(https.request).createCacheableRequest();
const cacheableRequest = new CacheableRequest(electron.net).createCacheableRequest();
The biggest change is that when you do a new
CacheableRequest you now want to call createCacheableRequest
method will give you the instance to use.
- const cacheableRequest = new CacheableRequest(http.request);
+ const cacheableRequest = new CacheableRequest(http.request).createCacheableRequest();
What's Changed
- updating security readme on support for v8.x.x by @jaredwray in #166
- upgrading keyv to 4.4.1 by @jaredwray in #168
- upgrading ts-jest to 28.0.8 by @jaredwray in #169
- fixed hooks instance issue by @alphmth in #167
- fixed issue by @alphmth in #172
- fixed type issues by @alphmth in #173
- Issue #174 by @slwhitman in #176
- Issue 171 by @alphmth in #175
New Contributors
- @slwhitman made their first contribution in #176
Full Changelog: v9.0.0...v10.0.0