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

@x-oasis/async-call-rpc-node

v0.13.0

Published

Node.js transport adapters (child_process.fork) for @x-oasis/async-call-rpc

Downloads

2,144

Readme

@x-oasis/async-call-rpc-node

Node.js 传输层适配器,为 @x-oasis/async-call-rpc 提供基于 child_process.fork() IPC 的通道实现。

安装

pnpm add @x-oasis/async-call-rpc-node @x-oasis/async-call-rpc

核心概念

本包提供 NodeProcessChannel,基于 Node.js child_process.fork() 建立的 IPC 通道进行双向 RPC 通信。

| 类 | 传输层 | 使用场景 | | -------------------- | -------------------------- | ------------------- | | NodeProcessChannel | child_process.fork() IPC | 父子进程间 RPC 通信 |

快速开始

父进程

import { fork } from 'child_process';
import { NodeProcessChannel } from '@x-oasis/async-call-rpc-node';
import { serviceHost, clientHost } from '@x-oasis/async-call-rpc';

const child = fork('./worker.js');
const channel = new NodeProcessChannel({
  process: child,
  description: 'parent→child',
});

// 注册本地服务(子进程可以反向调用)
const service = serviceHost.registerService('main', {
  getTimestamp: () => Date.now(),
});
service.setChannel(channel);

// 创建远程代理,调用子进程中的方法
const workerProxy = clientHost
  .registerClient('worker', { channel })
  .createProxy<{
    compute(n: number): Promise<number>;
    ping(): Promise<string>;
  }>();

const result = await workerProxy.compute(42);

子进程 (worker.js)

import { NodeProcessChannel } from '@x-oasis/async-call-rpc-node';
import { serviceHost } from '@x-oasis/async-call-rpc';

const channel = new NodeProcessChannel({
  process,
  description: 'child→parent',
});

const service = serviceHost.registerService('worker', {
  ping: () => 'pong',
  compute: (n: number) => n * 2,
});
service.setChannel(channel);

API 参考

NodeProcessChannel

new NodeProcessChannel(props: {
  process: ChildProcess | NodeJS.Process;
} & AbstractChannelProtocolProps)
  • process — 父进程侧传 fork() 返回的 ChildProcess,子进程侧传全局 process
  • 子进程退出时自动断开连接
  • IPC 消息会被包装为 { data: message } 形式以兼容 normalize 中间件
  • send() 通过 process.send() 发送,如果 IPC 通道不可用会打印警告

注意事项:

  • 进程必须通过 child_process.fork() 创建(而非 spawnexec),因为只有 fork() 会自动建立 IPC 通道
  • fork() 使用 structured clone 序列化,因此默认的 JSON 序列化格式通常足够使用

运行测试

pnpm test

License

ISC