CloseEventInit

interface

interface CloseEventInit extends EventInit

Configuration options for a WebSocket "close" event.

Example

// Creating a custom close event with specific parameters
const closeEventInit: CloseEventInit = {
  code: 1000,
  reason: "Normal closure",
  wasClean: true,
};
const event = new CloseEvent("close", closeEventInit);

See also

Properties

code

code?: number

reason

reason?: string

wasClean

wasClean?: boolean