Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cacheable-request

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable-request - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

3

package.json
{
"name": "cacheable-request",
"version": "0.1.0",
"version": "0.2.0",
"description": "Wrap native HTTP requests with RFC compliant cache support",

@@ -36,2 +36,3 @@ "main": "src/index.js",

"dependencies": {
"clone-response": "^0.2.2",
"get-stream": "^3.0.0",

@@ -38,0 +39,0 @@ "http-cache-semantics": "^3.7.3",

@@ -11,2 +11,3 @@ 'use strict';

const lowercaseKeys = require('lowercase-keys');
const cloneResponse = require('clone-response');

@@ -37,3 +38,3 @@ const cacheKey = opts => {

const headers = revalidatedPolicy.policy.responseHeaders();
response = new Response(opts._revalidate.statusCode, headers, opts._revalidate.body, opts._revalidate.url);
response = new Response(response.statusCode, headers, opts._revalidate.body, opts._revalidate.url);
response.cachePolicy = revalidatedPolicy.policy;

@@ -49,3 +50,5 @@ response.fromCache = true;

let clonedResponse;
if (cache && response.cachePolicy.storable()) {
clonedResponse = cloneResponse(response);
getStream.buffer(response).then(body => {

@@ -55,3 +58,3 @@ const value = {

url: response.url,
statusCode: response.statusCode,
statusCode: response.fromCache ? opts._revalidate.statusCode : response.statusCode,
body

@@ -62,6 +65,8 @@ };

});
} else if (opts._revalidate) {
opts.cache.delete(key);
}
if (typeof cb === 'function') {
cb(response);
cb(clonedResponse || response);
}

@@ -68,0 +73,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc