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

w3gram

v0.2.0

Published

W3gram Push Notification JavaScript Client Library

Downloads

19

Readme

W3gram Client JavaScript Library

Build Status API Documentation NPM Version

This is a W3C Push API polyfill that uses the W3gram push notification server. The library works in modern browsers and in node.js.

Prerequisites

Building the library requries node.js 0.10 or above.

The W3C Push API requires ES6 Promises. Fortunately, many polyfills are available. This library has been tested with es6-promise-polyfill in conjunction with the setImmediate polyfill that it recommends.

The code has been tested on the following platforms:

The library should work on any browser that supports the WebSocket API and Cross-Origin Resource Sharing. The list above states the platforms that the code is actively tested against.

Setup

On the server side, you must obtain a W3gram API key, generate a device ID for each user session, and compute the token (signature) for the device ID.

An easy way to get an API key is to set up your own W3gram server via the one-click Deploy to Heroku button on the W3gram Server repository README, and follow the instructions there to set up your application.

Browser Setup

Check out the library and build it.

git clone https://github.com/pwnall/w3gram-js.git w3gram.js
cd w3gram.js
npm install
npm package

The build output is lib/w3gram.js, minified as lib/w3gram.min.js, with the source map lib/w3gram.min.map.

Once your server-side code embeds the API key, device ID and token into Web pages, use the following snippet to initialize the W3gram client library.

W3gram.setupPushManager({
  "server": "https://your-w3gram-server.herokuapp.com",
  "key": "your-api-key",
  "device": "the-device-id",
  "token": "token-for-the-device-id"
});

After the setupPushManager call, the W3gram singleton implements the ServiceWorkerRegistration extensions in the W3C Push API.

W3gram.pushRegistrationManager.register().then(function (registration) {
  registration.onpush = function (event) {
    console.log("Got push notification: " + event.data);
  };
}, function (error) {
  console.log(error);
});

node.js Setup

This library does not yet have a properly designed API for node.js. Instead, it implements the W3C Push API, just like in the browser.

Add the dependency to your package.json.

"dependencies": {
  "w3gram": "0.1.2"
}

Require the library and use the Push API.

W3gram = require('w3gram');

Development Setup

Install all dependencies and create the PostgreSQL database used by the W3gram server in the test suite.

npm install
createdb w3gram_test

Run tests.

cake test
cake webtest
BROWSER=firefox cake webtest
BROWSER=safari cake webtest

License

This project is Copyright (c) 2014 Victor Costan, and distributed under the MIT License.