npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

x-platform-ws

v0.2.1

Published

A cross-platform wrapper over ws and WebSocket

Downloads

14

Readme

x-platform-ws

The cross-platform WebSocket wrapper in Javascript, imitating the API of the ws package on browser.

Installation

First make sure you have node and npm (Comes with Node) installed, then run:

  $ npm install x-platform-ws --save

Bingo! You're made it!

Further information

If you are x-platform-ws in a project with browserify or webpack, everything will be working fine.

If not, you should add events and buffer to your dependencies. They are peer dependencies of x-platform-ws so you have to install them manually. (Webpack and browserify have them installed and automatically bundled for browsers)

Usage

  const WebSocket = require('x-platform-ws');
  const ws = new WebSocket('wss://echo.websocket.org');
  ws.on('message', data => console.log(data));
  ws.on('open', () => console.log('Opened!'));
  ws.on('close', (code, reason) => console.log(`Closed: code=${code}, reason=${reason}`));
  setTimeout(() => ws.close(), 10000);

It is almost compatible with the client in the ws package, with some noticable differences:

  • The options parameter of the WebSocket constructor is only effective on the node side.
  • The ping() and pong() methods are not supported in the browser. See this SO thread for explanations.
  • The UNIX domain sockets are not supported in the browser.
  • The 'fragment' binaryType is not supported on the browser.
  • The 'ping', 'pong', 'unexpected-response' and 'upgrade' events are not supported on the browser.
  • The send() method does not take advantage of the options and the callback is invoked immediately.

For the ws api, see the official docs.

Features

  • Support using 'nodebuffer' as binaryType with almost 100% compatibility. (Thanks to the buffer npm package)
  • Support using on(), once() and other methods of the Node EventEmitter class. (Thanks to the events npm package)

Development

First clone the repository:

  $ git clone https://github.com/std4453/x-platform-ws

Then, change to working dir:

  $ cd x-platform-ws

And:

  $ npm install

Now play with it as you like!

Versioning

We use semantic versioning for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License, see LICENSE for details.