eventsource
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
EventSource is an npm package that provides a pure JavaScript implementation of the EventSource client. It is W3C compliant and allows developers to use it with Node.js or as a browser polyfill for browsers that lack native EventSource support. Its purpose is to facilitate Server-Sent Events (SSE), which allow updates to be pushed from servers to clients.
To use EventSource, first, install it using the npm package manager with the command: npm install eventsource
. Once installed, you can utilize it in your code. For example, if you're setting HTTP request headers, you can do this:
var eventSourceInitDict = {headers: {'Cookie': 'test=test'}};
var es = new EventSource(url, eventSourceInitDict);
Or, for letting unauthorized HTTPS requests:
var eventSourceInitDict = {https: {rejectUnauthorized: false}};
var es = new EventSource(url, eventSourceInitDict);
HTTP/HTTPS proxies can also be defined:
var es = new EventSource(url, {proxy: 'http://your.proxy.com'});
Additionally, there are examples included in the repository that can be started with Node and accessed via your browser at http://localhost:8080 for further usage comprehension.
The primary documentation for the EventSource package is available within its GitHub repository: https://github.com/EventSource/eventsource. Here, you will find everything from installation instructions to examples of usage and API information. The API aims to be W3C compatible and the package is a JavaScript implementation of the client described on the EventSource page of the WHATWG HTML Living Standard, which can serve as supplementary documentation.