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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lambdaroyal-autobahn

v1.4.2

Published

Holy javascript client/server communication over websockets (sync/async/timed/publish/subscribed/multichan) — Edit

Downloads

32

Readme

lambdaroyal-autobahn

holy javascript client/server communication over websockets (sync/async/timed/publish/subscribed/multichan)

It feels like doing ordinary XMLHttpRequest and getting back a promise that resolves or gets rejected. But under the hood you get a configurable number of websockets providing your application with much less overhead in terms of connection handshake.

Furthermore one can send-off messages using a topic and receive answers to the topics by observers to come up with a more loosely coupled application architecture.

Light-weight

  • Only 2KB gzipped
  • Small API, easy to grasp
  • no-trap in, can be used with other libs in conjunction

How to use

Install

bower install lambdaroyal-autobahn

Initialize

One websocket, no callbacks on state transitions

var autobahn = new Autobahn("ws://echo.websocket.org");

Or a bit more elaborated - four websockets, callback for global transitions changes and check for dead-ends every 500ms

var autobahn = new Autobahn("ws://echo.websocket.org", {lanes: 4, maintainanceInterval: 500, stateCallback: function(state) {
    console.log("[autobahn] transiate to state " + state);
}})

Synchronous call

autobahn.sync("foo").then(function(data) {
  console.log("received message in time: " + data);
});

Synchronous call with error forwarding

  autobahn.sync("foo")
  .then(function(data) {
    console.log("received message in time: " + data);
  })
  .catch(function(msg) {
    console.log("uups");
  });

Async publishing

to a topic named foo

autobahn.async("foo",1)

Subscribing

to all incoming messages to a topic named foo

autobahn.sub("foo", function(data) {
    console.log("received message on topic foo: " + data);
});

Shut-down

closes all open websockets

autobahn.close();

Init parameters

init parameters are provided to the new instance as a Javascript Map. The following ones are considered:

  • debug (true) log debug messages to browser console
  • syncTimeout (2000) timeout (ms) related to sync calls
  • lanes (1) number of parallel websocket to be opened, actual max. number is browser-dependend
  • reconnectInterval (1000) The number of milliseconds to delay before attempting to reconnect after a close event. */
  • maintainanceInterval (2000) The number of milliseconds between two maintainance cycles where closed sockets are dumped and new sockets are established
  • protocols ("vlic") name(s) of the protocol used to initialize individual websockets
  • syncErrorCallback gets called when sync timeout occcures, can be used to inform log servers to get some failure stats. The lease (unique string representing the request) is passed to this function
  • stateCallback gets called when the global state changes
  • exceptionCallback gets called when an uncatched exception occurs during maintenance phase or when opening a websocket that would otherwise only result in a console log. the error message is passed to the function
  • statsOnSyncResponse gets called when responses on sync comm requests are received, accepts parameters ws and delay. [ws] denotes the websocket instance the response came in, [delay] denotes time in ms since request was spawned or undefined for responses that arrived after timeout
  • syncStarts (undefined) global callback that gets invoked right before a sync call is attempted to be sent via some websocket, the function can accept the request body as parameter
  • syncStops (undefined) global callback that gets invoked right after a sync call resolves or is rejected, the function can accept success as first and the response body as second parameter

Build

get build dependencies

npm install

minify

grunt

prepare publish by login-in

npm adduser

publish new version

npm publish