@internetarchive/browser-response-cache
Advanced tools
Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2
@@ -53,3 +53,3 @@ /** | ||
private cacheCleaningIntervalStorage?; | ||
constructor(options: { | ||
constructor(options?: { | ||
defaultCacheTTL?: CacheTTL; | ||
@@ -56,0 +56,0 @@ cacheName?: string; |
@@ -8,10 +8,10 @@ import { IndexedDBCacheExpirationStorage } from './indexeddb-cache-expiration-storage'; | ||
this.DEFAULT_CACHE_MAINTENANCE_INTERVAL = 1000 * 60 * 5; | ||
this.defaultCacheTTL = (_a = options.defaultCacheTTL) !== null && _a !== void 0 ? _a : this.DEFAULT_CACHE_TTL; | ||
this.cacheName = (_b = options.cacheName) !== null && _b !== void 0 ? _b : this.DEFAULT_CACHE_NAME; | ||
this.defaultCacheTTL = (_a = options === null || options === void 0 ? void 0 : options.defaultCacheTTL) !== null && _a !== void 0 ? _a : this.DEFAULT_CACHE_TTL; | ||
this.cacheName = (_b = options === null || options === void 0 ? void 0 : options.cacheName) !== null && _b !== void 0 ? _b : this.DEFAULT_CACHE_NAME; | ||
this.cacheExpirationStorage = | ||
(_c = options.cacheExpirationHandler) !== null && _c !== void 0 ? _c : new IndexedDBCacheExpirationStorage(); | ||
(_c = options === null || options === void 0 ? void 0 : options.cacheExpirationHandler) !== null && _c !== void 0 ? _c : new IndexedDBCacheExpirationStorage(); | ||
// cacheStorage can either be passed in or if using in a browser, | ||
// use `window.caches`, or in a WebWorker, use `self.caches` | ||
this.cacheStorage = | ||
(_d = options.cacheStorage) !== null && _d !== void 0 ? _d : ('caches' in window | ||
(_d = options === null || options === void 0 ? void 0 : options.cacheStorage) !== null && _d !== void 0 ? _d : ('caches' in window | ||
? window.caches | ||
@@ -21,3 +21,3 @@ : 'caches' in self | ||
: undefined); | ||
const cacheMaintenanceInterval = (_e = options.cacheMaintenanceInterval) !== null && _e !== void 0 ? _e : this.DEFAULT_CACHE_MAINTENANCE_INTERVAL; | ||
const cacheMaintenanceInterval = (_e = options === null || options === void 0 ? void 0 : options.cacheMaintenanceInterval) !== null && _e !== void 0 ? _e : this.DEFAULT_CACHE_MAINTENANCE_INTERVAL; | ||
this.doCacheMaintenance(); | ||
@@ -24,0 +24,0 @@ this.cacheCleaningIntervalStorage = setInterval(this.doCacheMaintenance.bind(this), cacheMaintenanceInterval); |
{ | ||
"name": "@internetarchive/browser-response-cache", | ||
"version": "0.0.1-alpha.1", | ||
"version": "0.0.1-alpha.2", | ||
"description": "A browser response cache manager.", | ||
@@ -5,0 +5,0 @@ "author": "browser-response-cache", |
@@ -66,3 +66,3 @@ import { IndexedDBCacheExpirationStorage } from './indexeddb-cache-expiration-storage'; | ||
constructor(options: { | ||
constructor(options?: { | ||
defaultCacheTTL?: CacheTTL; | ||
@@ -74,6 +74,6 @@ cacheName?: string; | ||
}) { | ||
this.defaultCacheTTL = options.defaultCacheTTL ?? this.DEFAULT_CACHE_TTL; | ||
this.cacheName = options.cacheName ?? this.DEFAULT_CACHE_NAME; | ||
this.defaultCacheTTL = options?.defaultCacheTTL ?? this.DEFAULT_CACHE_TTL; | ||
this.cacheName = options?.cacheName ?? this.DEFAULT_CACHE_NAME; | ||
this.cacheExpirationStorage = | ||
options.cacheExpirationHandler ?? new IndexedDBCacheExpirationStorage(); | ||
options?.cacheExpirationHandler ?? new IndexedDBCacheExpirationStorage(); | ||
@@ -83,3 +83,3 @@ // cacheStorage can either be passed in or if using in a browser, | ||
this.cacheStorage = | ||
options.cacheStorage ?? | ||
options?.cacheStorage ?? | ||
('caches' in window | ||
@@ -92,3 +92,3 @@ ? window.caches | ||
const cacheMaintenanceInterval = | ||
options.cacheMaintenanceInterval ?? | ||
options?.cacheMaintenanceInterval ?? | ||
this.DEFAULT_CACHE_MAINTENANCE_INTERVAL; | ||
@@ -95,0 +95,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115645