Comparing version 0.3.1 to 0.3.2
@@ -1118,2 +1118,4 @@ 'use strict'; | ||
_context.prev = 12; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore params can be undefined | ||
handled = handler(ctx, msg.params); | ||
@@ -1120,0 +1122,0 @@ |
@@ -1116,2 +1116,4 @@ import { nanoid } from 'nanoid'; | ||
_context.prev = 12; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore params can be undefined | ||
handled = handler(ctx, msg.params); | ||
@@ -1118,0 +1120,0 @@ |
import type { RPCErrorResponse, RPCMethods, RPCRequest, RPCResponse, RPCResultResponse } from './types'; | ||
export declare type ErrorHandler<Context, Methods extends RPCMethods> = <K extends keyof Methods>(ctx: Context, req: RPCRequest<Methods, K>, error: Error) => void; | ||
export declare type MethodHandler<Context, Params, Result> = (ctx: Context, params?: Params) => Result | Promise<Result>; | ||
export declare type MethodHandler<Context, Params = undefined, Result = undefined> = Params extends undefined ? (ctx: Context, params?: undefined) => Result | Promise<Result> : (ctx: Context, params: Params) => Result | Promise<Result>; | ||
export declare type NotificationHandler<Context, Methods extends RPCMethods> = <K extends keyof Methods>(ctx: Context, req: RPCRequest<Methods, K>) => void; | ||
@@ -5,0 +5,0 @@ export declare type HandlerMethods<Context, Methods extends RPCMethods> = { |
{ | ||
"name": "rpc-utils", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"author": "Paul Le Cam <paul@3box.io>", | ||
@@ -26,6 +26,6 @@ "license": "(Apache-2.0 OR MIT)", | ||
"dependencies": { | ||
"nanoid": "^3.1.20" | ||
"nanoid": "^3.1.21" | ||
}, | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^4.9.2", | ||
"@size-limit/preset-small-lib": "^4.10.1", | ||
"@types/nanoid": "^2.1.0", | ||
@@ -36,6 +36,6 @@ "eslint": "^7.21.0", | ||
"prettier": "^2.2.1", | ||
"size-limit": "^4.9.2", | ||
"size-limit": "^4.10.1", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.2.2" | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -42,0 +42,0 @@ "husky": { |
@@ -16,6 +16,9 @@ import { ERROR_CODE, RPCError, createParseError, getErrorMessage } from './error' | ||
export type MethodHandler<Context, Params, Result> = ( | ||
ctx: Context, | ||
params?: Params | ||
) => Result | Promise<Result> | ||
export type MethodHandler< | ||
Context, | ||
Params = undefined, | ||
Result = undefined | ||
> = Params extends undefined | ||
? (ctx: Context, params?: undefined) => Result | Promise<Result> | ||
: (ctx: Context, params: Params) => Result | Promise<Result> | ||
@@ -108,2 +111,4 @@ export type NotificationHandler<Context, Methods extends RPCMethods> = <K extends keyof Methods>( | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore params can be undefined | ||
const handled = handler(ctx, msg.params) | ||
@@ -110,0 +115,0 @@ const result = |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
270168
2406
Updatednanoid@^3.1.21