# @mys-x/m-rpc

> A message based RPC library.

Latest version **0.12.2** (published 2024-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mys-x/m-rpc
pnpm add @mys-x/m-rpc
yarn add @mys-x/m-rpc
bun add @mys-x/m-rpc
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.12.2 |
| Published | 2024-05-05 |
| First published | 2024-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 49.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3 |
| Author | mys1024 |
| Maintainers | mys1024 |
| Keywords | deno, message, RPC, WebSocket, MessagePort, function, call |

## Links

- npm: https://www.npmjs.com/package/@mys-x/m-rpc
- Repository: https://github.com/mys1024/m-rpc
- Homepage: https://github.com/mys1024/m-rpc#readme
- Issues: https://github.com/mys1024/m-rpc/issues
- npm.io page: https://npm.io/package/@mys-x/m-rpc

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.12.2 (latest) — 2024-05-05
- 0.12.1 — 2024-04-21
- 0.12.0 — 2024-04-21
- 0.11.2 — 2024-04-20
- 0.11.1 — 2024-04-13
- 0.11.0 — 2024-04-13
- 0.10.1 — 2024-03-24
- 0.9.8 — 2024-03-22

## README

<div align="center">

# m-rpc

[![jsr-version](https://img.shields.io/jsr/v/%40mys/m-rpc?style=flat-square&color=%23f7df1e)](https://jsr.io/@mys/m-rpc)
[![npm-version](https://img.shields.io/npm/v/%40mys-x%2Fm-rpc?style=flat-square&color=%23cb3837)](https://www.npmjs.com/package/@mys-x/m-rpc)
[![npm-minzip](https://img.shields.io/bundlephobia/minzip/%40mys-x%2Fm-rpc?style=flat-square&label=minzip)](https://bundlephobia.com/package/@mys-x/m-rpc)
[![docs](https://img.shields.io/badge/docs-reference-blue?style=flat-square)](https://jsr.io/@mys/m-rpc/doc?style=flat-square)
[![stars](https://img.shields.io/github/stars/mys1024/m-rpc?style=flat-square)](https://github.com/mys1024/m-rpc)
[![license](https://img.shields.io/github/license/mys1024/m-rpc?&style=flat-square)](./LICENSE)

[![coverage](https://img.shields.io/codecov/c/github/mys1024/m-rpc?style=flat-square)](https://app.codecov.io/gh/mys1024/m-rpc)
[![workflow-ci](https://img.shields.io/github/actions/workflow/status/mys1024/m-rpc/ci.yml?label=ci&style=flat-square)](https://github.com/mys1024/m-rpc/actions/workflows/ci.yml)
[![workflow-release](https://img.shields.io/github/actions/workflow/status/mys1024/m-rpc/release.yml?label=release&style=flat-square)](https://github.com/mys1024/m-rpc/actions/workflows/release.yml)

_A message based RPC library._

</div>

## Usage

### basic

```typescript
import { MRpc } from "@mys-x/m-rpc"; // or "jsr:@mys/m-rpc"

function add(a: number, b: number) {
  return a + b;
}

// The port can be a MessagePort, a WebSocket, a Worker, or a WorkerGlobalScope
const { port1, port2 } = new MessageChannel();
const rpc1 = new MRpc(port1);
const rpc2 = new MRpc(port2);

rpc1.defineLocalFn("add", add);
await rpc2.callRemoteFn<typeof add>("add", [1, 2]); // 3
```

## License

[MIT](./LICENSE) License &copy; 2024-PRESENT
[mys1024](https://github.com/mys1024)

---
_Source: https://npm.io/package/@mys-x/m-rpc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
