amp-toolbox-cache-list
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -19,3 +19,3 @@ /** | ||
const {OneBehindFetch} = require('amp-toolbox-core'); | ||
const {oneBehindFetch} = require('amp-toolbox-core'); | ||
const CACHE_LIST_ENDPOINT = 'https://cdn.ampproject.org/caches.json'; | ||
@@ -31,7 +31,6 @@ | ||
* | ||
* @param {Object} [fetchStrategy = OneBehindFetch] The fetch strategy to be used when fetching | ||
* data from the caches endpoint. Defaults to OneBehindFetch. | ||
* @param {Function} fetch - a fetch implementation | ||
*/ | ||
constructor(fetchStrategy = OneBehindFetch.create()) { | ||
this.fetchStrategy_ = fetchStrategy; | ||
constructor(fetch=oneBehindFetch) { | ||
this.fetch_ = fetch; | ||
} | ||
@@ -55,10 +54,11 @@ | ||
*/ | ||
get(cacheId) { | ||
return this.list() | ||
.then((caches) => caches.find((cache) => cache.id === cacheId)); | ||
async get(cacheId) { | ||
const caches = await this.list(); | ||
return caches.find((cache) => cache.id === cacheId); | ||
} | ||
getCaches_() { | ||
return this.fetchStrategy_.get(CACHE_LIST_ENDPOINT) | ||
.then((json) => json.caches); | ||
async getCaches_() { | ||
const response = await this.fetch_(CACHE_LIST_ENDPOINT); | ||
const data = await response.json(); | ||
return data.caches; | ||
} | ||
@@ -65,0 +65,0 @@ } |
{ | ||
"name": "amp-toolbox-cache-list", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Lists AMP Caches", | ||
@@ -15,2 +15,6 @@ "main": "index.js", | ||
], | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
], | ||
"author": "AMPHTML Team", | ||
@@ -23,5 +27,5 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"amp-toolbox-core": "^0.1.5" | ||
"amp-toolbox-core": "^0.1.6" | ||
}, | ||
"gitHead": "0f15452c5a91d97bb54194b70bff3dcaf9f56d0e" | ||
"gitHead": "058a60702136ac24dfd0a4f421877ed23aeee19f" | ||
} |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
3883
4
77
1
Updatedamp-toolbox-core@^0.1.6