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

@types/eventsource

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/eventsource

TypeScript definitions for eventsource

  • 1.1.15
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @types/eventsource?

@types/eventsource provides TypeScript definitions for the EventSource API, which is used for receiving server-sent events (SSE). This package allows TypeScript developers to use the EventSource API with type safety and autocompletion in their projects.

What are @types/eventsource's main functionalities?

Creating an EventSource instance

This feature allows you to create a new EventSource instance to listen for server-sent events from a specified URL.

const eventSource = new EventSource('https://example.com/events');

Listening for messages

This feature allows you to set up an event listener for incoming messages from the server. The event handler receives an event object containing the data sent by the server.

eventSource.onmessage = (event) => { console.log(event.data); };

Handling errors

This feature allows you to handle errors that occur while receiving events. The event handler receives an event object that can be used to log or handle the error.

eventSource.onerror = (event) => { console.error('Error:', event); };

Closing the connection

This feature allows you to close the EventSource connection when it is no longer needed, freeing up resources.

eventSource.close();

Other packages similar to @types/eventsource

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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