Socket
Socket
Sign inDemoInstall

json-rpc-middleware-stream

Package Overview
Dependencies
Maintainers
10
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rpc-middleware-stream - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

6

dist/createEngineStream.d.ts

@@ -0,6 +1,6 @@

import type { JsonRpcEngine } from '@metamask/json-rpc-engine';
import { Duplex } from 'readable-stream';
import { JsonRpcEngine } from '@metamask/json-rpc-engine';
interface EngineStreamOptions {
declare type EngineStreamOptions = {
engine: JsonRpcEngine;
}
};
/**

@@ -7,0 +7,0 @@ * Takes a JsonRpcEngine and returns a Duplex stream wrapping it.

@@ -12,3 +12,3 @@ "use strict";

function createEngineStream(opts) {
if (!opts || !opts.engine) {
if (!(opts === null || opts === void 0 ? void 0 : opts.engine)) {
throw new Error('Missing engine parameter!');

@@ -30,9 +30,9 @@ }

* @param _encoding - The stream encoding, not used.
* @param cb - The stream write callback.
* @param streamWriteCallback - The stream write callback.
*/
function write(req, _encoding, cb) {
function write(req, _encoding, streamWriteCallback) {
engine.handle(req, (_err, res) => {
stream.push(res);
});
cb();
streamWriteCallback();
}

@@ -39,0 +39,0 @@ }

@@ -0,8 +1,8 @@

import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import SafeEventEmitter from '@metamask/safe-event-emitter';
import type { JsonRpcParams } from '@metamask/utils';
import { Duplex } from 'readable-stream';
import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';
import type { JsonRpcParams } from '@metamask/utils';
interface Options {
declare type Options = {
retryOnMessage?: string;
}
};
/**

@@ -9,0 +9,0 @@ * Creates a JsonRpcEngine middleware with an associated Duplex stream and

@@ -46,6 +46,6 @@ "use strict";

* @param _encoding - The stream encoding, not used.
* @param cb - The stream write callback.
* @param streamWriteCallback - The stream write callback.
*/
function processMessage(res, _encoding, cb) {
let err = null;
function processMessage(res, _encoding, streamWriteCallback) {
let errorObj = null;
try {

@@ -61,6 +61,6 @@ const isNotification = !res.id;

catch (_err) {
err = _err;
errorObj = _err;
}
// continue processing stream
cb(err);
streamWriteCallback(errorObj);
}

@@ -73,8 +73,9 @@ /**

function processResponse(res) {
const context = idMap[res.id];
const responseId = res.id;
const context = idMap[responseId];
if (!context) {
console.warn(`StreamMiddleware - Unknown response id "${res.id}"`);
console.warn(`StreamMiddleware - Unknown response id "${responseId}"`);
return;
}
delete idMap[res.id];
delete idMap[responseId];
// copy whole res onto original res

@@ -81,0 +82,0 @@ Object.assign(context.res, res);

{
"name": "json-rpc-middleware-stream",
"version": "5.0.0",
"version": "5.0.1",
"description": "A small toolset for streaming JSON-RPC data and matching requests and responses.",

@@ -17,6 +17,7 @@ "repository": {

"build:clean": "rimraf dist && yarn build",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:dependencies",
"lint:dependencies": "depcheck",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
"prepublishOnly": "yarn build:clean && yarn lint && yarn test",

@@ -37,22 +38,24 @@ "setup": "yarn install && yarn allow-scripts",

"@metamask/auto-changelog": "^3.0.0",
"@metamask/eslint-config": "^9.0.0",
"@metamask/eslint-config-jest": "^9.0.0",
"@metamask/eslint-config-nodejs": "^9.0.0",
"@metamask/eslint-config-typescript": "^9.0.1",
"@metamask/eslint-config": "^12.0.0",
"@metamask/eslint-config-jest": "^12.0.0",
"@metamask/eslint-config-nodejs": "^12.0.0",
"@metamask/eslint-config-typescript": "^12.0.0",
"@types/jest": "^26.0.13",
"@types/node": "^17.0.23",
"@types/readable-stream": "^2.3.9",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.4",
"eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"depcheck": "^1.4.5",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^39.3.3",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"extension-port-stream": "^2.0.1",
"jest": "^27.5.1",
"jest-it-up": "^2.0.2",
"prettier": "^2.2.1",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.2.17",

@@ -62,5 +65,6 @@ "rimraf": "^3.0.2",

"ts-node": "^10.7.0",
"typescript": "^4.2.4",
"typescript": "~4.8.4",
"webextension-polyfill-ts": "^0.26.0"
},
"packageManager": "yarn@3.6.3",
"engines": {

@@ -67,0 +71,0 @@ "node": "^16.20 || ^18.16 || >=20"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc