Socket
Socket
Sign inDemoInstall

vscode-jsonrpc

Package Overview
Dependencies
0
Maintainers
7
Versions
125
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-jsonrpc

A json rpc implementation over streams


Version published
Maintainers
7
Weekly downloads
1,982,476
decreased by-1.45%

Weekly downloads

Readme

Source

VSCode JSON RPC

NPM Version NPM Downloads Build Status

This npm module implements the base messaging protocol spoken between a VSCode language server and a VSCode language client.

The npm module can also be used standalone to establish a JSON-RPC channel between a client and a server. Below an example how to setup a JSON-RPC connection. First the client side.

import * as cp from 'child_process';
import * as rpc from 'vscode-jsonrpc/node';

let childProcess = cp.spawn(...);

// Use stdin and stdout for communication:
let connection = rpc.createMessageConnection(
	new rpc.StreamMessageReader(childProcess.stdout),
	new rpc.StreamMessageWriter(childProcess.stdin));

let notification = new rpc.NotificationType<string, void>('testNotification');

connection.listen();

connection.sendNotification(notification, 'Hello World');

The server side looks very symmetrical:

import * as rpc from 'vscode-jsonrpc/node';


let connection = rpc.createMessageConnection(
	new rpc.StreamMessageReader(process.stdin),
	new rpc.StreamMessageWriter(process.stdout));

let notification = new rpc.NotificationType<string, void>('testNotification');
connection.onNotification(notification, (param: string) => {
	console.log(param); // This prints Hello World
});

connection.listen();

History

5.0.0

  • add progress support
  • move JS target to ES2017

4.0.0

  • move JS target to ES6.

3.0.0:

  • converted the NPM module to use TypeScript 2.0.3.
  • added strict null support.
  • support for passing more than one parameter to a request or notification.
  • Breaking changes:
    • due to the use of TypeScript 2.0.3 and differences in d.ts generation users of the new version need to move to TypeScript 2.0.3 as well.

License

MIT

FAQs

Last updated on 19 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc