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

ameba-rpc

v1.5.0

Published

Simply core implementation of pure RPC engine.

Readme

Ameba pure RPC engine

Core implementation of pure RPC engine in TypeScript.

ameba-rpc

Project Status: Active – The project has reached a stable, usable state and is being actively developed. License: MIT npm version


What is this?

Are you tired of struggling with the choice of RPC to use for intercommunication between systems, or of doing the same and different implementations over and over again? This library is a pure RPC engine based on TypeScript, extracting only the core features of RPC.

You only need to consider the following two points:

  • How to serialize/deserialize RPC messages (the simplest is just to JSON.stringfy()/JSON.parse())
  • Methods for sending and receiving RPC messages (any method is acceptable, including HTTP/WebSocket/IPC/Cloud MQ service, etc.)

The RPC engine provides the following functionality:

  • Identification of the calling function by identifier (string).
  • Can use arbitrary values (primitive values, objects and function objects).
  • All functions return Promise<T>, so they are fully asynchronous operation.
  • Can expose asynchronous-generator AsyncGenerator<T, void, unknown>, it handles streaming value transfer.
  • Arguments can be AbortSignal.

Function objects can be specified as arguments and return values. In other words, callback RPC is also supported. RPC implementation, "Fully symmetric" and "Full-duplex" asynchronous mutual callable.


Usage

To get the Ameba pure RPC engine working, you will need to perform the following two steps:

  1. Create an RPC controller to send and receive RPC messages.
  2. Register RPC callable functions in the RPC controller.

Create and setup controller pair

Create Ameba RPC controller each instance domain.

In doing so, specify a handler onSendMessage that handles RPC messages that should be sent to the peer controller. It also calls insertMessage(), which tells the controller the RPC message received from the peer controller.

import { createAmebaRpcController } from 'ameba-rpc';

// Create Ameba RPC controller
const controller = createAmebaRpcController({
  // Handler for RPC message sending
  onSendMessage: async message => {
    // S1. Serialize RPC message to JSON
    const messageJson = JSON.stringify(message);
    // S2. Send to the peer controller
    await fetch(
      'http://example.com/rpc', {  // Example using fetch API to send message
        method: 'POST',
        headers: { "Content-Type": "application/json" },
        body: messageJson
    });
  }
});

// ...

// R1. Got peer message from HTTP/SSE/WebSocket/MQ/etc...
const messageJson = ...

// R2. Deserialize peer message from JSON
const message = JSON.parse(messageJson);
// Insert peer message to controller
controller.insertMessage(message);

Register functions

The following code exposes the add function to the peer controller.

Note that the function to be exposed returns Promise<T>. What types can be used depends on the types supported by serialization and reverse serialization. If you are using TypeScript or JavaScript, you will find that you can specify JSON with almost the same feeling as accessing a Web API.

// Register `add` function (asynchronous function)
const disposer = controller.register({
  // add: (a: number, b: number) => a + b
  'add',
  async (a: number, b: number): Promise<number> => {
    return a + b;
  }
);

// ...

// Remove `add` function
disposer.release();

For more information, see repository documents.


License

Under MIT.