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

quickbus

v0.0.0

Published

A lightweight promise-based RPC wrapper for `postMessage`-style communication (ServiceWorker, iframe, cross-domain).

Downloads

993

Readme

quickbus

A lightweight promise-based RPC wrapper for postMessage-style communication (ServiceWorker, iframe, cross-domain).

Installation

npm install quickbus

Importing

// ES Modules
import { Client, Server } from 'quickbus';
// CommonJS
const { Client, Server } = require('quickbus');

Architecture

quickbus implements a simple server/client protocol.

A server exposes a set of methods that can be called by the client. It can run in a tab, iframe, or worker/serviceworker.

ServiceWorker Messaging

In your ServiceWorker (the "server" side)

Spawn a quickbus server within an iframe to expose methods to pages.

import { Server } from 'quickbus';

const qbServer = new Server({
  sayHello(to) {
    return `Hello, ${to}!`;
  }
});

globalThis.addEventListener('message', event => {
  qbServer.handleMessageEvent(event);
});

In your page (the "client" side)

Spawn a quickbus client and call your method, and await the result.

Pass navigator.serviceWorker.controller to select the service worker as the recipient of the client's requests.

import { Client } from 'quickbus';

async function callRemoteMethod() {
  const qbClient = new Client(navigator.serviceWorker.controller);
  const greeting = await qbClient.sayHello('World');
  console.log(greeting); // Hello, World!
}

callRemoteMethod();

iFrames

In your iFrame (the "server" side)

Spawn a quickbus server within an iframe to expose methods to the outer page. This can also be done vice versa.

If you plan to communicate across different origins, supply the target origin as the second parameter.

import { Server } from 'quickbus';

const handler = {
  sayHello: (to) => {
    return `Hello, ${to}!`;
  }
};

const qbServer = new Server(handler, 'https://example.com');

globalThis.addEventListener('message', event => {
  qbServer.handleMessageEvent(event);
});

In your page (the "client" side)

Spawn a quickbus client and call your method, and await the result.

Pass the iframe as the first parameter to select it as the recipient of the client's requests.

You'll also need to pass its origin as the second parameter if you plan to make cross-domain calls.

import { Client } from 'quickbus';

const iframe = document.querySelector('iframe');
const frameOrigin = 'https://child.example.com';
const qbClient = new Client(iframe.contentWindow, frameOrigin);

async function callRemoteMethod() {
  const greeting = await qbClient.sayHello('World');
  console.log(greeting); // Hello, World!
}

callRemoteMethod();

API Reference

Client(recipient, origin?)

  • recipient: A Window-like object (e.g. WindowClient or Window) with .postMessage(...).
  • origin: Optional second argument passed as targetOrigin for postMessage; defaults to * (same-origin).

Returns a Proxy: any method call (bus.foo(arg1, arg2)) sends { action: 'foo', params: [arg1, arg2], token } and returns a Promise resolving to the remote result.

Server(handler, origins?)

  • handler: An object whose methods (sync or async) implement your RPC endpoints.
  • origins: Optional array of acceptable targetOrigins for responses; defaults to same-origin.

Use server.handleMessageEvent(event) inside a message event listener to dispatch RPC calls and post responses back.

const server = new Server(handler, 'https://client.example.com');
globalThis.addEventListener('message', server.handleMessageEvent.bind(server));