# stdio-jsonrpc

> JSON RPC throught stdio

Latest version **0.1.3** (published 2019-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install stdio-jsonrpc
pnpm add stdio-jsonrpc
yarn add stdio-jsonrpc
bun add stdio-jsonrpc
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2019-02-13 |
| First published | 2019-02-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mathieu Dutour |
| Maintainers | mathieudutour |
| Keywords | json, rpc, jsonrpc, stdio |

## Links

- npm: https://www.npmjs.com/package/stdio-jsonrpc
- npm.io page: https://npm.io/package/stdio-jsonrpc

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.3 (latest) — 2019-02-13
- 0.1.2 — 2019-02-13
- 0.1.1 — 2019-02-13
- 0.1.0 — 2019-02-06

## README

# stdio-JSONRPC

Leverage [JSON-RPC](https://www.jsonrpc.org) to communicate with another process via stdio

## Installation

```bash
npm install stdio-jsonrpc
```

## Usage

```js
const {setup, sendNotification, sendRequest, RPCError} = require('stdio-jsonrpc')

setup({
  onNotification(method, params) {
    // handle a notification
  },
  onRequest(method, params, callback) {
    // handle a request

    callback(new RPCError.MethodNotFound())
  }
})

sendRequest('ping').then(pong => {
  sendNotification('pong', { msg: pong })
})
.catch(err => {
  // something bad happened
})
```

## API

```
setup: ({
  onNotification: (method: string, params: any) -> void
  onRequest: (method: string, params: any, callback: (error: Error | null, result: any) -> void) -> void
}) -> void

sendNotification: (method: string, params?: any) -> void

sendRequest: (method: string, params?: any, timeout?: Number) -> Promise<any>

RPCError: {
  ParseError: (data: any) -> Error
  InvalidRequest: (data: any) -> Error
  MethodNotFound: (data: any) -> Error
  InvalidParams: (data: any) -> Error
  InternalError: (data: any) -> Error
}
```

## License

MIT

---
_Source: https://npm.io/package/stdio-jsonrpc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
