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

json-rpc-interface

v1.0.1

Published

Create a JSON RPC server to communicate with other processes. Can be used to communicate with text editors using LSP.

Readme

JSON-RPC-Interface

A library for communicating with other processes as a JSON RPC server.

Can be used to communicate with text editors using LSP

How to use:

Simple to use interface, only 4 functions that you need to know:

onRequest

onRequest events allow you to send a return value back to the process.

jsonRpc.onRequest(name, handler)

name: string - the name of the request handler: function - The function will receieve a params object and can return a value back to the requester The handler function may be async or return a promise.

onNotification

Similar to onRequest, except notifier is not expecting a return value

jsonRpc.onNotification(name, handler)

sendRequest

An async function that sends a request to the client process and returns a promise that will resolve with the response from the client.

const response = await jsonRpc.sendRequest('request-name', {data: "request-params"})

sendNotification

Similar to sendRequest, however there is no response to wait for, so this function has no return value.

jsonRpc.sendNotification('notification-name', {data: "notification-params"})

Example:

Here is quick example using this library to create an LSP server for text editors.

  // Create the server using stdin and stdout as the input and output streams
  const jsonRpc = new JsonRpcInterface({ inputStream: process.stdin, outputStream: process.stdout })

  jsonRpc.onRequest("initialize", (params) => {
    return {
      serverInfo: {
        name: "My LSP Server",
        version: "1.0.0",
      },
      capabilities: {
        textDocumentSync: 1, // full text sync
      },
    }
  })

  // use this function to hook into initalized event
  jsonRpc.onNotification("initialized", () => {
  })

  // handle shutdown and exit requests and notificaitons
  jsonRpc.onRequest("shutdown", () => {
    return null
  })

  jsonRpc.onNotification("exit", () => {
    process.exit(0)
  })

  // handle LSP file open and change notifications
  jsonRpc.onNotification("textDocument/didOpen", (params) => {
  })

  jsonRpc.onNotification("textDocument/didChange", (params) => {
  })
}

100% Test coverage for all files

$ npm test

 RUN  v3.2.4 /Users/niels/dev/src/json-rpc-interface
      Coverage enabled with v8

 ✓ src/LspWriter.test.js (9 tests) 3ms
 ✓ src/LspReader.test.js (33 tests) 5ms
 ✓ src/JsonRpcInterface.test.js (27 tests) 7ms

 Test Files  3 passed (3)
      Tests  69 passed (69)
   Start at  13:35:13
   Duration  262ms (transform 40ms, setup 0ms, collect 67ms, tests 15ms, environment 0ms, prepare 114ms)

 % Coverage report from v8
------------------------|---------|----------|---------|---------|-------------------
File                    | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------------------|---------|----------|---------|---------|-------------------
All files               |     100 |      100 |     100 |     100 |
 json-rpc-interface     |     100 |      100 |     100 |     100 |
  index.js              |     100 |      100 |     100 |     100 |
 json-rpc-interface/src |     100 |      100 |     100 |     100 |
  JsonRpcInterface.js   |     100 |      100 |     100 |     100 |
  LspReader.js          |     100 |      100 |     100 |     100 |
  LspWriter.js          |     100 |      100 |     100 |     100 |
  constants.js          |     100 |      100 |     100 |     100 |