node-fetch-cache
Advanced tools
+7
-3
@@ -336,2 +336,9 @@ 'use strict'; | ||
| const ejectSelfFromCache = async () => fetchCustomization.cache.remove(cacheKey); | ||
| const cachedValue = await fetchCustomization.cache.get(cacheKey); | ||
| if (cachedValue) { | ||
| return new NFCResponse(cachedValue.bodyStream, cachedValue.metaData, ejectSelfFromCache, true); | ||
| } | ||
| if (hasOnlyIfCachedOption(resource, init)) { | ||
| return NFCResponse.cacheMissResponse(getUrlFromRequestArguments(resource)); | ||
| } | ||
| return locko.doWithLock(cacheKey, async () => { | ||
@@ -342,5 +349,2 @@ const cachedValue = await fetchCustomization.cache.get(cacheKey); | ||
| } | ||
| if (hasOnlyIfCachedOption(resource, init)) { | ||
| return NFCResponse.cacheMissResponse(getUrlFromRequestArguments(resource)); | ||
| } | ||
| const fetchResponse = await fetch(resource, init); | ||
@@ -347,0 +351,0 @@ const serializedMeta = NFCResponse.serializeMetaFromNodeFetchResponse(fetchResponse); |
+7
-3
@@ -22,2 +22,9 @@ import fetch, { Request as NodeFetchRequest } from 'node-fetch'; | ||
| const ejectSelfFromCache = async () => fetchCustomization.cache.remove(cacheKey); | ||
| const cachedValue = await fetchCustomization.cache.get(cacheKey); | ||
| if (cachedValue) { | ||
| return new NFCResponse(cachedValue.bodyStream, cachedValue.metaData, ejectSelfFromCache, true); | ||
| } | ||
| if (hasOnlyIfCachedOption(resource, init)) { | ||
| return NFCResponse.cacheMissResponse(getUrlFromRequestArguments(resource)); | ||
| } | ||
| return locko.doWithLock(cacheKey, async () => { | ||
@@ -28,5 +35,2 @@ const cachedValue = await fetchCustomization.cache.get(cacheKey); | ||
| } | ||
| if (hasOnlyIfCachedOption(resource, init)) { | ||
| return NFCResponse.cacheMissResponse(getUrlFromRequestArguments(resource)); | ||
| } | ||
| const fetchResponse = await fetch(resource, init); | ||
@@ -33,0 +37,0 @@ const serializedMeta = NFCResponse.serializeMetaFromNodeFetchResponse(fetchResponse); |
+1
-1
| { | ||
| "name": "node-fetch-cache", | ||
| "version": "4.0.8", | ||
| "version": "4.0.9", | ||
| "description": "node-fetch with caching.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
56367
0.68%953
0.85%