Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

service-worker-mock

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

service-worker-mock - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

65

index.js

@@ -9,37 +9,46 @@ const url = require('url');

module.exports = function makeServiceWorkerEnv() {
const env = {
listeners: {},
location: { origin: '/' },
skipWaiting: () => Promise.resolve(),
caches: new CacheStorage(),
clients: new Clients(),
registration: new ServiceWorkerRegistration(),
addEventListener: function (name, callback) {
if (!env.listeners[name]) {
env.listeners[name] = [];
class ServiceWorkerGlobalScope {
constructor() {
this.listeners = {};
this.location = { origin: '/' };
this.skipWaiting = () => Promise.resolve();
this.caches = new CacheStorage();
this.clients = new Clients();
this.registration = new ServiceWorkerRegistration();
this.Request = Request;
this.Response = Response;
this.URL = url.URL || url.parse;
this.ServiceWorkerGlobalScope = ServiceWorkerGlobalScope;
// Instance variable to avoid issues with `this`
this.addEventListener = (name, callback) => {
if (!this.listeners[name]) {
this.listeners[name] = [];
}
env.listeners[name].push(callback);
},
trigger: function (name, args) {
if (env.listeners[name]) {
return handleEvents(name, args, env.listeners[name]);
this.listeners[name].push(callback);
};
// Instance variable to avoid issues with `this`
this.trigger = (name, args) => {
if (this.listeners[name]) {
return handleEvents(name, args, this.listeners[name]);
}
return Promise.resolve();
},
snapshot: function () {
};
// Instance variable to avoid issues with `this`
this.snapshot = () => {
return {
caches: env.caches.snapshot(),
clients: env.clients.snapshot(),
notifications: env.registration.snapshot()
caches: this.caches.snapshot(),
clients: this.clients.snapshot(),
notifications: this.registration.snapshot()
};
},
Request: Request,
Response: Response,
URL: url.URL || url.parse
};
};
env.self = env;
this.self = this;
}
}
return env;
module.exports = function makeServiceWorkerEnv() {
return new ServiceWorkerGlobalScope();
};
{
"name": "service-worker-mock",
"version": "1.2.4",
"version": "1.3.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc