New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

browsermon

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browsermon - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

4

browser.js

@@ -26,2 +26,6 @@ const URL = "ws://" + location.host + "/browsermon";

};
ws.addEventListener("message", (event) => {
if (event.data === "reload") window.location.reload();
});
}
import http = require("http");
export default function browsermon({ server }: { server: http.Server }): void;
export default function browsermon({
server,
filename,
}: {
server: http.Server;
filename?: string;
}): void;

13

index.js

@@ -5,2 +5,3 @@ const http = require("http");

const WebSocket = require("ws");
const watch = require("node-watch");

@@ -11,7 +12,13 @@ const browserJsContents = fs.readFileSync(path.join(__dirname, "browser.js"));

wss.on("connection", (ws) => {
wss.on("connection", (ws, filename) => {
// client got connected ...
// when a file got updated notify the browser
if (filename) {
watch(filename, { recursive: true }, () => {
ws.send("reload");
});
}
});
function browsermon({ server }) {
function browsermon({ server, filename }) {
if (process.env.NODE_ENV === "production") {

@@ -37,3 +44,3 @@ // do nothing in production ...

wss.handleUpgrade(req, socket, head, (ws, req) => {
wss.emit("connection", ws, req);
wss.emit("connection", ws, filename);
});

@@ -40,0 +47,0 @@ }

{
"name": "browsermon",
"version": "1.0.1",
"version": "1.0.2",
"description": "Automatically reload browser when nodemon restarts http server during development",

@@ -27,4 +27,5 @@ "main": "./index.js",

"dependencies": {
"node-watch": "^0.7.1",
"ws": "^7.5.0"
}
}
}
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