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

transport-layer

v0.0.2

Published

Extendable transport layer for real-time transports.

Readme

transport-layer

The transport-layer module is a base class or common layer for real-time transports. Having a shared layer makes it easier for people to create custom transports which can be used by frameworks that depend on transports with this base layer.

Please note that is module is designed to be a dependency of a transport not as transport it self.

We have some specific goals we're trying to figure out:

  • Know if a transport can be used in a cross domain/port/protocol environment
  • If the transport is supported by the by the current environment (browser/node/js-engine)
  • Know the capabilities of the transport can it write/receive data and does it support binary.
  • At what state of the environment is it save to use this transport.

Installation

This module is intended to be used on the browser using Browserify and Node.js and distributed in the public npm registry. It can be installed by running:

npm install --save transport-layer

Events

Event | Description ------------------|-------------------------------------------------- initialize | The instance has been fully initialized. url:modify | Last chance to modify the URL before it a string. url | Complete URL that we're about to request. timeline | Register a new event in our timeline. log | Debug/log message from the framework. log:<severity> | Specifically listen to certain log messages.

Implementing a transport

Before we're going to get started we going to assume that you've already required the transport-layer as following:

'use strict';

var TL = require('transport-layer');

We're just going to call it TL as it's shorter and easier to write then TransportLayer every single time. In this example we're going to implement a WebSocket based transport.

To implement your own real-time transport you need to extend the transport-layer instance. We follow the same pattern as you might have used in Backbone.js which is a special .extend function which allows you to create a class of your own which correctly inherits all properties and prototypes from the transport-layer class. The extend method requires 2 arguments:

  1. object, Properties and methods that need to be added on the prototype of your transport-layer instance.
  2. object, Properties that need to be added to the constructor of your instance. There are a few mandatory properties that need to be set in order for people to figure out if they can use your instance to communicate.
var WebRocket = TL.extend({}, {
  crossdomain: true,                    // Cross domain enabled.
  supported: 'WebSocket' in window,     // Supported in this browser.
  writable: true,                       // Transport can send data to server.
  readable: true,                       // Transport can receive data from server.
  binary: true                          // We can tranfer binary data.
});

License

MIT