New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

api-cache-box

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-cache-box - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

lib/main.d.ts
import { ApiCacheBoxParams, ApiCacheBoxCache } from "./ApiCacheBox";
export declare const bustApiCacheObject: () => {};
export declare function apiCacheBox({ url, apiFn, successCallback, failureCallback, }: ApiCacheBoxParams): Promise<ApiCacheBoxCache>;
export declare function apiCacheBox({ url, successCallback, failureCallback, apiFn, }: ApiCacheBoxParams): Promise<ApiCacheBoxCache>;

@@ -43,5 +43,5 @@ "use strict";

function apiCacheBox(_a) {
var url = _a.url, apiFn = _a.apiFn, successCallback = _a.successCallback, failureCallback = _a.failureCallback;
var url = _a.url, successCallback = _a.successCallback, failureCallback = _a.failureCallback, apiFn = _a.apiFn;
return __awaiter(this, void 0, void 0, function () {
var cacheKey, res, error_1;
var cacheKey, json, res, error_1;
return __generator(this, function (_b) {

@@ -53,15 +53,26 @@ switch (_b.label) {

case 1:
_b.trys.push([1, 3, 4, 5]);
return [4 /*yield*/, apiFn(url)];
_b.trys.push([1, 7, 8, 9]);
json = void 0;
if (!!apiFn) return [3 /*break*/, 4];
return [4 /*yield*/, fetch(url)];
case 2:
res = _b.sent();
___apiCacheObject[cacheKey] = res;
successCallback(res);
return [3 /*break*/, 5];
return [4 /*yield*/, res.json()];
case 3:
json = _b.sent();
return [3 /*break*/, 6];
case 4: return [4 /*yield*/, apiFn(url)];
case 5:
json = _b.sent();
_b.label = 6;
case 6:
___apiCacheObject[cacheKey] = json;
successCallback(json);
return [3 /*break*/, 9];
case 7:
error_1 = _b.sent();
failureCallback(error_1);
return [3 /*break*/, 5];
case 4: return [2 /*return*/, ___apiCacheObject];
case 5: return [2 /*return*/];
return [3 /*break*/, 9];
case 8: return [2 /*return*/, ___apiCacheObject];
case 9: return [2 /*return*/];
}

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

{
"name": "api-cache-box",
"version": "1.0.0",
"version": "1.0.1",
"description": "Calls api and caches response",

@@ -53,7 +53,9 @@ "keywords": [

"jest": "^26.0.1",
"jest-fetch-mock": "^3.0.3",
"lint-staged": "^10.2.2",
"prettier": "^2.0.5",
"sort-package-json": "^1.42.2"
"sort-package-json": "^1.42.2",
"typescript": "^3.9.2"
},
"prepublish": "tsc"
}
### API Cache Box
[![Build Status](https://travis-ci.com/dankreiger/api-cache-box.svg?branch=master)](https://travis-ci.com/dankreiger/api-cache-box)
```sh
$ npm install api-cache-box
```
```
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