service-worker-mock
Advanced tools
Comparing version 1.6.0 to 1.7.0
20
index.js
@@ -27,6 +27,17 @@ const URL = require('dom-urls'); | ||
const makeListenersWithReset = () => { | ||
const listeners = {}; | ||
Object.defineProperty(listeners, 'reset', { | ||
enumerable: false, | ||
value: () => { | ||
self.listeners = makeListenersWithReset(); | ||
} | ||
}); | ||
return listeners; | ||
}; | ||
class ServiceWorkerGlobalScope { | ||
constructor(envOptions) { | ||
const options = defaults(envOptions); | ||
this.listeners = {}; | ||
this.listeners = makeListenersWithReset(); | ||
this.location = new URL(options.locationUrl, options.locationBase); | ||
@@ -82,2 +93,9 @@ this.skipWaiting = () => Promise.resolve(); | ||
// Allow resetting without rewriting | ||
this.resetSwEnv = () => { | ||
this.caches.reset(); | ||
this.clients.reset(); | ||
this.listeners.reset(); | ||
}; | ||
this.self = this; | ||
@@ -84,0 +102,0 @@ } |
@@ -71,4 +71,8 @@ // https://developer.mozilla.org/en-US/docs/Web/API/Cache | ||
} | ||
reset() { | ||
this.store = new Map(); | ||
} | ||
} | ||
module.exports = Cache; |
@@ -50,4 +50,8 @@ const Cache = require('./Cache'); | ||
} | ||
reset() { | ||
this.caches = {}; | ||
} | ||
} | ||
module.exports = CacheStorage; |
@@ -32,4 +32,7 @@ const Client = require('./Client'); | ||
reset() { | ||
this.clients = []; | ||
} | ||
} | ||
module.exports = Clients; |
{ | ||
"name": "service-worker-mock", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"main": "index.js", | ||
@@ -23,3 +23,6 @@ "repository": { | ||
"author": "zackargyle", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"dependencies": { | ||
"dom-urls": "^1.1.0" | ||
} | ||
} |
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
20782
539
1
+ Addeddom-urls@^1.1.0
+ Addeddom-urls@1.1.0(transitive)
+ Addedurijs@1.19.11(transitive)