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

got-cached

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got-cached - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

history.md

24

build/index.js

@@ -18,10 +18,11 @@ 'use strict';

function gotCached(options) {
if (!options.cache) throw Error('cache is a required option');
var cache = options.cache;
function gotCached(config) {
if (!config.cache) throw Error('cache is a required option');
var cache = config.cache;
function setCache(key, response) {
function setCache(key, response, options) {
var promise = response.then(function (response) {
cache.set(key, response.body);
var value = options.json ? JSON.stringify(response.body) : response.body;
cache.set(key, value);

@@ -34,5 +35,6 @@ return Promise.resolve(response);

function getCache(key) {
function getCache(key, options) {
var promise = cache.get(key).then(function (value) {
if (!value) return null;
if (options.json) value = JSON.parse(value);

@@ -56,3 +58,3 @@ return Promise.resolve({

var cachedResponse = getCache(url).then(function (cached) {
var cachedResponse = getCache(url, options).then(function (cached) {
// return the cached result if it exist

@@ -62,3 +64,3 @@ if (cached) return cached;

// return got response but first set cache with it
return setCache(url, (0, _got2.default)(url, options));
return setCache(url, (0, _got2.default)(url, options), options);
});

@@ -69,7 +71,3 @@

for (var prop in _got2.default) {
cachedGot[prop] = _got2.default[prop];
}
return cachedGot;
return Object.assign(cachedGot, _got2.default);
}
{
"name": "got-cached",
"version": "1.0.2",
"version": "1.1.0",
"description": "Got response cache for get requests",

@@ -18,3 +18,4 @@ "author": "janneh",

"build": "babel -d ./build index.js",
"prepublish": "npm run build"
"prepublish": "npm run build",
"postpublish": "rm -r ./build"
},

@@ -21,0 +22,0 @@ "dependencies": {

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