You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@types/ws

Package Overview
Dependencies
1
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/ws

TypeScript definitions for ws


Version published
Weekly downloads
16M
increased by4.39%
Maintainers
1
Created
Weekly downloads
 

Package description

What is @types/ws?

The @types/ws package provides TypeScript type definitions for the ws (WebSocket) library, enabling developers to use ws in TypeScript projects with type checking and IntelliSense support. It doesn't add any functionality on its own but allows for a better development experience when working with WebSockets in TypeScript.

What are @types/ws's main functionalities?

Creating a WebSocket server

This code sample demonstrates how to create a WebSocket server that listens on port 8080. It handles new connections and messages from clients, and sends a message to clients upon connection.

import * as WebSocket from 'ws';

const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
    console.log('received: %s', message);
  });

  ws.send('something');
});

Connecting to a WebSocket server

This example shows how to connect to a WebSocket server and interact with it by sending a message upon opening the connection and logging messages received from the server.

import * as WebSocket from 'ws';

const ws = new WebSocket('ws://www.host.com/path');

ws.on('open', function open() {
  ws.send('something');
});

ws.on('message', function incoming(data) {
  console.log(data);
});

Other packages similar to @types/ws

Readme

Source

Installation

npm install --save @types/ws

Summary

This package contains type definitions for ws (https://github.com/websockets/ws).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ws.

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: @types/node

Credits

These definitions were written by Paul Loyd, Margus Lamp, Philippe D'Alva, reduckted, teidesu, Bartosz Wojtkowiak, Kyle Hensel, and Samuel Skeen.

FAQs

Package last updated on 21 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc