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

easy-server-sent-events

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-server-sent-events - npm Package Compare versions

Comparing version

to
1.0.10

4

package.json
{
"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>",

}
}
}

@@ -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=')) {