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 🙏

© 2026 – Pkg Stats / Ryan Hefner

websocketification-client

v0.8.7

Published

Websocketification client.

Readme

Websocketification Client

Websocketification Client in the fetch way with the help of WebpackJs.

TODO

  • [ ] Add Tests.
  • [ ] Update Docs.
  • [ ] Connection Retry.
  • [ ] Connection retry max time.
  • [x] Compile es6 to es5.
  • [ ] Separate project.

Installation

npm install --save websocketification-client

Browser-Side Usage

Integrate websocketification-client in the following way and pack it with WebpackJs before execute it in the browser.

const WebsocketificationClient = require('websocketification-client');
const client = new WebsocketificationClient('ws://127.0.0.1:3123/');
client.connect();
const fetch = client.fetch;

let options = {
	method: 'POST',
	credentials: 'include',
	headers: {'Content-Type': 'application/json'},
	body: {name: 'Tom'}
};

return fetch('/users', options).then(
	response => response.json()
).then(response => {
	console.log('Got users: ', response);
}).catch(error => {
	console.error('Failed to get users: ', error);
});

/**
 * Add on broadcast listener.
 */
client.setOnBroadcastListener('app.messages', (error, message) => {
	if (error) {return console.error(error);}
	console.log(message);
});

Server/NodeJs Side Usage

To run in the server, use ws as the global.WebSocket Object.

@see ./examples/get-started.js.

if ('undefined' === typeof(window) && !global.WebSocket) {
	global.WebSocket = require('ws');
}

// ...

First

  1. CONNECTING
    • Wait for connection.
  2. OPEN
    • Send Request
  3. CLOSING
  4. CLOSED
    • If first time return error.
    • If not first time reconnect immediately.

Heartbeat Package Policy

  • Send heartbeat every 50 seconds.
  • Heartbeat will be @${beat-times} string.

Connection Retry and Reconnection Policy

When the connection between the client and server breaks, the client will:

  1. try to reconnect after 5 seconds.
    • reconnect immediately if any request is about to send.
  2. wait for 10 seconds and reconnect, if last step failed.
  3. wait for 20 seconds and reconnect, if last step failed.
  4. wait for 40 seconds and reconnect, if last step failed.
  5. wait for 80 seconds and reconnect, if last step failed.

Disconnect Timer

Reasons WebSocket Connection Breaks

  • Client disconnects.
  • Connection times out.
  • Client physically disconnects, no Internet, weak signal.
  • Server goes down temporarily.
  • Server goes down permanently.

References

  • WebSocket Protocol: https://tools.ietf.org/html/rfc6455
  • WebScoket API: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
  • Close Event: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
  • https://developer.mozilla.org/en-US/docs/Web/API/Response