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

@cspell/rpc

v9.7.0

Published

Type Safe RPC library.

Readme

Simple RPC

A basic client / server RPC for sending the requests over a MessagePort.

This supports Node Worker Threads, Web Workers, or anything that can provide a MessagePortLike interface.

Communication Details

The client and server communicate by sending messages over the MessagePort.

export interface RPCMessage {
  sig: 'RPC0';
  /**
   * A Unique identifier for the request/response.
   * Ideally this is a randomUUID.
   */
  id: RequestID;
  /**
   * The type of message being sent.
   */
  type: 'request' | 'response' | 'cancel' | 'canceled' | 'ok' | 'ready';
}

export type RPCRequestType = 'request' | 'cancel' | 'ok' | 'ready';

export type RPCResponseType = 'response' | 'canceled' | 'ok' | 'ready';

There are two types of messages: Request and Response. The client sends requests and the server sends responses.

RPC Request

sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    W->>-S: Result
    S->>-C: Response <id>, Result

RPC Request with ACK

sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>, ACK
    S->>C: ACK <id>
    S->>+W: Method
    W->>-S: Result
    S->>-C: Response <id>, Result

RPC Request with Error

sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>, ACK
    S->>C: ACK <id>
    S->>+W: Method
    W->>-S: Error
    S->>-C: Response <id>, Error

OK Request

This request is used to check if the server is ok.

sequenceDiagram
    Client->>Server: OK <id>?
    Server->>Client: OK <id>, Code 200

Cancel Request

A cancellation request is used to cancel or abort a request. The server accepts the request and acknowledges that it was received. It does not wait

Cancel Request: no wait

sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    C->>S: Cancel <id>
    S->>-C: Canceled <id>
    S--xW: Cancel
    W--x-S: Canceled

Cancel Request: wait

sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    C->>S: Cancel <id>, Wait
    S--xW: Cancel
    W-->>-S: Canceled
    S->>-C: Canceled <id>

RPC Request, Canceled by Server

It can happen that the server needs to cancel requests. This can happen if the server is getting disposed and still has pending requests. It has a couple of ways to do this:

  1. Send an Error Response
  2. Send a Canceled Response
sequenceDiagram
    participant C as Client
    participant S as Server
    participant W as Worker
    C->>+S: Request <id>
    S->>+W: Method
    W--x-S: Canceled
    S->>-C: Canceled <id>

Abort

An abort request is the same as a Cancel request, only the client will not wait on a response and the response will be ignored.

sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: Request <id>
    C-->>S: Cancel <id>
    S--xC: Canceled <id>