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

websocketstream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocketstream

a Stream interface on top of WebSocket

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

WebSocketStream provides a Node.js stream interface on top of WebSocket that works on Node.js and in the browser.

Installation

You can install the library with npm for use with Node.js:

npm install websocketstream

or with Bower for use in the browser:

bower install WebSocketStream

Node.js Example

'use strict';

var WebSocket = require('ws'),
  webSocketServer = new WebSocket.Server({port: 8080}),
  WebSocketStream = require('websocketstream');
  
webSocketServer.on('connection', function (webSocket) {
  var stream = new WebSocketStream(webSocket);
      
  stream.on('readable', function () {
    console.log("Something just came in over the wire: " + stream.read());
  });
        
  stream.write("There's a place I know just east of here.");
});

Browser Example

'use strict';

require.config({
  map: {
    '*': {
      'stream': 'Node-in-browser/lib/stream',
      'util': 'Node-in-browser/lib/util'
    }
  }
});

require(['WebSocketStream/lib/main'], function (WebSocketStream) {
  var webSocket = new WebSocket('ws://' + location.host),
    stream = new WebSocketStream(webSocket);
  
  stream.on('readable', function () {
    console.log("Something just came in over the wire: " + stream.read());
  });
        
  stream.write("There's a place I know just east of here.");  
});

Copyright 2013 David Braun

This file is part of WebSocketStream.

WebSocketStream is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

WebSocketStream is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with WebSocketStream. If not, see http://www.gnu.org/licenses/.

Keywords

FAQs

Package last updated on 09 Mar 2014

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