Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grpc-util

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-util - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0-0

.editorconfig

4

lib/index.d.ts

@@ -1,2 +0,2 @@

import { ServiceDefinition } from "grpc";
export declare function catchGrpcPromiseErrors<T>(serviceDef: ServiceDefinition<T>, serviceImplCtor: new (...args: any[]) => T, errorHandler?: (err: any) => void): void;
export * from './catchGrpcPromiseErrors';
export * from './promisifyGrpcClient';
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
function catchGrpcPromiseUnaryError(serviceDef, rpcName, serviceImplCtor) {
const originalRpc = serviceImplCtor.prototype[rpcName];
serviceImplCtor.prototype[rpcName] = function (call, originalCallback) {
return __awaiter(this, void 0, void 0, function* () {
let callbackInvoked = false;
const callback = (err, response) => {
if (callbackInvoked) {
// @TODO: Warn about multi invoke of callback
}
callbackInvoked = true;
return originalCallback(err, response);
};
try {
const result = originalRpc.call(this, call, callback);
yield result;
}
catch (err) {
callback(err, null);
throw err;
}
if (!callbackInvoked) {
callback(new Error('Callback not invoked after promise fullfilled'), null);
}
});
};
}
function catchGrpcPromiseBidiError(serviceDef, rpcName, serviceImplCtor) {
// @TODO: Implement bidi stream catch
}
function catchGrpcPromiseRequestStreamError(serviceDef, rpcName, serviceImplCtor) {
// @TODO: Implement request stream catch
}
function catchGrpcPromiseResponseStreamError(serviceDef, rpcName, serviceImplCtor) {
// @TODO: Implement response stream catch
}
function catchGrpcPromiseErrors(serviceDef, serviceImplCtor, errorHandler) {
for (let rpcName in serviceDef) {
const rpcDef = serviceDef[rpcName];
if (!rpcDef.requestStream && !rpcDef.responseStream) {
catchGrpcPromiseUnaryError(serviceDef, rpcName, serviceImplCtor);
}
else if (rpcDef.requestStream && rpcDef.responseStream) {
catchGrpcPromiseBidiError(serviceDef, rpcName, serviceImplCtor);
}
else if (rpcDef.requestStream) {
catchGrpcPromiseRequestStreamError(serviceDef, rpcName, serviceImplCtor);
}
else if (rpcDef.responseStream) {
catchGrpcPromiseResponseStreamError(serviceDef, rpcName, serviceImplCtor);
}
}
}
exports.catchGrpcPromiseErrors = catchGrpcPromiseErrors;
__export(require("./catchGrpcPromiseErrors"));
__export(require("./promisifyGrpcClient"));
{
"name": "grpc-util",
"version": "0.1.0",
"version": "0.2.0-0",
"description": "",

@@ -23,2 +23,3 @@ "main": "lib/index.js",

"devDependencies": {
"@types/node": "^10.12.18",
"ava": "^1.0.1",

@@ -25,0 +26,0 @@ "grpc": "^1.17.0",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc