easy-server-sent-events
Advanced tools
+2
-2
| { | ||
| "name": "easy-server-sent-events", | ||
| "version": "1.0.8", | ||
| "version": "1.0.10", | ||
| "description": "An easy to use Server Side Events library for Node.js + frontend", | ||
@@ -29,2 +29,2 @@ "author": "Thomas Frank <thomas@nodehill.com>", | ||
| } | ||
| } | ||
| } |
+9
-3
@@ -5,2 +5,4 @@ export default class SSE { | ||
| this.listeners = []; | ||
| this.timeoutOnError = 200; | ||
| this.timeoutMem; | ||
| this.restart(endpoint); | ||
@@ -11,7 +13,10 @@ } | ||
| this.endPointCalc(endPoint); | ||
| if(this.longpolling){} | ||
| this.stream && this.stream.close(); | ||
| this.stream = new EventSource(this.endPoint); | ||
| this.stream.addEventListener('error', () => { | ||
| this.addListeners(); | ||
| clear(this.timeoutMem); | ||
| this.timeoutMem = setTimeout(() => this.addListeners(), this.timeoutOnError); | ||
| if (this.timeoutOnError < 10000) { | ||
| this.timeoutOnError += 1000; | ||
| } | ||
| }); | ||
@@ -34,2 +39,3 @@ } | ||
| this.stream.addEventListener(x, (event) => { | ||
| this.timeoutOnError = 200; | ||
| let data = event.data; | ||
@@ -51,3 +57,3 @@ try { data = JSON.parse(data) } catch (e) { } | ||
| endPointCalc(endPoint){ | ||
| endPointCalc(endPoint) { | ||
| this.endPoint = endPoint || this.endPoint || '/api/sse'; | ||
@@ -54,0 +60,0 @@ if (!this.endPoint.includes('browserId=')) { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
11245
2.13%143
4.38%