aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
commit6555fb80fdd8f6a5d201efadec3189d1244830a0 (patch)
treec1aa1c5aedc634ad1ea7fad4847884d559b51290 /sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js
parent7d3640f824f46490b47bd95f1c5a16644f712068 (diff)
Izbrisala bin, obj i node-modules.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js45
1 files changed, 0 insertions, 45 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js b/sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js
deleted file mode 100644
index cca93d9b..00000000
--- a/sandbox/testAppNevena/Front/node_modules/make-fetch-happen/lib/cache/index.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const { NotCachedError } = require('./errors.js')
-const CacheEntry = require('./entry.js')
-const remote = require('../remote.js')
-
-// do whatever is necessary to get a Response and return it
-const cacheFetch = async (request, options) => {
- // try to find a cached entry that satisfies this request
- const entry = await CacheEntry.find(request, options)
- if (!entry) {
- // no cached result, if the cache mode is 'only-if-cached' that's a failure
- if (options.cache === 'only-if-cached')
- throw new NotCachedError(request.url)
-
- // otherwise, we make a request, store it and return it
- const response = await remote(request, options)
- const entry = new CacheEntry({ request, response, options })
- return entry.store('miss')
- }
-
- // we have a cached response that satisfies this request, however if the cache
- // mode is 'no-cache' then we send the revalidation request no matter what
- if (options.cache === 'no-cache')
- return entry.revalidate(request, options)
-
- // if the cached entry is not stale, or if the cache mode is 'force-cache' or
- // 'only-if-cached' we can respond with the cached entry. set the status
- // based on the result of needsRevalidation and respond
- const _needsRevalidation = entry.policy.needsRevalidation(request)
- if (options.cache === 'force-cache' ||
- options.cache === 'only-if-cached' ||
- !_needsRevalidation)
- return entry.respond(request.method, options, _needsRevalidation ? 'stale' : 'hit')
-
- // if we got here, the cache entry is stale so revalidate it
- return entry.revalidate(request, options)
-}
-
-cacheFetch.invalidate = async (request, options) => {
- if (!options.cachePath)
- return
-
- return CacheEntry.invalidate(request, options)
-}
-
-module.exports = cacheFetch